PC-1056
This commit is contained in:
parent
db59c32b5e
commit
e0706f3627
@ -13,6 +13,7 @@ import org.bukkit.entity.Horse.Variant;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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.F;
|
||||||
import mineplex.core.common.util.UtilAlg;
|
import mineplex.core.common.util.UtilAlg;
|
||||||
import mineplex.core.common.util.UtilEnt;
|
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.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier;
|
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
|
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
|
||||||
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.utils.UtilVariant;
|
import mineplex.core.utils.UtilVariant;
|
||||||
@ -39,6 +43,8 @@ import nautilus.game.arcade.kit.Perk;
|
|||||||
|
|
||||||
public class PerkHorsePet extends Perk
|
public class PerkHorsePet extends Perk
|
||||||
{
|
{
|
||||||
|
private static final ItemStack SADDLE_ITEM = new ItemBuilder(Material.SADDLE).setTitle(C.cGreenB + "Saddle").build();
|
||||||
|
|
||||||
private HashMap<Player, Horse> _horseMap = new HashMap<Player, Horse>();
|
private HashMap<Player, Horse> _horseMap = new HashMap<Player, Horse>();
|
||||||
private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>();
|
private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>();
|
||||||
|
|
||||||
@ -98,7 +104,7 @@ public class PerkHorsePet extends Perk
|
|||||||
horse.setOwner(player);
|
horse.setOwner(player);
|
||||||
horse.setMaxDomestication(1);
|
horse.setMaxDomestication(1);
|
||||||
horse.setJumpStrength(1);
|
horse.setJumpStrength(1);
|
||||||
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
|
horse.getInventory().setSaddle(SADDLE_ITEM);
|
||||||
horse.setMaxHealth(40);
|
horse.setMaxHealth(40);
|
||||||
horse.setHealth(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)
|
private KitModifier getHorseType(Player player)
|
||||||
{
|
{
|
||||||
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();
|
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();
|
||||||
|
Loading…
Reference in New Issue
Block a user