diff --git a/make_jar.jardesc b/make_jar.jardesc index 0964a49..258e062 100644 --- a/make_jar.jardesc +++ b/make_jar.jardesc @@ -1,6 +1,6 @@ - + diff --git a/resources/plugin.yml b/resources/plugin.yml index f2adee1..0a9011d 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -1,6 +1,6 @@ name: PandacraftUtils main: net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils -version: 4.0 +version: 4.1 diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java index 58cfbb8..9bcfa37 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/PandacraftUtils.java @@ -13,11 +13,12 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.listener.XAuthListener; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.AutoMessagesManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CalculatorManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.CommandAliasManager; -import net.mc_pandacraft.java.plugin.pandacraftutils.modules.LoginLogoutMessageManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.modules.VanillaMessageManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.PacketOutServerInfoListener; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.SpawnTimeManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.TPSAnalysisManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.WESelectionDisplayManager; +import net.mc_pandacraft.java.plugin.pandacraftutils.modules.fun.GhostManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.fun.HeartThrowManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.player_control.AfkManager; import net.mc_pandacraft.java.plugin.pandacraftutils.modules.player_control.ChatAnalysisManager; @@ -80,7 +81,7 @@ public class PandacraftUtils extends JavaPlugin { public ChatAnalysisManager chatAnalysisManager; public CreativCheatManager creativCheatManager; public NoPvpProtectManager noPvpProtectManager; - public LoginLogoutMessageManager loginLogoutMessageManager; + public VanillaMessageManager vanillaMessageManager; public CalculatorManager calculatorManager; public SurvivalCuboManager survivalCuboManager; public StaffQueueManager staffQueueManager; @@ -91,6 +92,7 @@ public class PandacraftUtils extends JavaPlugin { public WorldBorderManager worldBorderManager; public HeartThrowManager heartThrowManager; public JailsManager jailsManager; + public GhostManager ghostManager; @@ -130,7 +132,7 @@ public class PandacraftUtils extends JavaPlugin { chatAnalysisManager = new ChatAnalysisManager(); creativCheatManager = new CreativCheatManager(); noPvpProtectManager = new NoPvpProtectManager(); - loginLogoutMessageManager = new LoginLogoutMessageManager(); + vanillaMessageManager = new VanillaMessageManager(); calculatorManager = new CalculatorManager(); survivalCuboManager = new SurvivalCuboManager(); staffQueueManager = new StaffQueueManager(); @@ -141,6 +143,7 @@ public class PandacraftUtils extends JavaPlugin { worldBorderManager = new WorldBorderManager(); heartThrowManager = new HeartThrowManager(); jailsManager = new JailsManager(); + ghostManager = new GhostManager(); // chargement des écouteurs d'évènement diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/listener/PlayerListener.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/listener/PlayerListener.java index 8a2984a..fb94e21 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/listener/PlayerListener.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/listener/PlayerListener.java @@ -6,7 +6,9 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerAchievementAwardedEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerDropItemEvent; @@ -45,10 +47,15 @@ public class PlayerListener implements Listener { @EventHandler(ignoreCancelled=false,priority=EventPriority.NORMAL) public void onPlayerJoin(PlayerJoinEvent event) { - plugin.loginLogoutMessageManager.onPlayerJoin(event); + plugin.vanillaMessageManager.onPlayerJoin(event); plugin.staffQueueManager.onPlayerJoin(event); } + @EventHandler(ignoreCancelled=false,priority=EventPriority.HIGHEST) + public void onPlayerJoin_Highest(PlayerJoinEvent event) { + plugin.ghostManager.onPlayerJoin(event); + } + @@ -61,7 +68,7 @@ public class PlayerListener implements Listener { @EventHandler(ignoreCancelled=false,priority=EventPriority.NORMAL) public void onPlayerQuit(PlayerQuitEvent event) { - plugin.loginLogoutMessageManager.onPlayerQuit(event); + plugin.vanillaMessageManager.onPlayerQuit(event); plugin.staffQueueManager.onPlayerQuit(event); } @EventHandler(ignoreCancelled=false,priority=EventPriority.HIGHEST) @@ -122,12 +129,44 @@ public class PlayerListener implements Listener { + + + + @EventHandler(ignoreCancelled=false,priority=EventPriority.NORMAL) + public void onPlayerDeath(PlayerDeathEvent event) { + plugin.vanillaMessageManager.onPlayerDeath(event); + } + + + + + + + + + + + + + + @EventHandler(ignoreCancelled=false,priority=EventPriority.NORMAL) + public void onPlayerAchievementAwarded(PlayerAchievementAwardedEvent event) { + plugin.vanillaMessageManager.onPlayerAchievementAwarded(event); + } + + + + + + + + + @EventHandler(ignoreCancelled=false,priority=EventPriority.NORMAL) - public void onPlayerMove (PlayerMoveEvent event) - { + public void onPlayerMove(PlayerMoveEvent event) { plugin.afkManager.onPlayerMove(event); plugin.creativCheatManager.onPlayerMove(event); } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/listener/XAuthListener.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/listener/XAuthListener.java index fda964d..471cbeb 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/listener/XAuthListener.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/listener/XAuthListener.java @@ -29,7 +29,7 @@ public class XAuthListener implements Listener { @EventHandler(ignoreCancelled=false,priority=EventPriority.NORMAL) public void onxAuthLogin(xAuthLoginEvent event) { - plugin.loginLogoutMessageManager.onxAuthLogin(event); + plugin.vanillaMessageManager.onxAuthLogin(event); } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/LoginLogoutMessageManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/VanillaMessageManager.java similarity index 64% rename from src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/LoginLogoutMessageManager.java rename to src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/VanillaMessageManager.java index 9d72c80..db7a899 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/LoginLogoutMessageManager.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/VanillaMessageManager.java @@ -2,15 +2,16 @@ package net.mc_pandacraft.java.plugin.pandacraftutils.modules; import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; -import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.EssentialsInterface; import org.bukkit.ChatColor; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerAchievementAwardedEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import de.luricos.bukkit.xAuth.events.xAuthLoginEvent; -public class LoginLogoutMessageManager { +public class VanillaMessageManager { private PandacraftUtils plugin = PandacraftUtils.getInstance(); @@ -23,7 +24,7 @@ public class LoginLogoutMessageManager { public void onxAuthLogin(xAuthLoginEvent event) { - if (EssentialsInterface.isPlayerVanished(event.getPlayer())) return; + if (OnlinePlayerManager.get(event.getPlayer()).isVanished()) return; plugin.getServer().broadcastMessage(ChatColor.YELLOW+event.getPlayer().getDisplayName()+ChatColor.YELLOW+" vient de se connecter"); } @@ -36,11 +37,30 @@ public class LoginLogoutMessageManager { return; // on affiche le message que si le joueur n'est pas vanish - if (EssentialsInterface.isPlayerVanished(event.getPlayer())) return; + if (OnlinePlayerManager.get(event.getPlayer()).isVanished()) return; plugin.getServer().broadcastMessage(ChatColor.YELLOW+event.getPlayer().getDisplayName()+ChatColor.YELLOW+" a quitté le jeu"); } + + + public void onPlayerDeath(PlayerDeathEvent event) { + + if (OnlinePlayerManager.get(event.getEntity()).isVanished()) { + event.setDeathMessage(null); + } + + } + + + public void onPlayerAchievementAwarded(PlayerAchievementAwardedEvent event) { + + if (OnlinePlayerManager.get(event.getPlayer()).isVanished()) { + event.setCancelled(true); + } + } + + } diff --git a/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/fun/GhostManager.java b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/fun/GhostManager.java new file mode 100644 index 0000000..fc40463 --- /dev/null +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/modules/fun/GhostManager.java @@ -0,0 +1,37 @@ +package net.mc_pandacraft.java.plugin.pandacraftutils.modules.fun; + +import org.bukkit.event.player.PlayerJoinEvent; + +import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils; +import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager; + +public class GhostManager { + @SuppressWarnings("unused") + private PandacraftUtils plugin = PandacraftUtils.getInstance(); + + + + + + + + + + + + public void onPlayerJoin(PlayerJoinEvent event) { + if (!event.getPlayer().hasPermission("pandacraft.ghost")) return; + + OnlinePlayerManager.get(event.getPlayer()).getEssentialsUser().setVanished(true); + + } + + + + + + + + + +} 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 a1e84d6..4548a8f 100644 --- a/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OffPlayer.java +++ b/src/net/mc_pandacraft/java/plugin/pandacraftutils/players/OffPlayer.java @@ -82,7 +82,10 @@ public class OffPlayer { public User getEssentialsUser() { - return EssentialsInterface.getPlugin().getOfflineUser(playerName); + User u = EssentialsInterface.getPlugin().getOfflineUser(playerName); + if (isOnline()) + u.setBase(getBukkitOnlinePlayer()); + return u; }