diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index c39f1bbbe..c30741532 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -19,9 +19,9 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; -import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; +import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; import mineplex.game.clans.core.repository.ClanTerritory; @@ -689,6 +689,16 @@ public class ClansUtility { ClanInfo clan = getClanByPlayer(caller); + // Pre Event + PlayerPreClaimTerritoryEvent preEvent = new PlayerPreClaimTerritoryEvent(caller, caller.getLocation().getChunk(), clan); + + UtilServer.getServer().getPluginManager().callEvent(preEvent); + + if (preEvent.isCancelled()) + { + return false; + } + if (clan == null) { Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You are not in a Clan.")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerPreClaimTerritoryEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerPreClaimTerritoryEvent.java new file mode 100644 index 000000000..e74cd8d96 --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerPreClaimTerritoryEvent.java @@ -0,0 +1,63 @@ +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; + +import mineplex.game.clans.clans.ClanInfo; + +public class PlayerPreClaimTerritoryEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + private Player _claimer; + private Chunk _claimedChunk; + + private boolean _cancelled; + + private ClanInfo _clan; + + public PlayerPreClaimTerritoryEvent(Player claimer, Chunk claimedChunk, ClanInfo clan) + { + _claimer = claimer; + _claimedChunk = claimedChunk; + _clan = clan; + } + + public Player getClaimer() + { + return _claimer; + } + + public ClanInfo getClan() + { + return _clan; + } + + 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/Tutorial.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java index 5203e5cd8..d5ce0818b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/Tutorial.java @@ -169,36 +169,43 @@ public abstract class Tutorial implements ScoreboardElement, Listener get(player).LastDescriptionSentTime = 0; get(player).CurrentTask.visibleFinish(player); - // Cycle to next task, or null if last task. - get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1); - - if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()))) + // 6 Seconds for player to read the finish message (sent by the line above) + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() { - _taskManager.completedTask(new Callback() + public void run() { - public void run(final Boolean completed) + // Cycle to next task, or null if last task. + get(player).CurrentTask = task.equals(_tasks.get(_tasks.size())) ? null : _tasks.get(task.getID() + 1); + + if (!_taskManager.hasCompletedTask(player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName()))) { - // If last task, end tutorial. - if (task.equals(_tasks.get(_tasks.size()))) + _taskManager.completedTask(new Callback() { - finishFor(player); - } - else - { - // Start next task in 1.5 Seconds (just to give a more smooth feel to the tutorial) - _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() + public void run(final Boolean completed) { - public void run() + // If last task, end tutorial. + if (task.equals(_tasks.get(_tasks.size()))) { - get(player).CurrentTask.startFor(player); + finishFor(player); } - }, 10L); - } - - player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); + else + { + // Start next task in 1.5 Seconds (just to give a more smooth feel to the tutorial) + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() + { + public void run() + { + get(player).CurrentTask.startFor(player); + } + }, 30L); + } + + player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f); + } + }, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())); } - }, player, String.format(TASK_COMPLETE_TASK, _technicalName, task.getTechnicalName())); - } + } + }, 6 * 20L); } public TutorialTask getTask(final String technicalName) @@ -303,35 +310,32 @@ public abstract class Tutorial implements ScoreboardElement, Listener public void run() { // Sets the tutorial as complete in the TaskManager and effects. - if (!_taskManager.hasCompletedTask(player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName))) + _taskManager.completedTask(new Callback() { - _taskManager.completedTask(new Callback() + public void run(final Boolean completed) { - public void run(final Boolean completed) + if (_ghostMode) { - if (_ghostMode) + for (Player other : UtilServer.getPlayers()) { - for (Player other : UtilServer.getPlayers()) - { - other.showPlayer(player); - player.showPlayer(other); - } - } - - for (int i = 0; i < 8; i++) - { - final int index = i; - _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() - { - public void run() - { - UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 0); - } - }, i * 10); + other.showPlayer(player); + player.showPlayer(other); } } - }, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); - } + + for (int i = 0; i < 8; i++) + { + final int index = i; + _manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(_manager.getPlugin(), new Runnable() + { + public void run() + { + UtilFirework.launchFirework(player.getLocation(), Type.BALL_LARGE, (index % 2 == 0) ? Color.RED : Color.LIME, false, false, new Vector(0, 0, 0), 0); + } + }, i * 10); + } + } + }, player, String.format(TUTORIAL_COMPLETE_TASK, _technicalName)); } }, 20 * 2); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java index 1dee7b5c4..a3c936754 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskClaim.java @@ -5,6 +5,7 @@ import org.bukkit.event.EventPriority; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; +import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.tutorials.TutorialTask; public class TaskClaim extends TutorialTask @@ -19,27 +20,24 @@ public class TaskClaim extends TutorialTask _description = "Clans can claim 16x16 areas of Territory! " + "Once claimed, only your Clan can break/place blocks here. " + "This is the perfect place to build a base and stash your items! " - + "You can only claim in the Wilderness, and not next to other Clans Territory. " - + "Claim some Territory now, by typing {/c claim}!"; + + "You can only claim in the Wilderness, and not next to other Clan's Territory. " + + "To claim some territory, go into the Clans GUI by typing {/c} and {Left-Clicking}"; } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onClansCommand(ClansCommandExecutedEvent event) + public void onClansCommand(PlayerPreClaimTerritoryEvent event) { - if (!isDoing(event.getPlayer())) + if (!isDoing(event.getClaimer())) { return; } - if (!ClansManager.getInstance().isInClan(event.getPlayer())) + if (!ClansManager.getInstance().isInClan(event.getClaimer())) { return; } - if (event.getCommand().equals("claim")) - { - finishFor(event.getPlayer()); - event.setCancelled(true); - } + finishFor(event.getClaimer()); + event.setCancelled(true); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java index 23eaa66fc..ea7d0c3a6 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskCustomizeClass.java @@ -25,7 +25,8 @@ public class TaskCustomizeClass extends TutorialTask _technicalName = "CustomizeKlass"; _description = "Now that you have equipped a class, use this enchantment table to customize your class builds. " - + "Click on the enchantment table, and click the edit build button."; + + "Click on the enchantment table, and click the edit build button. " + + "Make sure to select an axe ability to try out in the next task!"; _taskPos = new Location(Spawn.getSpawnWorld(), 6, 66, -300, -180f, 0f); } @@ -44,7 +45,7 @@ public class TaskCustomizeClass extends TutorialTask Player player = Bukkit.getPlayer(iterator.next()); final ClientClass clientclass = ClansManager.getInstance().getClassManager().Get(player); - if (clientclass != null && clientclass.GetSavingCustomBuild() != null) + if (clientclass != null && clientclass.GetSavingCustomBuild() != null && clientclass.GetSavingCustomBuild().AxeSkill != null) { finishFor(player); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java index 3456ceb19..71a8155da 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskLeaveSpawn.java @@ -47,7 +47,7 @@ public class TaskLeaveSpawn extends TutorialTask { Player player = Bukkit.getPlayer(iterator.next()); - if (player.getLocation().getY() < 100) + if (player.getLocation().getY() < 100 && getClans().getClanUtility().getClaim(player.getLocation()) == null) { finishFor(player); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java index 328400559..60e732340 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/gettingstarted/TaskViewClanDetails.java @@ -28,6 +28,8 @@ public class TaskViewClanDetails extends TutorialTask return; } + System.out.println(event.getCommand()); + if (event.getCommand().equals("info")) { finishFor(event.getPlayer());