From 27c6ef4e9dcdb7b33bd71652d104b1956b034cdc Mon Sep 17 00:00:00 2001 From: NewGarbo Date: Mon, 2 Nov 2015 10:16:13 +0000 Subject: [PATCH] Success! Finished all events woohoo! --- .../clans/clans/commands/ClansCommand.java | 14 ++--- .../clans/clans/event/ClanDeleteEvent.java | 7 +-- .../event/ClansCommandExecutedEvent.java | 46 ++++++++++++++++ .../event/PlayerClaimTerritoryEvent.java | 53 +++++++++++++++++++ .../types/TutorialGettingStarted.java | 19 ++++--- 5 files changed, 122 insertions(+), 17 deletions(-) create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClansCommandExecutedEvent.java create mode 100644 Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerClaimTerritoryEvent.java 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 6834e151d..877d69dda 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 @@ -26,9 +26,9 @@ import mineplex.game.clans.clans.ClansPlayer; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.event.ClanDisbandedEvent; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.tutorials.TutorialManager; -import mineplex.game.clans.tutorials.TutorialType; -import mineplex.game.clans.tutorials.types.TutorialGettingStarted; public class ClansCommand extends CommandBase { @@ -48,7 +48,6 @@ public class ClansCommand extends CommandBase { if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId())) infoClan(caller, Plugin.getClanMemberUuidMap().get(caller.getUniqueId()).getName()); - else UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); return; @@ -169,6 +168,8 @@ public class ClansCommand extends CommandBase private void help(Player caller) { + UtilServer.getServer().getPluginManager().callEvent(new ClansCommandExecutedEvent(caller, "help", null)); + UtilPlayer.message(caller, F.main("Clans", "Commands List;")); UtilPlayer.message(caller, F.help("/c create ", "Create new Clan", Rank.ALL)); UtilPlayer.message(caller, F.help("/c join ", "Join a Clan", Rank.ALL)); @@ -950,8 +951,8 @@ public class ClansCommand extends CommandBase // Recharge if (!Recharge.Instance.use(caller, "Territory Claim", 60000, true, false)) return; - // Tutorial - if (!((TutorialGettingStarted) TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED)).onClaim(caller)) return; + // Event + PlayerClaimTerritoryEvent event = new PlayerClaimTerritoryEvent(caller, caller.getLocation().getChunk()); // Task Plugin.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false); @@ -1188,10 +1189,11 @@ public class ClansCommand extends CommandBase return; } + UtilServer.getServer().getPluginManager().callEvent(new ClansCommandExecutedEvent(caller, "info", search)); + ClanInfo clan = Plugin.getClanUtility().searchClanPlayer(caller, search, true); if (clan == null) return; - ((TutorialGettingStarted) TutorialManager.Instance.getTutorials().get(TutorialType.GETTING_STARTED)).onClanInfo(caller, search); UtilPlayer.message(caller, clan.mDetails(caller)); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClanDeleteEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClanDeleteEvent.java index 20b4bdf35..6076a1cab 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClanDeleteEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClanDeleteEvent.java @@ -1,13 +1,10 @@ package mineplex.game.clans.clans.event; -import mineplex.core.gadget.types.Gadget; -import mineplex.core.mount.Mount; -import mineplex.game.clans.clans.ClanInfo; - -import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import mineplex.game.clans.clans.ClanInfo; + public class ClanDeleteEvent extends Event { private static final HandlerList handlers = new HandlerList(); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClansCommandExecutedEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClansCommandExecutedEvent.java new file mode 100644 index 000000000..e71a507a7 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/ClansCommandExecutedEvent.java @@ -0,0 +1,46 @@ +package mineplex.game.clans.clans.event; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class ClansCommandExecutedEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _player; + private String _command; + private String[] _args; + + public ClansCommandExecutedEvent(Player player, String command, String... args) + { + _player = player; + _command = command; + _args = args; + } + + public Player getPlayer() + { + return _player; + } + + public String getCommand() + { + return _command; + } + + public String[] getArguments() + { + return _args; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerClaimTerritoryEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerClaimTerritoryEvent.java new file mode 100644 index 000000000..f198fa14c --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerClaimTerritoryEvent.java @@ -0,0 +1,53 @@ +package mineplex.game.clans.clans.event; + +import org.bukkit.Chunk; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class PlayerClaimTerritoryEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _claimer; + private Chunk _claimedChunk; + + private boolean _cancelled; + + public PlayerClaimTerritoryEvent(Player claimer, Chunk claimedChunk) + { + _claimer = claimer; + _claimedChunk = claimedChunk; + } + + public Player getClaimer() + { + return _claimer; + } + + public Chunk getClaimedChunk() + { + return _claimedChunk; + } + + public void setCancelled(boolean cancelled) + { + _cancelled = cancelled; + } + + public boolean isCancelled() + { + return _cancelled; + } + + public HandlerList getHandlers() + { + return handlers; + } + + public static HandlerList getHandlerList() + { + return handlers; + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java index 48303800a..a74f8796d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/TutorialGettingStarted.java @@ -20,8 +20,10 @@ import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.ClanCreatedEvent; import mineplex.game.clans.clans.event.ClanDisbandedEvent; +import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent; import mineplex.game.clans.clans.event.ClansShopAddButtonEvent; +import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.tutorials.Tutorial; @@ -170,11 +172,15 @@ public class TutorialGettingStarted extends Tutorial } } - public void onClanInfo(final Player caller, final String name) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onClansCommand(ClansCommandExecutedEvent event) { - if (isInTutorial(caller.getName()) && get(caller).hasFinishedTask(getTask("Welcome")) && !get(caller).hasFinishedTask(getTask("Viewing Clan Info"))) + if (event.getCommand().equals("info")) { - finishTask(caller, "Viewing Clan Info"); + if (isInTutorial(event.getPlayer()) && get(event.getPlayer()).hasFinishedTask(getTask("Welcome")) && !get(event.getPlayer()).hasFinishedTask(getTask("Viewing Clan Info"))) + { + finishTask(event.getPlayer(), "Viewing Clan Info"); + } } } @@ -198,11 +204,12 @@ public class TutorialGettingStarted extends Tutorial } } - public boolean onClaim(final Player caller) + @EventHandler(priority = EventPriority.MONITOR) + public boolean onClaim(final PlayerClaimTerritoryEvent event) { - if (isInTutorial(caller) && get(caller).hasFinishedTask(getTask("Go To The Wilderness")) && !get(caller).hasFinishedTask(getTask("Claiming Territory"))) + if (isInTutorial(event.getClaimer()) && get(event.getClaimer()).hasFinishedTask(getTask("Go To The Wilderness")) && !get(event.getClaimer()).hasFinishedTask(getTask("Claiming Territory"))) { - finishTask(caller, "Claiming Territory"); + finishTask(event.getClaimer(), "Claiming Territory"); return false; }