From e2be425513a843447f330ea925e14b4dae1669bc Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 29 Mar 2015 22:22:07 -0400 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20de=20la=20commande=20/ghost=20+?= =?UTF-8?q?=20Correction=20de=20bugs=20relatifs=20aux=20=C3=A9v=C3=A8nemen?= =?UTF-8?q?ts=20+=20am=C3=A9lioration=20de=20l'efficacit=C3=A9=20du=20vani?= =?UTF-8?q?sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/CommandGhost.java | 125 ++++++++++++++++++ .../listener/PlayerListener.java | 18 ++- .../modules/fun/GhostManager.java | 11 ++ .../protection/NoPvpProtectManager.java | 10 +- .../pandacraftutils/players/OffPlayer.java | 5 +- 5 files changed, 156 insertions(+), 13 deletions(-) create mode 100644 src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandGhost.java diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandGhost.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandGhost.java new file mode 100644 index 0000000..c63f28b --- /dev/null +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/commands/CommandGhost.java @@ -0,0 +1,125 @@ +package net.mc_pandacraft.java.plugin.pandacraftutils.commands; + +import java.util.List; +import java.util.Random; + +import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.config.elements.WorldBorderConfigEntry; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class CommandGhost extends AbstractCommandExecutor { + + public CommandGhost() { + super("ghost"); + } + + + + + @Override + public boolean onCommand(CommandSender sender, Command cmd, String label, + String[] args) { + + if (!(sender instanceof Player)) { + sender.sendMessage(ChatColor.RED+"Vous devez être en ligne pour faire cette commande"); + return true; + } + + Player player = (Player) sender; + + if (args.length == 0) { + showHelp(player); + return true; + } + + if (args.length >= 1 && args[0].equalsIgnoreCase("thor")) { + onCommandThor(player); + return true; + } + + + + + + + + // on arrive ici si aucune des sous commandes correspond à celle tapée + sender.sendMessage(ChatColor.RED+"Mauvaise utilisation de la commande. Faites "+ChatColor.GRAY+"/ghost"+ChatColor.RED+" pour connaitre l'utilisation"); + + + return true; + } + + + + + private void showHelp(Player player) { + + + } + + + + + + + + + + private void onCommandThor(Player player) { + + List worlds = plugin.getServer().getWorlds(); + + Random r = new Random(); + + for (World w : worlds) { + + int nbStrike = r.nextInt(2)+1; + + for (int i=0; i "+ChatColor.ITALIC+"%2$s"); + } + + + + diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/NoPvpProtectManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/NoPvpProtectManager.java index f7f3561..79f156a 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/NoPvpProtectManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/protection/NoPvpProtectManager.java @@ -77,7 +77,7 @@ public class NoPvpProtectManager { for (Player pl : pls) { // on ne compte pas le poseur (sinon, on y arrivera pas x) ) - if (pl == p || pl.getGameMode() == GameMode.CREATIVE) + if (pl == p || !pl.isOnline() || pl.getGameMode() == GameMode.CREATIVE) continue; if (OnlinePlayerManager.get(pl).isVanished()) @@ -119,7 +119,7 @@ public class NoPvpProtectManager { for (Player pl : pls) { // on ne compte pas le poseur (sinon, on y arrivera pas x) ) - if (pl == p || pl.getGameMode() == GameMode.CREATIVE) + if (pl == p || !pl.isOnline() || pl.getGameMode() == GameMode.CREATIVE) continue; if (OnlinePlayerManager.get(pl).isVanished()) @@ -164,7 +164,7 @@ public class NoPvpProtectManager { for (Player pl : pls) { // on ne compte pas le poseur (sinon, on y arrivera pas x) ) - if (pl == p || pl.getGameMode() == GameMode.CREATIVE) + if (pl == p || !pl.isOnline() || pl.getGameMode() == GameMode.CREATIVE) continue; if (OnlinePlayerManager.get(pl).isVanished()) @@ -204,7 +204,7 @@ public class NoPvpProtectManager { for (Player pl : pls) { // on ne compte pas le poseur (sinon, on y arrivera pas x) ) et on ignorent ceux qui fly - if (pl == p || pl.isFlying()) + if (pl == p || !pl.isOnline() || pl.isFlying()) continue; if (OnlinePlayerManager.get(pl).isVanished()) @@ -250,7 +250,7 @@ public class NoPvpProtectManager { for (Player pl : pls) { // on ignore ceux en créatif - if (pl.getGameMode() == GameMode.CREATIVE) + if (pl == null || !pl.isOnline() || pl.getGameMode() == GameMode.CREATIVE) continue; if (OnlinePlayerManager.get(pl).isVanished()) diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OffPlayer.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OffPlayer.java index 4548a8f..8e4a86a 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OffPlayer.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OffPlayer.java @@ -94,10 +94,7 @@ public class OffPlayer { * @return l'instance xAuth du joueur, ou null si aucune donnée n'est présente à propos du joueur */ public xAuthPlayer getXAuthPlayer() { - xAuthPlayer xAP = xAuth.getPlugin().getPlayerManager().getPlayer(playerName); - if (xAP.getAccountId() == -1) - return null; - return xAP; + return xAuth.getPlugin().getPlayerManager().getPlayer(playerName); }