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 d874792d5..fb51dbcc2 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 @@ -36,6 +36,7 @@ import mineplex.core.gadget.gadgets.particle.king.types.Peasant; import mineplex.core.hologram.Hologram; import mineplex.core.hologram.HologramManager; import mineplex.core.mount.event.MountActivateEvent; +import mineplex.core.pet.event.PetSpawnEvent; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -664,6 +665,10 @@ public class CastleManager extends MiniPlugin } } + /** + * Stops players from using mounts inside the castle + * @param event + */ @EventHandler public void onMount(MountActivateEvent event) { @@ -673,4 +678,14 @@ public class CastleManager extends MiniPlugin if (isInsideCastle(event.getPlayer().getLocation())) event.setCancelled(true); } + + @EventHandler + public void onPetSpawn(PetSpawnEvent event) + { + if (!isHub()) + return; + + if (isInsideCastle(event.getLocation())) + event.setCancelled(true); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 58b555539..902e5218a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -70,9 +70,9 @@ import mineplex.core.disguise.disguises.DisguiseVillager; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.disguise.disguises.DisguiseZombie; import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.gadgets.particle.king.CastleManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.pet.event.PetSpawnEvent; import mineplex.core.pet.repository.PetRepository; import mineplex.core.pet.repository.token.ClientPetTokenWrapper; import mineplex.core.updater.UpdateType; @@ -97,7 +97,6 @@ public class PetManager extends MiniClientPlugin private DonationManager _donationManager; private CoreClientManager _clientManager; private InventoryManager _inventoryManager; - private CastleManager _castleManager; private Map _flyingPets = new HashMap<>(); private Map _trueLovePets = new HashMap<>(); @@ -110,8 +109,7 @@ public class PetManager extends MiniClientPlugin private ShapeWings _cupidWingsEdge = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0, 0, 0), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_HEART_WING_PATTERN); public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager - , InventoryManager inventoryManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore, - CastleManager castleManager) + , InventoryManager inventoryManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore) { super("Pet Manager", plugin); @@ -216,11 +214,11 @@ public class PetManager extends MiniClientPlugin return; } - if (_castleManager.isInsideCastle(location)) - { - UtilPlayer.message(player, F.main("Pets", "You cannot spawn a pet inside the castle!")); + PetSpawnEvent petSpawnEvent = new PetSpawnEvent(player, petType.getEntityType(), location); + Bukkit.getPluginManager().callEvent(petSpawnEvent); + + if (petSpawnEvent.isCancelled()) return; - } Entity pet; EntityType entityType = petType.getEntityType(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/event/PetSpawnEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/event/PetSpawnEvent.java index cbd0d2c32..2b7ec73f1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/event/PetSpawnEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/event/PetSpawnEvent.java @@ -23,17 +23,17 @@ public class PetSpawnEvent extends Event implements Cancellable _location = location; } - public Player GetPlayer() + public Player getPlayer() { return _player; } - public EntityType GetEntityType() + public EntityType getEntityType() { return _entityType; } - public Location GetLocation() + public Location getLocation() { return _location; }