Java 类org.bukkit.inventory.InventoryHolder 实例源码

项目:AddGun    文件:StandardGun.java   
/**
 * This figures out if the gun's ammo is in the entity's inventory. 
 * 
 * @param entity the entity to check
 * @return the Bullet type found that is valid for this gun, or null.
 */
public Bullet getAmmo(LivingEntity entity) {
    if (entity == null || !enabled)
        return null;

    ItemStack[] inv;
    if (entity instanceof InventoryHolder) {
        // complex inventory
        InventoryHolder holder = (InventoryHolder) entity;
        inv = holder.getInventory().getContents();
    } else {
        // simple inventory
        inv = entity.getEquipment().getArmorContents();
    }

    if (inv != null) {
        for (ItemStack item : inv) {
            Bullet bullet = AddGun.getPlugin().getAmmo().findBullet(item);
            if (bullet != null && this.allBullets.contains(bullet.getName())) {
                return bullet;
            }
        }
    }
    return null;
}
项目:AddGun    文件:StandardGun.java   
/**
 * Check if this living entity has a gun of this type already in possession
 * @param entity the entity to check
 * @return true if already in inventory, false otherwise.
 */
public boolean hasGun(LivingEntity entity) {
    if (entity == null || !enabled)
        return false;

    ItemStack[] inv;
    if (entity instanceof InventoryHolder) {
        // complex inventory
        InventoryHolder holder = (InventoryHolder) entity;
        inv = holder.getInventory().getContents();
    } else {
        // simple inventory
        inv = entity.getEquipment().getArmorContents();
    }

    if (inv != null) {
        for (ItemStack item : inv) {
            if (isGun(item)) {
                return true;
            }
        }
    }
    return false;
}
项目:AddGun    文件:RailGun.java   
public boolean hasBullet(LivingEntity entity) {
    if (entity == null || !enabled)
        return false;

    ItemStack[] inv;
    if (entity instanceof InventoryHolder) {
        // complex inventory
        InventoryHolder holder = (InventoryHolder) entity;
        inv = holder.getInventory().getContents();
    } else {
        // simple inventory
        inv = entity.getEquipment().getArmorContents();
    }

    if (inv != null) {
        for (ItemStack item : inv) {
            if (isBullet(item)) {
                return true;
            }
        }
    }
    return false;
}
项目:AddGun    文件:RailGun.java   
public boolean hasGun(LivingEntity entity) {
    if (entity == null || !enabled)
        return false;

    ItemStack[] inv;
    if (entity instanceof InventoryHolder) {
        // complex inventory
        InventoryHolder holder = (InventoryHolder) entity;
        inv = holder.getInventory().getContents();
    } else {
        // simple inventory
        inv = entity.getEquipment().getArmorContents();
    }

    if (inv != null) {
        for (ItemStack item : inv) {
            if (isGun(item)) {
                return true;
            }
        }
    }
    return false;
}
项目:AddGun    文件:RailGun.java   
/**
 * Estimates the XP this entity in inventory.
 * 
 * @param entity
 * @return
 */
private int getInvXp(LivingEntity entity) {
    if (entity == null || !enabled)
        return 0;

    ItemStack[] inv;
    if (entity instanceof InventoryHolder) {
        // complex inventory
        InventoryHolder holder = (InventoryHolder) entity;
        inv = holder.getInventory().getContents();
    } else {
        // simple inventory
        inv = entity.getEquipment().getArmorContents();
    }

    int total = 0;
    if (inv != null) {
        for (ItemStack item : inv) {
            if (Material.EXP_BOTTLE.equals(item)) {
                total += item.getAmount();
            }
        }
    }
    return total;
}
项目:AddGun    文件:Utilities.java   
/**
 * Estimates the XP this entity has in inventory.
 * 
 * @param entity the entity to check
 * @return how much XP is held
 */
public static int getInvXp(LivingEntity entity) {
    if (entity == null)
        return 0;

    ItemStack[] inv;
    if (entity instanceof InventoryHolder) {
        // complex inventory
        InventoryHolder holder = (InventoryHolder) entity;
        inv = holder.getInventory().getContents();
    } else {
        // simple inventory
        inv = entity.getEquipment().getArmorContents();
    }

    int total = 0;
    if (inv != null) {
        for (ItemStack item : inv) {
            if (Material.EXP_BOTTLE.equals(item)) {
                total += item.getAmount();
            }
        }
    }
    return total;
}
项目:SparseBukkitAPI    文件:MenuManager.java   
@EventHandler
public void onInventoryClose(InventoryCloseEvent e)
{
    if(!(e.getPlayer() instanceof Player))
        return;

    Inventory inv = e.getInventory();
    InventoryHolder holder = inv.getHolder();
    if(holder != null && holder instanceof Menu)
    {
        Menu menu = (Menu) holder;
        menu.viewers.remove(e.getPlayer());
        if(menu.viewers.size() == 0)
            openMenus.remove(menu);
    }
}
项目:ProjectAres    文件:WoolMatchModule.java   
@EventHandler
public void handleWoolCrafting(PrepareItemCraftEvent event) {
    ItemStack result = event.getRecipe().getResult();
    InventoryHolder holder = event.getInventory().getHolder();

    if (holder instanceof Player) {
        MatchPlayer playerHolder = this.match.getPlayer((Player) holder);

        if (playerHolder != null && result != null && result.getType() == Material.WOOL) {
            for(MonumentWool wool : this.wools) {
                if(wool.getDefinition().isObjectiveWool(result)) {
                    if(!wool.getDefinition().isCraftable()) {
                        playerHolder.sendMessage(ChatColor.RED + PGMTranslations.t("match.wool.craftDisabled", playerHolder, BukkitUtils.woolMessage(wool.getDyeColor())));
                        event.getInventory().setResult(null);
                    }
                }
            }
        }
    }
}
项目:ProjectAres    文件:FillListener.java   
/**
 * Return a predicate that applies a Filter to the given InventoryHolder,
 * or null if the InventoryHolder is not something that we should be filling.
 */
private static @Nullable Predicate<Filter> passesFilter(InventoryHolder holder) {
    if(holder instanceof DoubleChest) {
        final DoubleChest doubleChest = (DoubleChest) holder;
        return filter -> !filter.denies((Chest) doubleChest.getLeftSide()) ||
                         !filter.denies((Chest) doubleChest.getRightSide());
    } else if(holder instanceof BlockState) {
        return filter -> !filter.denies((BlockState) holder);
    } else if(holder instanceof Player) {
        // This happens with crafting inventories, and possibly other transient inventory types
        // Pretty sure we never want to fill an inventory held by the player
        return null;
    } else if(holder instanceof Entity) {
        return filter -> !filter.denies(new EntityQuery((Entity) holder));
    } else {
        // If we're not sure what it is, don't fill it
        return null;
    }
}
项目:ProjectAres    文件:ViewInventoryMatchModule.java   
@EventHandler(ignoreCancelled = true)
public void showInventories(final ObserverInteractEvent event) {
    if(event.getClickType() != ClickType.RIGHT) return;
    if(event.getPlayer().isDead()) return;

    if(event.getClickedParticipant() != null) {
        event.setCancelled(true);
        if(canPreviewInventory(event.getPlayer(), event.getClickedParticipant())) {
            this.previewPlayerInventory(event.getPlayer().getBukkit(), event.getClickedParticipant().getInventory());
        }
    } else if(event.getClickedEntity() instanceof InventoryHolder && !(event.getClickedEntity() instanceof Player)) {
        event.setCancelled(true);
        this.previewInventory(event.getPlayer().getBukkit(), ((InventoryHolder) event.getClickedEntity()).getInventory());
    } else if(event.getClickedBlockState() instanceof InventoryHolder) {
        event.setCancelled(true);
        this.previewInventory(event.getPlayer().getBukkit(), ((InventoryHolder) event.getClickedBlockState()).getInventory());
    }
}
项目:NeverLag    文件:AntiNegativeItemDupe.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent e) {
    if (!cm.isAntiNegativeItemDupe) {
        return;
    }
    Inventory content = null;
    if (e.getBlock().getState() instanceof InventoryHolder) {
        content = ((InventoryHolder) e.getBlock().getState()).getInventory();
    }
    if (content == null || content.getSize() == 0) {
        return;
    }
    for (ItemStack item : content.getContents()) {
        if (item != null && item.getType() != Material.AIR) {
            if (item.getAmount() <= 0) {
                item.setType(Material.AIR);
            }
        }
    }
}
项目:HCFCore    文件:PearlGlitchListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
        Block block = event.getClickedBlock();
        // Don't prevent opening chests, etc, as these won't throw the Enderpearls anyway
        if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
            Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation());
            if (!(factionAt instanceof ClaimableFaction)) {
                return;
            }

            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem()); // required to update Enderpearl count
        }
    }
}
项目:HCFCore    文件:PearlGlitchListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
        Block block = event.getClickedBlock();
        // Don't prevent opening chests, etc, as these won't throw the Enderpearls anyway
        if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
            Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation());
            if (!(factionAt instanceof ClaimableFaction)) {
                return;
            }

            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem()); // required to update Enderpearl count
        }
    }
}
项目:AnnihilationPro    文件:Furnace_V1_7_R4.java   
@Override
    public InventoryHolder getOwner()
    {
//      int x = 0;
//      org.bukkit.block.Block b = this.world.getWorld().getBlockAt(x, 0, 0);
//      while(b != null && b.getType() != Material.AIR)
//          b = this.world.getWorld().getBlockAt(++x,0,0);
//      Furnace furnace = new CraftFurnace(b);
        Furnace furnace = new CraftFurnace(this.world.getWorld().getBlockAt(0, 0, 0));
        try
        {
            ReflectionUtil.setValue(furnace, "furnace", this);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        return furnace;
    }
项目:AnnihilationPro    文件:Furnace_V1_8_R1.java   
@Override
    public InventoryHolder getOwner()
    {
//      int x = 0;
//      org.bukkit.block.Block b = this.world.getWorld().getBlockAt(x, 0, 0);
//      while(b != null && b.getType() != Material.AIR)
//          b = this.world.getWorld().getBlockAt(++x,0,0);
//      Furnace furnace = new CraftFurnace(b);
        org.bukkit.block.Furnace furnace = new CraftFurnace(this.world.getWorld().getBlockAt(0, 0, 0));
        try
        {
            ReflectionUtil.setValue(furnace, "furnace", this);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        return furnace;
    }
项目:AnnihilationPro    文件:Furnace_V1_7_R3.java   
@Override
    public InventoryHolder getOwner()
    {
        //Bukkit.getLogger().info("getOwner");
//      int x = 0;
//      org.bukkit.block.Block b = this.world.getWorld().getBlockAt(x, 0, 0);
//      while(b != null && b.getType() != Material.AIR)
//          b = this.world.getWorld().getBlockAt(++x,0,0);
//      Furnace furnace = new CraftFurnace(b);
        furnace = new CraftFurnace(this.world.getWorld().getBlockAt(0, 0, 0));
        try
        {
            ReflectionUtil.setValue(furnace, "furnace", this);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        return furnace;
    }
项目:AnnihilationPro    文件:Furnace_v1_8_R2.java   
@Override
    public InventoryHolder getOwner()
    {
//      int x = 0;
//      org.bukkit.block.Block b = this.world.getWorld().getBlockAt(x, 0, 0);
//      while(b != null && b.getType() != Material.AIR)
//          b = this.world.getWorld().getBlockAt(++x,0,0);
//      Furnace furnace = new CraftFurnace(b);
        org.bukkit.block.Furnace furnace = new CraftFurnace(this.world.getWorld().getBlockAt(0, 0, 0));
        try
        {
            ReflectionUtil.setValue(furnace, "furnace", this);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
        return furnace;
    }
项目:TradeShop    文件:Utils.java   
/**
 * Reads the name of the inventory
 *
 * @param state blockState to change the name of
 * @return Name of inventory
 */
public String readInvName(BlockState state) {
    if (!plugin.getAllowedInventories().contains(state.getType())) {
        return null;
    }

    Inventory inv = ((InventoryHolder) state).getInventory();

    if (((Nameable) state).getCustomName() == null) {
        return "";
    }

    String[] names = inv.getName().split(" <");

    if (names[0] == null || names[0].equalsIgnoreCase("")) {
        return "";
    } else {
        return names[0];
    }

}
项目:TradeShop    文件:Utils.java   
/**
 * Resets the name of the inventory
 *
 * @param state blockState to change the name of
 * @return void
 */
public void resetInvName(BlockState state) {
    Inventory inv = ((InventoryHolder) state).getInventory();
    String name = inv.getName();
    String[] temp = name.split(";");

    if (name.startsWith("o:")) {
        name = "";
    }

    String[] names = name.split(" <");

    while (names[0].endsWith(" ")) {
        names[0] = names[0].substring(0, name.length() - 2);
    }

    setName(((InventoryHolder) state), names[0]);

}
项目:ExilePearl    文件:PlayerListener.java   
/**
 * Handle inventory dragging properly
 * @param event
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryDrag(InventoryDragEvent event) {

    Map<Integer, ItemStack> items = event.getNewItems();

    for(Integer slot : items.keySet()) {
        ItemStack item = items.get(slot);

        ExilePearl pearl = pearlApi.getPearlFromItemStack(item);
        if(pearl != null) {
            boolean clickedTop = event.getView().convertSlot(slot) == slot;

            InventoryHolder holder = clickedTop ? event.getView().getTopInventory().getHolder() : event.getView().getBottomInventory().getHolder();

            updatePearlHolder(pearl, holder, event);

            if(event.isCancelled()) {
                return;
            }
        }
    }
}
项目:ExilePearl    文件:PlayerListener.java   
/**
 * Updates the pearl holder
 * @param pearl The pearl to update
 * @param holder The pearl holder
 * @param event The event
 */
private void updatePearlHolder(ExilePearl pearl, InventoryHolder holder, Cancellable event) {

    if (holder instanceof Chest) {
        updatePearl(pearl, (Chest)holder);
    } else if (holder instanceof DoubleChest) {
        updatePearl(pearl, (Chest) ((DoubleChest) holder).getLeftSide());
    } else if (holder instanceof Furnace) {
        updatePearl(pearl, (Furnace) holder);
    } else if (holder instanceof Dispenser) {
        updatePearl(pearl, (Dispenser) holder);
    } else if (holder instanceof Dropper) {
        updatePearl(pearl, (Dropper) holder);
    } else if (holder instanceof Hopper) {
        updatePearl(pearl, (Hopper) holder);
    } else if (holder instanceof BrewingStand) {
        updatePearl(pearl, (BrewingStand) holder);
    } else if (holder instanceof Player) {
        updatePearl(pearl, (Player) holder);
    }else {
        event.setCancelled(true);
    }
}
项目:ShopChest    文件:ShopUtils.java   
/**
 * Get the amount of shops of a player
 * @param p Player, whose shops should be counted
 * @return The amount of a shops a player has (if {@link Config#exclude_admin_shops} is true, admin shops won't be counted)
 */
public int getShopAmount(OfflinePlayer p) {
    float shopCount = 0;

    for (Shop shop : getShops()) {
        if (shop.getVendor().equals(p)) {
            if (shop.getShopType() != Shop.ShopType.ADMIN || !plugin.getShopChestConfig().exclude_admin_shops) {
                shopCount++;

                InventoryHolder ih = shop.getInventoryHolder();

                if (ih instanceof DoubleChest)
                    shopCount -= 0.5;
            }
        }
    }

    return Math.round(shopCount);
}
项目:BusyInv    文件:BusyMenu.java   
@Override
public boolean isOpenFor(Player p)
{
    InventoryView iview = p.getOpenInventory();
    if(null == iview)
        return false;
    Inventory inv = iview.getTopInventory();
    if(null == inv)
        return false;
    InventoryHolder holder = inv.getHolder();
    if(!(holder instanceof BusyHolder))
        return false;
    IBusyMenu menu = ((BusyHolder)holder).getMenu();
    if(!menu.equals(this))
        return false;
    return true;
}
项目:ShopChest    文件:ShopUtils.java   
/** Remove a shop
 * @param shop Shop to remove
 * @param removeFromDatabase Whether the shop should also be removed from the database
 * @param callback Callback that - if succeeded - returns null
 */
public void removeShop(Shop shop, boolean removeFromDatabase, Callback<Void> callback) {
    plugin.debug("Removing shop (#" + shop.getID() + ")");

    InventoryHolder ih = shop.getInventoryHolder();

    if (ih instanceof DoubleChest) {
        DoubleChest dc = (DoubleChest) ih;
        Chest r = (Chest) dc.getRightSide();
        Chest l = (Chest) dc.getLeftSide();

        shopLocation.remove(r.getLocation());
        shopLocation.remove(l.getLocation());
    } else {
        shopLocation.remove(shop.getLocation());
    }

    shop.removeItem();
    shop.removeHologram();

    if (removeFromDatabase) {
        plugin.getShopDatabase().removeShop(shop, callback);
    } else {
        if (callback != null) callback.callSyncResult(null);
    }
}
项目:BusyInv    文件:BusyMenu.java   
/**
 * If a BusyMenu is opened for the target player, this method will reload
 * the menu for the player.
 * 
 * @see {@link IBusyMenu#reload}
 * 
 * @param p
 *            Target player
 * @return true if and only if the menu is reloaded. Otherwise false(for
 *         example the player didn't open an inventory or the inventory
 *         isn't a menu)
 */
public static boolean reloadFor(Player p)
{
    InventoryView iview = p.getOpenInventory();
    if(null == iview)
        return false;
    Inventory inv = iview.getTopInventory();
    if(null == inv)
        return false;
    InventoryHolder holder = inv.getHolder();
    if(!(holder instanceof BusyHolder))
        return false;
    ((BusyHolder)holder).getMenu().updateFor(p);
    p.updateInventory();
    return true;
}
项目:Contraptions    文件:FactoryProperties.java   
/**
 * Creates a Factory Contraptions
 *
 * @param location Location to attempt creation
 * @return Created Contraption if successful
 */
@Override
public Response createContraption(BlockLocation location) {
    Anchor anchor = structureGadget.exists(location);
    if (anchor == null) {
        return new Response(false, "Incorrect structure for factory");
    }
    Inventory inventory = ((InventoryHolder) location.getBlock().getState()).getInventory();
    if (matchGadget.matches(inventory) && matchGadget.consume(inventory)) {
        Factory newFactory = new Factory(this, anchor);
        contraptionManager.registerContraption(newFactory);
        SoundType.CREATION.play(newFactory.getLocation());
        return new Response(true, "Created a " + newFactory.getName() + " factory!", newFactory);
    }
    return new Response(false, "Incorrect items for a Factory");
}
项目:Contraptions    文件:GeneratorProperties.java   
/**
 * Creates a Factory Contraptions
 *
 * @param anchor Anchor to attempt creation
 * @return Created Contraption if successful
 */
@Override
public Response createContraption(BlockLocation location) {
    //Check if interaction block is correct
    if (structureGadget.validBlock(location.getBlock())) {
        return new Response(false, "Incorrect block for a Factory");
    }
    Anchor anchor = structureGadget.exists(location);
    if (anchor == null) {
        return new Response(false, "Incorrect structure for factory");
    }
    Inventory inventory = ((InventoryHolder) location.getBlock().getState()).getInventory();
    if (matchGadget.matches(inventory) && matchGadget.consume(inventory)) {
        Generator newGenerator = new Generator(this, anchor);
        contraptionManager.registerContraption(newGenerator);
        SoundType.CREATION.play(anchor.getLocation());
        return new Response(true, "Created a " + newGenerator.getName() + " factory!", newGenerator);
    }
    return new Response(false, "Incorrect items for a Factory");
}
项目:vanillacraft    文件:GriefContainer.java   
public GriefContainer(BlockState block, UUID owner, boolean allowed)
{
    this.block = block;
    this.owner = owner;
    this.allowed = allowed;
    if (block instanceof Chest)
    {
        items = ((Chest) block).getBlockInventory().getContents();
    }
    else
    {
        items = ((InventoryHolder) block).getInventory().getContents();
    }

    timestamp = System.currentTimeMillis();
}
项目:Warzone    文件:WoolChestModule.java   
@Override
public void load(Match match) {
    runnableId = Bukkit.getScheduler().scheduleSyncRepeatingTask(TGM.get(), new Runnable() {
        @Override
        public void run() {
            for (InventoryHolder inventory : woolChests.keySet()) {
                fillInventoryWithWool(inventory.getInventory(), woolChests.get(inventory));
            }
        }
    }, 10 * 20L, 10 * 20L);
}
项目:Uranium    文件:CraftInventoryCustom.java   
public MinecraftInventory(InventoryHolder owner, int size, String title) {
    Validate.notNull(title, "Title cannot be null");
    Validate.isTrue(title.length() <= 32, "Title cannot be longer than 32 characters");
    this.items = new net.minecraft.item.ItemStack[size];
    this.title = title;
    this.viewers = new ArrayList<HumanEntity>();
    this.owner = owner;
    this.type = InventoryType.CHEST;
}
项目:Uranium    文件:CraftInventory.java   
public InventoryHolder getHolder() {
    // Cauldron start - fixes openblocks AbstractMethodError
    try {
        return inventory.getOwner();
    } catch (AbstractMethodError e) {
        if (inventory instanceof net.minecraft.tileentity.TileEntity) {
            return CauldronUtils.getOwner((net.minecraft.tileentity.TileEntity)inventory);
        } else {
            return null;                
        }
    }
    // Cauldron end
}
项目:Uranium    文件:CauldronUtils.java   
public static InventoryHolder getOwner(TileEntity tileentity)
{
    org.bukkit.block.BlockState state = tileentity.worldObj.getWorld().getBlockAt(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord).getState();

    if (state instanceof InventoryHolder)
    {
        return (InventoryHolder) state;
    }

    return null;
}
项目:EscapeLag    文件:AntiBreakUsingChest.java   
@EventHandler
public void CheckNoBreakChest(BlockBreakEvent e) {
    if (ConfigPatch.protectUsingChest) {
        Player p = e.getPlayer();
        if (e.getBlock().getState() instanceof InventoryHolder) {
            InventoryHolder ih = (InventoryHolder) e.getBlock().getState();
            if (ih.getInventory().getViewers().isEmpty() == false) {
                e.setCancelled(true);
                AzureAPI.log(p, ConfigPatch.AntiBreakUsingChestWarnMessage);
            }
        }
    }
}
项目:SparseBukkitAPI    文件:MenuManager.java   
@EventHandler
public void onInventoryOpen(InventoryOpenEvent e)
{
    if(!(e.getPlayer() instanceof Player))
        return;

    Inventory inv = e.getInventory();
    InventoryHolder holder = inv.getHolder();
    if(holder != null && holder instanceof Menu)
    {
        Menu menu = (Menu) holder;
        menu.viewers.add((Player) e.getPlayer());
        openMenus.add(menu);
    }
}
项目:SparseBukkitAPI    文件:MenuManager.java   
@EventHandler
public void onInventoryClick(InventoryClickEvent e)
{
    if(!(e.getWhoClicked() instanceof Player))
        return;

    Inventory inv = e.getInventory();
    InventoryHolder holder = inv.getHolder();
    if(holder != null && holder instanceof Menu)
    {
        Menu menu = (Menu) holder;
        menu.onClick(e);
    }
}
项目:ProjectAres    文件:WoolMatchModule.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onContainerPlace(BlockPlaceEvent event) {
    // Blacklist any placed container blocks
    if(event.getBlock().getState() instanceof InventoryHolder) {
        this.chests.put(((InventoryHolder) event.getBlock().getState()).getInventory(), false);
    }
}
项目:ProjectAres    文件:FillListener.java   
@Override
Stream<Inventory> inventories() {
    return Stream.concat(
        cache.region()
             .tileEntities(world)
             .filter(FillListener::isFillable)
             .filter(block -> !cache.filter().denies(block))
             .map(block -> ((InventoryHolder) block).getInventory()),
        cache.region()
             .entities(world)
             .filter(FillListener::isFillable)
             .filter(entity -> !cache.filter().denies(new EntityQuery(entity)))
             .map(entity -> ((InventoryHolder) entity).getInventory())
    );
}
项目:InventoryAPI    文件:McGui.java   
@Override
public void setSize( Vector2i dimension ) {
    Validate.isTrue( inventory.getType() == InventoryType.CHEST, "Size can only be adjusted if the inventory is a chest!" );
    ItemStack[] contents = inventory.getContents();
    InventoryHolder holder = inventory.getHolder();
    int stack = inventory.getMaxStackSize();
    String title = inventory.getTitle();

    inventory = Bukkit.createInventory( holder, dimension.getX() * dimension.getY(), title );
    inventory.setContents( contents );
    inventory.setMaxStackSize( stack );
}
项目:AlphaLibary    文件:Menu.java   
public void open(Player p, InventoryHolder holder) {
    Inventory inv = Bukkit.createInventory(holder, getSize(), getTitle());

    for (Map.Entry<Integer, MenuElement> element : this.elements.entrySet()) {
        inv.setItem(element.getKey(), element.getValue().getIcon(p));
    }

    getMenuManager().setMenuOpened(p, this);

    p.openInventory(inv);
}
项目:Punishments    文件:PunishGUI.java   
public static void open(Player player) 
{
    InventoryHolder holder = player;
    invHolder = holder;

    Inventory inv = Bukkit.createInventory(holder, 27, ChatColor.RED + "Punishment's");
    inventory = inv;

    player.openInventory(inv);
}