From 1d4472255fb20ab839e4c82a46002049b74d2cdd Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 29 Mar 2016 18:50:28 +0100 Subject: [PATCH] PC-40 - Add cooldown to Tutorial /c home --- .../goals/finalobj/TpClanHomeGoal.java | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/finalobj/TpClanHomeGoal.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/finalobj/TpClanHomeGoal.java index f1f175a38..9ac3d2dc2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/finalobj/TpClanHomeGoal.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorial/tutorials/clans/objective/goals/finalobj/TpClanHomeGoal.java @@ -3,6 +3,11 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.finalobj; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.delayedtask.DelayedTask; +import mineplex.core.delayedtask.DelayedTaskClient; import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent; import mineplex.game.clans.tutorial.objective.Objective; import mineplex.game.clans.tutorial.objective.ObjectiveGoal; @@ -40,10 +45,40 @@ public class TpClanHomeGoal extends ObjectiveGoal { return; } - - UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have teleported to your Clan's Home.")); - event.getPlayer().teleport(getObjective().getPlugin().getTutorialSession(event.getPlayer()).getHomeLocation()); - finish(event.getPlayer()); + + DelayedTask.Instance.doDelay( + event.getPlayer(), + "Tutorial Home Teleport", + new Callback() + { + @Override + public void run(DelayedTaskClient data) + { + UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have teleported to your Clan's Home.")); + event.getPlayer().teleport(getObjective().getPlugin().getTutorialSession(event.getPlayer()).getHomeLocation()); + finish(event.getPlayer()); + } + }, + new Callback() + { + @Override + public void run(DelayedTaskClient data) + { + UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.time(UtilTime.MakeStr(Math.max(0, data.getTimeLeft("Tutorial Home Teleport")))), 0, 5, 0, data.getPlayer()); + } + }, + new Callback() + { + @Override + public void run(DelayedTaskClient data) + { + UtilPlayer.message(data.getPlayer(), F.main("Clans", "Teleport has been cancelled due to movement.")); + } + }, + 15 * 1000, // 15 second cooldown + false + ); + event.setCancelled(true); } }