From e0706f362717d9e8e25bdd7d43f156818feba96c Mon Sep 17 00:00:00 2001 From: samczsun Date: Wed, 15 Mar 2017 20:29:17 -0400 Subject: [PATCH] PC-1056 --- .../game/arcade/kit/perks/PerkHorsePet.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java index fe636fede..ae8c54f91 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkHorsePet.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Horse.Variant; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.inventory.ItemStack; @@ -22,12 +23,15 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier; import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.utils.UtilVariant; @@ -39,6 +43,8 @@ import nautilus.game.arcade.kit.Perk; public class PerkHorsePet extends Perk { + private static final ItemStack SADDLE_ITEM = new ItemBuilder(Material.SADDLE).setTitle(C.cGreenB + "Saddle").build(); + private HashMap _horseMap = new HashMap(); private HashMap _deathTime = new HashMap(); @@ -98,7 +104,7 @@ public class PerkHorsePet extends Perk horse.setOwner(player); horse.setMaxDomestication(1); horse.setJumpStrength(1); - horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); + horse.getInventory().setSaddle(SADDLE_ITEM); horse.setMaxHealth(40); horse.setHealth(40); @@ -299,6 +305,22 @@ public class PerkHorsePet extends Perk } } + @EventHandler + public void onClick(InventoryClickEvent event) + { + Horse horse = _horseMap.get(event.getWhoClicked()); + if (horse != null) + { + if (event.getInventory().equals(horse.getInventory())) + { + if (UtilInv.shouldCancelEvent(event, item -> UtilItem.isSimilar(item, SADDLE_ITEM, UtilItem.ItemAttribute.NAME))) + { + event.setCancelled(true); + } + } + } + } + private KitModifier getHorseType(Player player) { GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();