Skip to content

Commit

Permalink
Alpha-1.0.1 is here!
Browse files Browse the repository at this point in the history
  • Loading branch information
Jachou-yt committed Oct 8, 2023
1 parent 31c09f1 commit 86283ae
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ Indisponible pour le moment.
Pour réanimer un joueur, il suffit de faire un clic droit sur lui. Le joueur sera réanimé au bout de 5 secondes.
## Commandes

Indisponible pour le moment.
- /reanimate
- Description : Permet de réanimer un joueur.
- Utilisation : `/reanimate <joueur>`
- Permission : `reanimatemc.reanimate`

## Permissions

Expand Down
11 changes: 8 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fr.jachou</groupId>
<artifactId>ReanimateMC</artifactId>
<version>1.20.1-alpha-1.0.0</version>
<version>1.20.1-alpha-1.0.1</version>
<packaging>jar</packaging>

<name>ReanimateMC</name>
Expand All @@ -23,8 +23,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -70,5 +70,10 @@
<version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</project>
27 changes: 21 additions & 6 deletions src/main/java/fr/jachou/reanimatemc/ReanimateMC.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,46 @@

package fr.jachou.reanimatemc;

import fr.jachou.reanimatemc.commands.ReanimateCommand;
import fr.jachou.reanimatemc.events.PlayerEvents;
import fr.jachou.reanimatemc.utils.KOPlayers;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bstats.bukkit.Metrics;
import org.bukkit.plugin.java.JavaPlugin;

public final class ReanimateMC extends JavaPlugin {

private static ReanimateMC instance;
private static final String PREFIX = "§7[§cReanimateMC§7] §r";
public static final String PREFIX = "§7[§cReanimateMC§7] §r";


@Override
public void onEnable() {
// Plugin startup logic
instance = this;

// bStats
int pluginId = 20003;
Metrics metrics = new Metrics(this, pluginId);


registerEvents(this);
registerCommands(this);

new BukkitRunnable() {
registerRunnable(new BukkitRunnable() {
@Override
public void run() {
// Vérifiez chaque joueur en jeu
for (Player player : Bukkit.getOnlinePlayers()) {
// Vérifiez si le joueur a un cœur ou moins (20 = plein cœur)
if (player.getHealth() <= 3 && !player.hasMetadata("frozen")) {
// Faites quelque chose ici, par exemple envoyer un message au joueur :
KOPlayers.koPlayer(player);
}
}
}
}.runTaskTimer(this, 0L, 20L);
});
}


Expand All @@ -55,6 +61,15 @@ private void registerEvents(Plugin plugin) {
getServer().getPluginManager().registerEvents(new PlayerEvents(), plugin);
}

private void registerCommands(Plugin plugin) {
getCommand("reanimate").setExecutor(new ReanimateCommand());
}

private void registerRunnable(BukkitRunnable runnable) {
runnable.runTaskTimer(this, 0L, 20L);
}


public static ReanimateMC getInstance() {
return instance;
}
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/fr/jachou/reanimatemc/commands/ReanimateCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package fr.jachou.reanimatemc.commands;

import fr.jachou.reanimatemc.ReanimateMC;
import fr.jachou.reanimatemc.utils.PlayerFreezeUtil;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class ReanimateCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length < 1) {
sender.sendMessage(ReanimateMC.PREFIX + "§cUsage: /reanimate <player>");
return false;
}

Player target = Bukkit.getPlayer(args[0]);

if (target == null || !target.isOnline()) {
sender.sendMessage(ReanimateMC.PREFIX + "§cPlayer not found or not online.");
return false;
}

if (PlayerFreezeUtil.playerIsFreezed(target)) {
PlayerFreezeUtil.unfreezePlayer(target);
sender.sendMessage(ReanimateMC.PREFIX + "§aThis player is no longer KO.");
} else {
sender.sendMessage(ReanimateMC.PREFIX + "§cThis player isn't KO.");
}

return true;
}
}
17 changes: 3 additions & 14 deletions src/main/java/fr/jachou/reanimatemc/utils/PlayerFreezeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,13 @@

public class PlayerFreezeUtil {
public static void freezePlayer(Player player) {
// Vous pouvez utiliser des métadonnées ou une autre méthode pour marquer le joueur comme gelé
// Par exemple, en ajoutant une métadonnée "frozen" comme nous l'avons vu précédemment
player.setWalkSpeed(0);
player.setFlySpeed(0);

// Ensuite, désactivez la capacité de déplacement du joueur
player.setWalkSpeed(0); // Le joueur ne pourra pas marcher
player.setFlySpeed(0); // Le joueur ne pourra pas voler (si applicable)

// Désactivez d'autres actions potentielles, comme les clics de souris

player.setAllowFlight(false);
player.setInvulnerable(true);

// Désactivez les clics de souris
player.setCanPickupItems(false);
player.setCollidable(false);
player.setGliding(false);
Expand All @@ -32,21 +26,17 @@ public static void freezePlayer(Player player) {

player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 99999999, 1));

// Vous pouvez également afficher un message au joueur pour indiquer qu'il est gelé
player.sendMessage("You can't move... Wait for someone to revive you !");

player.setMetadata("frozen", new FixedMetadataValue(ReanimateMC.getInstance(), true));
}

public static void unfreezePlayer(Player player) {
// Réactivez la capacité de déplacement du joueur
player.setWalkSpeed(0.2f); // Réglez la vitesse de marche par défaut (0.2f)
player.setWalkSpeed(0.2f);

// Réactivez d'autres actions potentielles, comme les clics de souris
player.setAllowFlight(true);
player.setInvulnerable(false);

// Réactivez les clics de souris
player.setCanPickupItems(true);
player.setCollidable(true);
player.setGliding(true);
Expand All @@ -57,7 +47,6 @@ public static void unfreezePlayer(Player player) {

player.removePotionEffect(PotionEffectType.BLINDNESS);

// Affichez un message au joueur pour indiquer qu'il a été réanimé
player.sendMessage("You have been revived !");

new BukkitRunnable() {
Expand Down
Empty file added src/main/resources/config.yml
Empty file.
9 changes: 7 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
name: ReanimateMC
version: '1.0'
version: 'alpha-1.0.1'
main: fr.jachou.reanimatemc.ReanimateMC
description: ReanimateMC plugin for Minecraft
description: ReanimateMC plugin for Minecraft
commands:
reanimate:
description: Reanimate a dead player
usage: /<command> <player>
permission: reanimatemc.reanimate

0 comments on commit 86283ae

Please sign in to comment.