Search in sources :

Example 36 with Inventory

use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.

the class ScribeCommand method equipBook.

private void equipBook(Player player, ItemStack book) {
    ItemStack currItem = player.getItemInHand();
    Inventory inv = player.getInventory();
    int emptySpot = inv.firstEmpty();
    // if player isn't holding anything
    if (currItem == null || currItem.getType() == Material.AIR) {
        player.setItemInHand(book);
        return;
    }
    // drop it if inventory has no empty slots
    emptySpot = inv.firstEmpty();
    dB.log("emptySpot: " + emptySpot);
    if (emptySpot == -1) {
        player.getWorld().dropItem(player.getLocation(), book);
        dB.log("Player's inventory is full, dropped book.");
    } else // move current held item to empty spot, set item in hand to the book
    {
        inv.setItem(emptySpot, currItem);
        player.setItemInHand(book);
        dB.log("...added book to player hand, moved original item");
    }
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory)

Example 37 with Inventory

use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.

the class ImprovedOfflinePlayer_v1_8_R3 method getEnderChest.

@Override
public Inventory getEnderChest() {
    if (offlineEnderChests.containsKey(getUniqueId())) {
        return offlineEnderChests.get(getUniqueId());
    }
    InventoryEnderChest endchest = new InventoryEnderChest();
    endchest.a(((CompoundTag_v1_8_R3) this.compound).toNMSTag().getList("EnderItems", 10));
    Inventory inv = new CraftInventory(endchest);
    offlineEnderChests.put(getUniqueId(), inv);
    return inv;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory) CompoundTag_v1_8_R3(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_8_R3) CraftInventory(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory) Inventory(org.bukkit.inventory.Inventory)

Example 38 with Inventory

use of org.bukkit.inventory.Inventory in project Denizen-For-Bukkit by DenizenScript.

the class ImprovedOfflinePlayer_v1_10_R1 method getEnderChest.

@Override
public Inventory getEnderChest() {
    if (offlineEnderChests.containsKey(getUniqueId())) {
        return offlineEnderChests.get(getUniqueId());
    }
    InventoryEnderChest endchest = new InventoryEnderChest();
    endchest.a(((CompoundTag_v1_10_R1) this.compound).toNMSTag().getList("EnderItems", 10));
    org.bukkit.inventory.Inventory inv = new CraftInventory(endchest);
    offlineEnderChests.put(getUniqueId(), inv);
    return inv;
}
Also used : CraftInventory(org.bukkit.craftbukkit.v1_10_R1.inventory.CraftInventory) CompoundTag_v1_10_R1(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_10_R1) Inventory(org.bukkit.inventory.Inventory)

Example 39 with Inventory

use of org.bukkit.inventory.Inventory in project EliteMobs by MagmaGuy.

the class LootGUI method lootGUI.

public void lootGUI(Player player) {
    Inventory fakeChestInventory = Bukkit.createInventory(null, 54, "EliteMobs loot.yml");
    tierConstructor(fakeChestInventory);
    headerConstructor(fakeChestInventory);
    lootNavigationConstructor(fakeChestInventory);
    lootConstructor(fakeChestInventory);
    player.openInventory(fakeChestInventory);
}
Also used : Inventory(org.bukkit.inventory.Inventory)

Example 40 with Inventory

use of org.bukkit.inventory.Inventory in project Essentials by drtshock.

the class SignFree method onSignInteract.

@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException {
    ItemStack itemStack = getItemStack(sign.getLine(1), 1, ess);
    itemStack = getItemMeta(itemStack, sign.getLine(2), ess);
    final ItemStack item = getItemMeta(itemStack, sign.getLine(3), ess);
    if (item.getType() == Material.AIR) {
        throw new SignException(tl("cantSpawnItem", "Air"));
    }
    item.setAmount(item.getType().getMaxStackSize());
    ItemMeta meta = item.getItemMeta();
    final String displayName = meta.hasDisplayName() ? meta.getDisplayName() : item.getType().toString();
    Inventory invent = ess.getServer().createInventory(player.getBase(), 36, displayName);
    for (int i = 0; i < 36; i++) {
        invent.addItem(item);
    }
    player.getBase().openInventory(invent);
    Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), sign.getBlock().getLocation(), ess);
    return true;
}
Also used : Trade(com.earth2me.essentials.Trade) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Inventory(org.bukkit.inventory.Inventory)

Aggregations

Inventory (org.bukkit.inventory.Inventory)48 ItemStack (org.bukkit.inventory.ItemStack)22 Player (org.bukkit.entity.Player)14 EventHandler (org.bukkit.event.EventHandler)14 InventoryHolder (org.bukkit.inventory.InventoryHolder)10 ArrayList (java.util.ArrayList)6 Block (org.bukkit.block.Block)5 PlayerInventory (org.bukkit.inventory.PlayerInventory)5 Island (com.wasteofplastic.acidisland.Island)4 UUID (java.util.UUID)4 Sign (org.bukkit.block.Sign)4 ASkyBlock (com.wasteofplastic.acidisland.ASkyBlock)3 HashMap (java.util.HashMap)3 Location (org.bukkit.Location)3 ItemActionInfo (com.gamingmesh.jobs.actions.ItemActionInfo)2 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)2 SettingsFlag (com.wasteofplastic.acidisland.Island.SettingsFlag)2 Schematic (com.wasteofplastic.acidisland.schematics.Schematic)2 Material (org.bukkit.Material)2 Entity (org.bukkit.entity.Entity)2