diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index db6b37ffd..e1c7dbef9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -1410,4 +1410,9 @@ public class GadgetManager extends MiniPlugin taunt.start(player); } + public CastleManager getCastleManager() + { + return _castleManager; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java index 67aa5cc1e..49eb81e85 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemBatGun.java @@ -1,5 +1,16 @@ package mineplex.core.gadget.gadgets.item; +import java.util.ArrayList; +import java.util.HashMap; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Bat; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -20,16 +31,6 @@ import mineplex.core.preferences.Preference; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Bat; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.util.Vector; - -import java.util.ArrayList; -import java.util.HashMap; public class ItemBatGun extends ItemGadget { @@ -94,6 +95,13 @@ public class ItemBatGun extends ItemGadget { if (!bat.isValid()) continue; + + if (Manager.getCastleManager().isInsideCastle(bat.getLocation())) + { + bat.remove(); + continue; + } + Vector rand = new Vector((Math.random() - 0.5)/3, (Math.random() - 0.5)/3, (Math.random() - 0.5)/3); bat.setVelocity(loc.getDirection().clone().multiply(0.5).add(rand)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java index 6c454ebff..82004ff2b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemFleshHook.java @@ -73,6 +73,9 @@ public class ItemFleshHook extends ItemGadget implements IThrown if (target instanceof ArmorStand) return; + if (Manager.getCastleManager().isInsideCastle(target.getLocation())) + return; + //Pull UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), player.getLocation()), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java index 264118b41..30c732740 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemMelonLauncher.java @@ -74,7 +74,7 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown { if (target != null) { - if (!(target instanceof ArmorStand)) + if (!(target instanceof ArmorStand) && !Manager.getCastleManager().isInsideCastle(target.getLocation())) { //Push UtilAction.velocity(target, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java index eecba68e1..eb0d65b51 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java @@ -67,7 +67,10 @@ public class ItemTNT extends ItemGadget { if (Manager.collideEvent(killer, this, player)) continue; - + + if (Manager.getCastleManager().isInsideCastle(player.getLocation())) + continue; + double mult = players.get(player); //Knockback 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 d4a662f45..2cfa9c882 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 @@ -385,12 +385,7 @@ public class CastleManager extends MiniPlugin // Removes old king from the throne if (UtilAlg.inBoundingBox(oldKing.getKing().getLocation(), _castleLocationA, _castleLocationB)) { - Entity target = oldKing.getKing(); - while (target.getVehicle() != null) - { - target = target.getVehicle(); - } - UtilAction.velocity(target, UtilAlg.getTrajectory(target.getLocation(), _removedKingLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true); + oldKing.getKing().teleport(new Location(UtilWorld.getWorld("world"), 0, 78, -31)); UtilPlayer.message(oldKing.getKing(), F.main("Kingdom", "You are no longer the king of that castle!")); } } @@ -434,8 +429,23 @@ public class CastleManager extends MiniPlugin if (!isKing(player)) return; + if (getKing().equals(getKing(player))) + _king = null; + _kings.get(player).clearPeasants(); _kings.remove(player); + + if (_item != null) + { + if (_item.getPassenger() != null) + { + if (_item.getPassenger().equals(player)) + { + player.leaveVehicle(); + } + } + } + updateLobbyKing(); } /** @@ -486,6 +496,15 @@ public class CastleManager extends MiniPlugin if (!isPeasant(player)) return; + if (getPeasant(player) != null) + { + Peasant peasant = getPeasant(player); + if (peasant.getKing() != null) + { + peasant.getKing().removePeasant(peasant); + peasant.removeKing(); + } + } _peasants.remove(player); } @@ -585,4 +604,9 @@ public class CastleManager extends MiniPlugin location.getBlock().setData(data); } } + + public boolean isInsideCastle(Location location) + { + return UtilAlg.inBoundingBox(location, _castleLocationA, _castleLocationB); + } }