diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java index aca47b4b7..d4020b924 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/king/CastleManager.java @@ -6,11 +6,15 @@ import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -22,6 +26,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilWorld; import mineplex.core.gadget.gadgets.particle.king.types.King; @@ -46,10 +51,17 @@ public class CastleManager extends MiniPlugin private Location[] _woolLocations = new Location[] { - new Location(UtilWorld.getWorld("world"), 33, 80, -3), - new Location(UtilWorld.getWorld("world"), 33, 80, 7), - new Location(UtilWorld.getWorld("world"), 43, 80, -3), - new Location(UtilWorld.getWorld("world"), 43, 80, 7) + new Location(UtilWorld.getWorld("world"), 33, 80, -3), + new Location(UtilWorld.getWorld("world"), 33, 80, 7), + new Location(UtilWorld.getWorld("world"), 43, 80, -3), + new Location(UtilWorld.getWorld("world"), 43, 80, 7) + }; + + private Location[] _throneLocations = new Location[] + { + new Location(UtilWorld.getWorld("world"), 41, 76, 2), + new Location(UtilWorld.getWorld("world"), 42, 77, 2), + new Location(UtilWorld.getWorld("world"), 42, 78, 2), }; private CoreClientManager _coreClientManager; @@ -212,6 +224,43 @@ public class CastleManager extends MiniPlugin updateLobbyKing(); } + /** + * Lets player sit on throne + * @param event + */ + @EventHandler + public void onSitThrone(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!isKing(player)) + return; + + if (!getKing().getKing().equals(player)) + return; + + if (event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + Block block = event.getClickedBlock(); + + boolean isThrone = false; + for (Location location : _throneLocations) + { + isThrone = block.getLocation().getBlockX() == location.getBlockX() + && block.getLocation().getBlockY() == location.getBlockY() + && block.getLocation().getBlockZ() == location.getBlockZ(); + } + + if (!isThrone) + return; + + Location arrowLoc = _throneLocations[0].clone().add(0, 0.25, 0); + Arrow arrow = arrowLoc.getWorld().spawn(arrowLoc, Arrow.class); + UtilEnt.vegetate(arrow, true); + arrow.setPassenger(player); + } + /** * Sets player as peasant * @param event