Search in sources :

Example 6 with Inventory

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

the class ImprovedOfflinePlayer_v1_11_R1 method getEnderChest.

@Override
public Inventory getEnderChest() {
    if (offlineEnderChests.containsKey(getUniqueId())) {
        return offlineEnderChests.get(getUniqueId());
    }
    InventoryEnderChest endchest = new InventoryEnderChest(null);
    endchest.a(((CompoundTag_v1_11_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_11_R1.inventory.CraftInventory) CompoundTag_v1_11_R1(net.aufdemrand.denizen.nms.impl.jnbt.CompoundTag_v1_11_R1) Inventory(org.bukkit.inventory.Inventory)

Example 7 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 8 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 9 with Inventory

use of org.bukkit.inventory.Inventory in project Jobs by GamingMesh.

the class JobsPaymentListener method onInventoryRepair.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryRepair(InventoryClickEvent event) {
    // make sure plugin is enabled
    if (!plugin.isEnabled())
        return;
    Inventory inv = event.getInventory();
    // If event is nothing or place, do nothing
    switch(event.getAction()) {
        case NOTHING:
        case PLACE_ONE:
        case PLACE_ALL:
        case PLACE_SOME:
            return;
        default:
            break;
    }
    // must be anvil inventory
    if (!(inv instanceof AnvilInventory))
        return;
    // Must be "container" slot 9
    if (!event.getSlotType().equals(SlotType.CONTAINER) || event.getSlot() != 2)
        return;
    if (!(event.getWhoClicked() instanceof Player))
        return;
    Player player = (Player) event.getWhoClicked();
    ItemStack resultStack = event.getCurrentItem();
    if (resultStack == null)
        return;
    if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
        return;
    // check if in creative
    if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
        return;
    double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
    JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
    Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR), multiplier);
}
Also used : Player(org.bukkit.entity.Player) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) ItemActionInfo(com.gamingmesh.jobs.actions.ItemActionInfo) AnvilInventory(org.bukkit.inventory.AnvilInventory) ItemStack(org.bukkit.inventory.ItemStack) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) CraftingInventory(org.bukkit.inventory.CraftingInventory) Inventory(org.bukkit.inventory.Inventory) EnchantingInventory(org.bukkit.inventory.EnchantingInventory) AnvilInventory(org.bukkit.inventory.AnvilInventory) EventHandler(org.bukkit.event.EventHandler)

Example 10 with Inventory

use of org.bukkit.inventory.Inventory in project Jobs by GamingMesh.

the class JobsPaymentListener method onEnchantItem.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEnchantItem(EnchantItemEvent event) {
    // make sure plugin is enabled
    if (!plugin.isEnabled())
        return;
    Inventory inv = event.getInventory();
    if (!(inv instanceof EnchantingInventory))
        return;
    Player player = event.getEnchanter();
    ItemStack resultStack = ((EnchantingInventory) inv).getItem();
    if (resultStack == null)
        return;
    if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
        return;
    // check if in creative
    if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
        return;
    double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
    JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
    Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.ENCHANT), multiplier);
}
Also used : Player(org.bukkit.entity.Player) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) ItemActionInfo(com.gamingmesh.jobs.actions.ItemActionInfo) ItemStack(org.bukkit.inventory.ItemStack) JobsPlayer(com.gamingmesh.jobs.container.JobsPlayer) CraftingInventory(org.bukkit.inventory.CraftingInventory) Inventory(org.bukkit.inventory.Inventory) EnchantingInventory(org.bukkit.inventory.EnchantingInventory) AnvilInventory(org.bukkit.inventory.AnvilInventory) EnchantingInventory(org.bukkit.inventory.EnchantingInventory) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Inventory (org.bukkit.inventory.Inventory)31 ItemStack (org.bukkit.inventory.ItemStack)15 InventoryHolder (org.bukkit.inventory.InventoryHolder)8 Player (org.bukkit.entity.Player)6 EventHandler (org.bukkit.event.EventHandler)6 PlayerInventory (org.bukkit.inventory.PlayerInventory)4 HashMap (java.util.HashMap)3 ItemActionInfo (com.gamingmesh.jobs.actions.ItemActionInfo)2 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)2 Block (org.bukkit.block.Block)2 HumanEntity (org.bukkit.entity.HumanEntity)2 InventoryType (org.bukkit.event.inventory.InventoryType)2 AnvilInventory (org.bukkit.inventory.AnvilInventory)2 CraftingInventory (org.bukkit.inventory.CraftingInventory)2 EnchantingInventory (org.bukkit.inventory.EnchantingInventory)2 EntityHandle (com.bergerkiller.generated.net.minecraft.server.EntityHandle)1 IInventoryHandle (com.bergerkiller.generated.net.minecraft.server.IInventoryHandle)1 CraftEntityHandle (com.bergerkiller.generated.org.bukkit.craftbukkit.entity.CraftEntityHandle)1 CraftInventoryHandle (com.bergerkiller.generated.org.bukkit.craftbukkit.inventory.CraftInventoryHandle)1 Trade (com.earth2me.essentials.Trade)1