当前位置: 首页>>代码示例>>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;未经允许,请勿转载。