@EventHandler(priority = EventPriority.LOWEST) public void onPetInventoryOpened(InventoryOpenEvent event) { Player player = (Player) event.getPlayer(); if (!InventoryManager.playerIsLoaded(player)) { return; } final PlayerWrapper playerWrapper = InventoryManager.get(player); if (playerWrapper.hasPet() && event.getInventory().getHolder() == playerWrapper.getPet()) { playerWrapper.openInventory(); event.setCancelled(true); new BukkitRunnable() { @Override public void run() { HorseInventory horseInv = ((Horse) playerWrapper.getPet()).getInventory(); horseInv.setSaddle(new ItemStack(Material.SADDLE)); } }.runTaskLater(RPGInventory.getInstance(), 1); } }
public static ItemStack getSaddle(final Entity entity) { if (!Sddls.isHorse(entity)) return null; final Inventory inv = ((InventoryHolder) entity).getInventory();; if (inv instanceof HorseInventory) return ((HorseInventory) inv).getSaddle(); return inv.getItem(0); }
@Override public boolean equip(Entity entity, ItemStack item) { PreCon.notNull(entity); PreCon.notNull(item); if (!(entity instanceof Horse)) return false; Horse horse = (Horse)entity; HorseInventory inventory = horse.getInventory(); Material material = item.getType(); if (material == Material.SADDLE) { inventory.setSaddle(item); } else { if (Materials.hasProperty(material, MaterialProperty.HORSE_ARMOR)) { inventory.setArmor(item); } else { return false; } } return true; }
@Override public List<ItemStack> clear(Entity entity) { PreCon.notNull(entity); if (!(entity instanceof Horse)) return new ArrayList<>(0); Horse horse = (Horse)entity; HorseInventory inventory = horse.getInventory(); List<ItemStack> result = new ArrayList<>(2); ItemStack saddle = inventory.getSaddle(); if (saddle != null) { result.add(saddle); inventory.setSaddle(null); } ItemStack armor = inventory.getArmor(); if (armor != null) { result.add(armor); inventory.setArmor(null); } return result; }
public HorseInventory getInventory() { return new CraftInventoryHorse(getHandle().horseChest); }
@Override public HorseInventory getInventory();
@Override public void setArmour(HorseArmour a) { ((HorseInventory) ((InventoryHolder) getBukkitEntity()).getInventory()) .setArmor(a.getMaterial() == null ? null : new ItemStack(a.getMaterial(), 1)); }
public HorseInventory getInventory() { throw new NotImplementedException("getInventory()"); }
public HorseInventory getInventory() { return new CraftInventoryHorse(getHandle().inventoryChest); }
@Override public HorseInventory getInventory() { return PoreHorseInventory.of(getHandle().getInventory()); }
@EventHandler public void onInventoryClick(InventoryClickEvent event) { if (event.getInventory() instanceof HorseInventory && event.getSlotType() != InventoryType.SlotType.QUICKBAR && event.getSlot() < 9) { event.setCancelled(true); } }
HorseInventory getInventory();