當前位置: 首頁>>代碼示例>>Java>>正文


Java DoubleChest類代碼示例

本文整理匯總了Java中org.bukkit.block.DoubleChest的典型用法代碼示例。如果您正苦於以下問題:Java DoubleChest類的具體用法?Java DoubleChest怎麽用?Java DoubleChest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DoubleChest類屬於org.bukkit.block包,在下文中一共展示了DoubleChest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: passesFilter

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
/**
 * 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;
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:23,代碼來源:FillListener.java

示例2: checkWorth

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void checkWorth(InventoryOpenEvent event) {
    // Do nothing if a player did not open the inventory or if chest events
    // are disabled.
    if (!(event.getPlayer() instanceof Player) || plugin.getSettings().isDisableChestEvents()) {
        return;
    }

    Inventory inventory = event.getInventory();

    // Set all default worth values for this chest.
    if (inventory.getHolder() instanceof DoubleChest) {
        DoubleChest chest = (DoubleChest) inventory.getHolder();
        checkWorth((Chest) chest.getLeftSide());
        checkWorth((Chest) chest.getRightSide());
    }

    if (inventory.getHolder() instanceof Chest) {
        checkWorth((Chest) inventory.getHolder());
    }
}
 
開發者ID:novucs,項目名稱:factions-top,代碼行數:22,代碼來源:WorthListener.java

示例3: updateWorth

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void updateWorth(InventoryCloseEvent event) {
    // Do nothing if a player did not close the inventory or if chest
    // events are disabled.
    if (!(event.getPlayer() instanceof Player) || plugin.getSettings().isDisableChestEvents()) {
        return;
    }

    // Get cached values from when chest was opened and add the difference
    // to the worth manager.
    if (event.getInventory().getHolder() instanceof DoubleChest) {
        DoubleChest chest = (DoubleChest) event.getInventory().getHolder();
        updateWorth((Chest) chest.getLeftSide());
        updateWorth((Chest) chest.getRightSide());
    }

    if (event.getInventory().getHolder() instanceof Chest) {
        updateWorth((Chest) event.getInventory().getHolder());
    }
}
 
開發者ID:novucs,項目名稱:factions-top,代碼行數:21,代碼來源:WorthListener.java

示例4: onInventoryCloseEvent

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
@EventHandler
public void onInventoryCloseEvent(InventoryCloseEvent event) {
	//long time=System.nanoTime();
	if(event.getInventory().getType()==InventoryType.CHEST&&CleanShop.shopScan)
	{
		Vector<ProtectedRegion> regions=null;
		if(event.getInventory().getHolder() instanceof Chest)
			regions=ShopUtils.getRegions(((Chest)event.getInventory().getHolder()).getLocation());
		if(event.getInventory().getHolder() instanceof DoubleChest)
			regions=ShopUtils.getRegions(((DoubleChest)event.getInventory().getHolder()).getLocation());
		if(regions!=null)
			for(ProtectedRegion p:regions)
			{
				if(p!=null)
					if(ShopUtils.shopExists(p))
					{
						//plugin.calculateShopStock(plugin.getShop(p));
						if(event.getInventory().getHolder() instanceof Chest)
							ChestUtils.calculateChestStock((Chest)event.getInventory().getHolder(), ShopUtils.getShop(p));
						else
							ChestUtils.calculateChestStock((DoubleChest)event.getInventory().getHolder(), ShopUtils.getShop(p));
						FileHandler.saveShops();
					}
			}
	}
}
 
開發者ID:OmniKraftDevelopers,項目名稱:CleanShop,代碼行數:27,代碼來源:EventListener.java

示例5: updatePearlHolder

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
/**
 * 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);
	}
}
 
開發者ID:DevotedMC,項目名稱:ExilePearl,代碼行數:29,代碼來源:PlayerListener.java

示例6: removeShop

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
/** 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);
    }
}
 
開發者ID:EpicEricEE,項目名稱:ShopChest,代碼行數:31,代碼來源:ShopUtils.java

示例7: getShopAmount

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:EpicEricEE,項目名稱:ShopChest,代碼行數:24,代碼來源:ShopUtils.java

示例8: remove

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
private void remove(final Shop shop, final Block b, final Player p) {
    if (shop.getInventoryHolder() instanceof DoubleChest) {
        DoubleChest dc = (DoubleChest) shop.getInventoryHolder();
        final Chest l = (Chest) dc.getLeftSide();
        final Chest r = (Chest) dc.getRightSide();

        Location loc = (b.getLocation().equals(l.getLocation()) ? r.getLocation() : l.getLocation());
        final Shop newShop = new Shop(shop.getID(), plugin, shop.getVendor(), shop.getProduct(), loc, shop.getBuyPrice(), shop.getSellPrice(), shop.getShopType());

        shopUtils.removeShop(shop, true, new Callback<Void>(plugin) {
            @Override
            public void onResult(Void result) {
                newShop.create(true);
                shopUtils.addShop(newShop, true);
            }
        });
    } else {
        shopUtils.removeShop(shop, true);
        plugin.debug(String.format("%s broke %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));
        p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.SHOP_REMOVED));
    }
}
 
開發者ID:EpicEricEE,項目名稱:ShopChest,代碼行數:23,代碼來源:ChestProtectListener.java

示例9: onItemMove

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onItemMove(InventoryMoveItemEvent e) {
    if (config.hopper_protection) {
        if ((e.getSource().getType().equals(InventoryType.CHEST)) && (!e.getInitiator().getType().equals(InventoryType.PLAYER))) {

            if (e.getSource().getHolder() instanceof DoubleChest) {
                DoubleChest dc = (DoubleChest) e.getSource().getHolder();
                Chest r = (Chest) dc.getRightSide();
                Chest l = (Chest) dc.getLeftSide();

                if (shopUtils.isShop(r.getLocation()) || shopUtils.isShop(l.getLocation())) e.setCancelled(true);

            } else if (e.getSource().getHolder() instanceof Chest) {
                Chest c = (Chest) e.getSource().getHolder();

                if (shopUtils.isShop(c.getLocation())) e.setCancelled(true);
            }

        }
    }
}
 
開發者ID:EpicEricEE,項目名稱:ShopChest,代碼行數:22,代碼來源:ChestProtectListener.java

示例10: setHolder

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
public void setHolder(InventoryHolder holder) throws CivException {
	if (holder instanceof Player) {
		Player player = (Player)holder;
		playerName = player.getName();
		blockLocation = null;
		return;
	} 
	
	if (holder instanceof Chest) {
		Chest chest = (Chest)holder;
		playerName = null;
		blockLocation = chest.getLocation();
		return;
	} 
	
	if (holder instanceof DoubleChest) {
		DoubleChest dchest = (DoubleChest)holder;
		playerName = null;
		blockLocation = dchest.getLocation();
		return;
	}
	
	throw new CivException("Invalid holder passed to set holder:"+holder.toString());
}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:25,代碼來源:InventoryHolderStorage.java

示例11: getLocationForHolder

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
private Location getLocationForHolder(InventoryHolder holder)
{
    if (holder instanceof Entity)
    {
        return ((Entity)holder).getLocation();
    }
    else if (holder instanceof DoubleChest)
    {
        //((Chest)inventory.getLeftSide().getHolder()).getLocation()
        return ((DoubleChest)holder).getLocation();
        //TODO get the correct chest
    }
    else if (holder instanceof BlockState)
    {
        return ((BlockState)holder).getLocation();
    }
    if (holder != null)
    {
        this.module.getLog().debug("Unknown InventoryHolder: {}", holder.getClass().getName());
    }
    return null;
}
 
開發者ID:CubeEngine,項目名稱:modules-extra,代碼行數:23,代碼來源:ListenerContainerItem.java

示例12: getLocationForHolder

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
private Location getLocationForHolder(InventoryHolder holder)
{
    if (holder instanceof Entity)
    {
        return ((Entity)holder).getLocation();
    }
    else if (holder instanceof DoubleChest)
    {
        //((Chest)inventory.getLeftSide().getHolder()).getLocation()
        return ((DoubleChest)holder).getLocation();
        //TODO get the correct chest
    }
    else if (holder instanceof BlockState)
    {
        return ((BlockState)holder).getLocation();
    }
    if (holder != null)
    {
        this.module.getLog().warn("Unknown InventoryHolder: {}", holder.getClass().getName());
    }
    return null;
}
 
開發者ID:CubeEngine,項目名稱:modules-extra,代碼行數:23,代碼來源:ListenerItemMove.java

示例13: getVanillaInventoryFor

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
/**
 * Get the vanilla inventory for the given block.
 *
 * @param target the block containing the target inventory
 * @return the block's inventory, or null if the block does not have one
 */
public static Inventory getVanillaInventoryFor(Block target) {
    switch (target.getType()) {
        case CHEST:
            Chest c = (Chest) target.getState();
            if (c.getInventory().getHolder() instanceof DoubleChest) {
                DoubleChest dc = (DoubleChest) c.getInventory().getHolder();
                return dc.getInventory();
            } else {
                return c.getBlockInventory();
            }
        case DISPENSER:
        case HOPPER:
        case DROPPER:
        case FURNACE:
        case BREWING_STAND:
        case BURNING_FURNACE:
            return ((InventoryHolder) target.getState()).getInventory();
        // any other vanilla inventory types ?
        default:
            return null;
    }
}
 
開發者ID:desht,項目名稱:sensibletoolbox,代碼行數:29,代碼來源:VanillaInventoryUtils.java

示例14: onInventoryOpen

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(final InventoryOpenEvent event) {
    final Inventory inventory = event.getInventory();
    final InventoryHolder holder = inventory.getHolder();
    if (holder instanceof Chest || holder instanceof DoubleChest) {
        final BlockState chest = (BlockState)(holder instanceof Chest ? holder : ((DoubleChest)holder).getLeftSide());
        final Block block = chest.getBlock();
        final NLocation loc = new NLocation(block.getLocation());
        final List<Sign> signs = SignUtil.getSignsForChest(block);
        for (final Sign sign : signs) {
            if (sign.getLine(0).equals(ITEMNETWORK_EMITTER)) {
                this.feature.lock(loc);
            }
        }
    }
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:17,代碼來源:ItemNetworkListener.java

示例15: updateOtherDoubleChestBlocks

import org.bukkit.block.DoubleChest; //導入依賴的package包/類
private void updateOtherDoubleChestBlocks() {
	if (cachedInv.getHolder() instanceof DoubleChest) {
		Material chestMaterial = block.getType();
		Location otherChestLoc = null;
		for (WrappedDirection pd : WrappedDirection.values()) {
			if (pd.isSide()) {
				if (block.getRelative(pd.getX(), pd.getY(), pd.getZ()).getType() == chestMaterial) {
					otherChestLoc = block.getRelative(pd.getX(), pd.getY(), pd.getZ()).getLocation();
				}
			}
		}
		Map<BlockLoc, TransportPipesContainer> containerMap = TransportPipes.instance
				.getContainerMap(block.getWorld());

		if (containerMap != null) {
			BlockLoc bl = BlockLoc.convertBlockLoc(otherChestLoc);
			if (containerMap.containsKey(bl)) {
				TransportPipesContainer tpc = containerMap.get(bl);
				if (tpc instanceof SimpleInventoryContainer) {
					SimpleInventoryContainer sic = (SimpleInventoryContainer) tpc;
					if (!(sic.cachedInv instanceof DoubleChestInventory)) {
						sic.updateBlock();
					}
				}
			}
		}
	}
}
 
開發者ID:RoboTricker,項目名稱:Transport-Pipes,代碼行數:29,代碼來源:SimpleInventoryContainer.java


注:本文中的org.bukkit.block.DoubleChest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。