use of org.bukkit.inventory.Inventory in project TotalFreedomMod by TotalFreedom.
the class Command_dispfill method setDispenserContents.
private static void setDispenserContents(final Block targetBlock, final ItemStack[] items) {
if (targetBlock.getType() == Material.DISPENSER) {
final Inventory dispenserInv = ((Dispenser) targetBlock.getState()).getInventory();
dispenserInv.clear();
dispenserInv.addItem(items);
}
}
use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.
the class ScribeCommand method giveBook.
private void giveBook(Player player, ItemStack book) {
Inventory inv = player.getInventory();
int emptySpot = inv.firstEmpty();
if (emptySpot != -1) {
player.getInventory().addItem(book);
} else {
player.getWorld().dropItem(player.getLocation(), book);
dB.log("Player's inventory is full, dropped book.");
}
}
use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.
the class ImprovedOfflinePlayer_v1_9_R2 method getEnderChest.
@Override
public Inventory getEnderChest() {
if (offlineEnderChests.containsKey(getUniqueId())) {
return offlineEnderChests.get(getUniqueId());
}
InventoryEnderChest endchest = new InventoryEnderChest();
endchest.a(((CompoundTag_v1_9_R2) this.compound).toNMSTag().getList("EnderItems", 10));
Inventory inv = new CraftInventory(endchest);
offlineEnderChests.put(getUniqueId(), inv);
return inv;
}
use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.
the class dNPCRegistry method _registerNPC.
public static void _registerNPC(dNPC denizenNPC) {
if (denizenNPC == null || !denizenNPC.isValid()) {
return;
}
int id = denizenNPC.getId();
if (!denizenNPCs.containsKey(id)) {
denizenNPCs.put(id, denizenNPC);
Inventory npcInventory = Bukkit.getServer().createInventory(denizenNPC, InventoryType.PLAYER);
npcInventory.setContents(Arrays.copyOf(denizenNPC.getInventoryTrait().getContents(), npcInventory.getSize()));
npcInventories.put(id, npcInventory);
}
}
use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.
the class dNPCRegistry method onInventoryClick.
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Inventory inventory = event.getInventory();
if (inventory.getHolder() instanceof dNPC) {
dNPC npc = (dNPC) inventory.getHolder();
npc.getInventory().setContents(inventory.getContents());
Equipment equipment = npc.getEquipmentTrait();
for (int i = 0; i < 5; i++) {
equipment.set(i, inventory.getItem(i));
}
}
}
Aggregations