From a30a591b582db08a848a95e57edb129d7bdc874d Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 27 Mar 2016 02:04:33 +0100 Subject: [PATCH] disable certain clans commands whilst in tutorial --- .../game/clans/clans/ClansManager.java | 2 +- .../clans/clans/commands/ClansCommand.java | 4 +- .../tutorials/clans/ClansMainTutorial.java | 52 ++++++++++++++----- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 2e1463a7f..a35aabd87 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -633,7 +633,7 @@ public class ClansManager extends MiniClientPluginimplements IRelati if (event.getLeaveMessage() != null) { event.setLeaveMessage(null); - UtilServer.broadcast(F.sys("Quit", event.getPlayer().getName())); + UtilServer.broadcast(F.sys("Leave", event.getPlayer().getName())); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 0cfd172e9..60d059276 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -61,9 +61,7 @@ public class ClansCommand extends CommandBase return; } - ClansCommandPreExecutedEvent event = new ClansCommandPreExecutedEvent(caller, args); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) + if (UtilServer.CallEvent(new ClansCommandPreExecutedEvent(caller, args)).isCancelled()) return; if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("h")) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java index 4bb0c7276..e2db35b92 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/ClansMainTutorial.java @@ -11,6 +11,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.player.PlayerDropItemEvent; @@ -26,6 +27,7 @@ import mineplex.core.npc.NpcManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; import mineplex.game.clans.message.ClansMessageManager; import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.tutorial.Tutorial; @@ -76,17 +78,6 @@ public class ClansMainTutorial extends Tutorial getMessage().removePlayer(player); player.teleport(Spawn.getNorthSpawn()); - ClansManager.getInstance().getClanDataAccess().delete(ClansManager.getInstance().getClan(player), new Callback() - { - @Override - public void run(Boolean data) - { - if (data.booleanValue()) - { - UtilPlayer.message(player, F.main("Clans", "Your Clan has been deleted.")); - } - } - }); } @Override @@ -262,7 +253,44 @@ public class ClansMainTutorial extends Tutorial List locations = region.getLocationMap().getIronLocations(dataLoc); locations.stream().map(Location::getBlock).forEach(this::destroyFence); } - + + @EventHandler(priority = EventPriority.LOW) + public void teleport(ClansCommandPreExecutedEvent event) + { + if (event.getArguments().length < 1) + { + return; + } + + if (!isInTutorial(event.getPlayer())) + { + return; + } + + if (event.getArguments()[0].equalsIgnoreCase("join") + || event.getArguments()[0].equalsIgnoreCase("leave") + || event.getArguments()[0].equalsIgnoreCase("map") + || event.getArguments()[0].equalsIgnoreCase("stuck") + || event.getArguments()[0].equalsIgnoreCase("promote") + || event.getArguments()[0].equalsIgnoreCase("demote") + || event.getArguments()[0].equalsIgnoreCase("invite") + || event.getArguments()[0].equalsIgnoreCase("kick") + || event.getArguments()[0].equalsIgnoreCase("neutral") + || event.getArguments()[0].equalsIgnoreCase("enemy") + || event.getArguments()[0].equalsIgnoreCase("ally") + || event.getArguments()[0].equalsIgnoreCase("trust") + || event.getArguments()[0].equalsIgnoreCase("unclaim") + || event.getArguments()[0].equalsIgnoreCase("delete") + || event.getArguments()[0].equalsIgnoreCase("disband") + || event.getArguments()[0].equalsIgnoreCase("admin") + || event.getArguments()[0].equalsIgnoreCase("x")) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You are not allowed to run this command during the Tutorial.")); + event.setCancelled(true); + } + + } + @EventHandler public void checkInRegion(UpdateEvent event) {