From 1c65f95293b59d14db127740cf4b75a0218cd187 Mon Sep 17 00:00:00 2001 From: Sciguymjm Date: Mon, 11 Apr 2016 13:24:15 -0400 Subject: [PATCH] Added wartime tele check --- .../sznp/thebuttonautoflair/PlayerListener.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PlayerListener.java b/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PlayerListener.java index 325b6a9..5a07519 100644 --- a/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PlayerListener.java +++ b/TheButtonAutoFlair/src/tk/sznp/thebuttonautoflair/PlayerListener.java @@ -8,6 +8,7 @@ import java.util.Timer; import java.util.TimerTask; import java.util.UUID; +import com.palmergames.bukkit.towny.Towny; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -48,6 +49,7 @@ import com.palmergames.bukkit.towny.object.Resident; import com.palmergames.bukkit.towny.object.Town; import com.palmergames.bukkit.towny.object.TownBlock; import com.palmergames.bukkit.towny.object.TownyUniverse; +import com.palmergames.bukkit.towny.war.eventwar.War; import com.palmergames.bukkit.towny.object.WorldCoord; import com.vexsoftware.votifier.model.Vote; import com.vexsoftware.votifier.model.VotifierEvent; @@ -385,11 +387,24 @@ public class PlayerListener implements Listener { || cmd.equalsIgnoreCase("tp")) { MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(event .getPlayer()); + String currentWorld = event.getPlayer().getLocation().getWorld().getName(); + Location currentLocation = event.getPlayer().getLocation(); + TownyUniverse universe = Towny.plugin.getTownyUniverse(); if (mgp.isInMinigame() && mgp.getMinigame().getMechanic().getMechanic() .equals("creativeglobal")) { mgp.setAllowTeleport(true); } + else if (universe.isWarTime()) + { + War war = universe.getWarEvent(); + if (war.isWarZone(new WorldCoord(currentWorld, currentLocation.getBlockX(), currentLocation.getBlockZ()))) + { + event.getPlayer().sendMessage( + "§cError: You can't teleport out of a war zone!"); + event.setCancelled(true); + } + } } else if (cmd.toLowerCase().startsWith("un")) { for (HelpTopic ht : PluginMain.Instance.getServer().getHelpMap() .getHelpTopics()) {