Search in sources :

Example 1 with Inventory

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);
    }
}
Also used : Dispenser(org.bukkit.block.Dispenser) Inventory(org.bukkit.inventory.Inventory)

Example 2 with Inventory

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.");
    }
}
Also used : Inventory(org.bukkit.inventory.Inventory)

Example 3 with Inventory

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;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_9_R2.inventory.CraftInventory) CompoundTag_v1_9_R2(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_9_R2) CraftInventory(org.bukkit.craftbukkit.v1_9_R2.inventory.CraftInventory) Inventory(org.bukkit.inventory.Inventory)

Example 4 with Inventory

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);
    }
}
Also used : Inventory(org.bukkit.inventory.Inventory)

Example 5 with Inventory

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));
        }
    }
}
Also used : net.aufdemrand.denizen.objects.dNPC(net.aufdemrand.denizen.objects.dNPC) Equipment(net.citizensnpcs.api.trait.trait.Equipment) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Inventory (org.bukkit.inventory.Inventory)222 ItemStack (org.bukkit.inventory.ItemStack)132 Player (org.bukkit.entity.Player)80 EventHandler (org.bukkit.event.EventHandler)57 PlayerInventory (org.bukkit.inventory.PlayerInventory)40 ArrayList (java.util.ArrayList)37 ItemMeta (org.bukkit.inventory.meta.ItemMeta)34 InventoryHolder (org.bukkit.inventory.InventoryHolder)25 Block (org.bukkit.block.Block)18 Mage (com.elmakers.mine.bukkit.api.magic.Mage)16 Location (org.bukkit.Location)16 UUID (java.util.UUID)13 HashMap (java.util.HashMap)12 Entity (org.bukkit.entity.Entity)12 Material (org.bukkit.Material)11 HumanEntity (org.bukkit.entity.HumanEntity)10 Vector (org.bukkit.util.Vector)9 Sign (org.bukkit.block.Sign)8 MageController (com.elmakers.mine.bukkit.api.magic.MageController)7 List (java.util.List)7