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


Java Chest.getInventory方法代碼示例

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


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

示例1: getBlockInventory

import org.bukkit.block.Chest; //導入方法依賴的package包/類
/**
 * Gets the single block inventory for a potentially double chest.
 * Handles people who have an old version of Bukkit.
 * This should be replaced with {@link org.bukkit.block.Chest#getBlockInventory()}
 * in a few months (now = March 2012) // note from future dev - lol
 *
 * @param chest The chest to get a single block inventory for
 * @return The chest's inventory
 */
private Inventory getBlockInventory(Chest chest) {
    try {
        return chest.getBlockInventory();
    } catch (Throwable t) {
        if (chest.getInventory() instanceof DoubleChestInventory) {
            DoubleChestInventory inven = (DoubleChestInventory) chest.getInventory();
            if (inven.getLeftSide().getHolder().equals(chest)) {
                return inven.getLeftSide();
            } else if (inven.getRightSide().getHolder().equals(chest)) {
                return inven.getRightSide();
            } else {
                return inven;
            }
        } else {
            return chest.getInventory();
        }
    }
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:28,代碼來源:BukkitWorld.java

示例2: deliverSupplyDrop

import org.bukkit.block.Chest; //導入方法依賴的package包/類
public void deliverSupplyDrop(World world) {
	Random r = new Random();

	// Supply drops between -500, + 500
	double x = r.nextInt(1000) - 500;
	double y = 0.0D;
	double z = r.nextInt(1000) - 500;

	Location dropLocation = new Location(world, x, y, z);

	// Get the highest block at that location.
	dropLocation.setY(world.getHighestBlockYAt(dropLocation));

	dropLocation.getBlock().setType(Material.CHEST);
	Chest dropChest = (Chest) dropLocation.getBlock().getState();

	SupplyDropObject supplyDrop = new SupplyDropObject(dropLocation, dropChest, dropChest.getInventory());
	addSupplyDrop(supplyDrop);

	for (Player p : world.getPlayers()) {
		p.sendMessage(MortuusTerraCore.ALERT_PREFIX + StringUtilities
				.color("&eSupply Drop spotted at: &6" + x + ", " + dropLocation.getY() + ", " + z + "&e!"));
	}
}
 
開發者ID:kadeska,項目名稱:MT_Core,代碼行數:25,代碼來源:SupplyDropManager.java

示例3: set

import org.bukkit.block.Chest; //導入方法依賴的package包/類
public void set(Location loc, Material material) {
	if (loc.getBlock().getType().equals(Material.AIR)) {
		loc.getBlock().setType(material);
		if (material.equals(Material.CHEST) || material.equals(Material.TRAP_DOOR)) {
			Chest chest = (Chest) loc.getBlock().getState();
			Inventory inv = chest.getInventory();
			for (int i = 0; i < inv.getSize(); i++) {
				Random gen = new Random();
				inv.setItem(i, new ItemStack(Material.values()[gen.nextInt(Material.values().length)]));
			}
			inv.setItem(4, new ItemStack(Material.BEDROCK));
			inv.setItem(13, new ItemStack(Material.BEDROCK));
			inv.setItem(21, new ItemStack(Material.BEDROCK));
			inv.setItem(23, new ItemStack(Material.BEDROCK));
		}
	}
}
 
開發者ID:iZenith,項目名稱:IZenith-Main,代碼行數:18,代碼來源:BowListener.java

示例4: getWorth

import org.bukkit.block.Chest; //導入方法依賴的package包/類
private double getWorth(Sign s) {

		double total = 0;
		Location l = new Location(s.getWorld(), s.getLocation().getX(), (s.getLocation().getY() - 1), s.getLocation().getZ());
		Chest c = (Chest) l.getBlock().getState();
		Inventory i = c.getInventory();

		for (ItemStack finalStack : i.getContents()) {
			if (finalStack == null)
				continue;

			if (inBlacklist(finalStack.getType())) {
				continue;
			}
			double quantity = finalStack.getAmount();
			ItemStack checkStack = new ItemStack(finalStack);
			checkStack.setAmount(1);
			if (itemIndex.get(checkStack) == null)
				continue;
			double price = itemIndex.get(checkStack);
			total = total + (price * quantity);
		}
		return roundTwoDecimals(total);

	}
 
開發者ID:StarQuestMinecraft,項目名稱:StarQuestCode,代碼行數:26,代碼來源:SQShops.java

示例5: popChest

import org.bukkit.block.Chest; //導入方法依賴的package包/類
private void popChest(Block item,Random rand) {
	//if (item.getType() != Material.CHEST) return;
	
	Chest c = (Chest) item.getState();
	Inventory inv = c.getInventory();
	
	int count = rand.nextInt(6);
	
	
	for (int i = 1; i < count; i++) {
		int chance = rand.nextInt(chestLoot.length);
		int amount = rand.nextInt(5);
		amount++;
		ItemStack is = new ItemStack(chestLoot[chance],amount);
		inv.addItem(is);
	}
	//MonoCities.log("populating chest");
	c.update();
	
}
 
開發者ID:monofuel,項目名稱:MonoMods,代碼行數:21,代碼來源:CityPopulator.java

示例6: onCommand

import org.bukkit.block.Chest; //導入方法依賴的package包/類
@CommandHandler("markchest")
@Permission("craftoplugin.extra.markchest")
public void onCommand(CommandSender cs, String[] args) {
	PermissionModule perm = PermissionModule.getInstance().get();

	Group group = Groups.DEFAULT;
	if (args.length == 0) { group = Groups.DEFAULT; }
	else if (args[0].equalsIgnoreCase("vip")) {group = Groups.VIP; }
	else if (args[0].equalsIgnoreCase("trusted")) { group = Groups.TRUSTED; }

	if (!(cs instanceof Player)) { sendFailure(cs, "sender not player"); return; }
	Player sender = (Player)cs;

	Block block = Utility.getTargetBlock(sender, 5).orElse(null);
	if (!block.getType().equals(Material.CHEST)) { sendFailure(cs, "block not chest"); return; }

	Chest chest = (Chest) block.getState();
	Inventory inventory = chest.getInventory();

	if (group == Groups.VIP) { vipInventories.add(inventory); }
	else if (group == Groups.TRUSTED) { trustedInventories.add(inventory); }
	else { defaultInventories.add(inventory); }

	sendSuccess(cs, "Kiste erfolgreich als " + group.getName() + " Kiste markiert.");
}
 
開發者ID:Craftolution,項目名稱:CraftoPlugin,代碼行數:26,代碼來源:ChestFillComponent.java

示例7: createFactory

import org.bukkit.block.Chest; //導入方法依賴的package包/類
public InteractionResponse createFactory(Location factoryLocation, Location inventoryLocation, Location powerSourceLocation) 
{
PrintingPressProperties printingPressProperties = plugin.getPrintingPressProperties();
	
	if (!factoryExistsAt(factoryLocation))
	{
		Block inventoryBlock = inventoryLocation.getBlock();
		Chest chest = (Chest) inventoryBlock.getState();
		Inventory chestInventory = chest.getInventory();
		ItemList<NamedItemStack> inputs = printingPressProperties.getConstructionMaterials();
		boolean hasMaterials = inputs.allIn(chestInventory);
		if (hasMaterials)
		{
			PrintingPress production = new PrintingPress(factoryLocation, inventoryLocation, powerSourceLocation, false, plugin.getPrintingPressProperties());
			if (printingPressProperties.getConstructionMaterials().removeFrom(production.getInventory()))
			{
				addFactory(production);
				return new InteractionResponse(InteractionResult.SUCCESS, "Successfully created " + printingPressProperties.getName());
			}
		}
		return new InteractionResponse(InteractionResult.FAILURE, "Not enough materials in chest!");
	}
	return new InteractionResponse(InteractionResult.FAILURE, "There is already a " + printingPressProperties.getName() + " there!");
}
 
開發者ID:gmlaxfanatic,項目名稱:FactoryMod,代碼行數:25,代碼來源:PrintingPressManager.java

示例8: initializeInventory

import org.bukkit.block.Chest; //導入方法依賴的package包/類
/**
 * Initializes the inventory for this factory
 */
//Due to non-destructable factories this will not have been called on reconstructed factories
//however I am unable to find a use for this method in the current code, so it doesn't
//seem to be an issue right now, maybe  the calls in the constructor should be gotten rid of
//all methods that get the inventory reinitialize the contents.
public void initializeInventory()
{
	switch(factoryType)
	{
	case PRODUCTION:
		Chest chestBlock = (Chest)factoryInventoryLocation.getBlock().getState();
		factoryInventory = chestBlock.getInventory();
		Furnace furnaceBlock = (Furnace)factoryPowerSourceLocation.getBlock().getState();
		factoryPowerInventory = furnaceBlock.getInventory();
		break;
	default:
		break;
	}
}
 
開發者ID:gmlaxfanatic,項目名稱:FactoryMod,代碼行數:22,代碼來源:FactoryObject.java

示例9: generateLoot

import org.bukkit.block.Chest; //導入方法依賴的package包/類
public void generateLoot(Location location) {
	_location = location;
	
	Block b = location.getWorld().getBlockAt(_location);
	b.setType(Material.CHEST);
	
	ItemStack[] stacks = _content.toArray(new ItemStack[_content.size()]);
	
	if (b.getType() == Material.CHEST) {
		_chestBlock = b;
		_chestItem = (Chest)b.getState();
		Inventory inv = _chestItem.getInventory();
		inv.setContents(stacks);
	}
}
 
開發者ID:Allov,項目名稱:world-of-icerealm,代碼行數:16,代碼來源:Loot.java

示例10: setChest

import org.bukkit.block.Chest; //導入方法依賴的package包/類
public boolean setChest(Location chestLocation, Perk perk) {
    if (chestLocation != null) {
        final Block block = chestLocation.getWorld().getBlockAt(chestLocation);
        if (block != null && block.getType() == Material.CHEST) {
            final Chest chest = (Chest) block.getState();
            final Inventory inventory = chest.getInventory();
            inventory.addItem(Settings.island_chestItems);
            if (Settings.island_addExtraItems) {
                inventory.addItem(ItemStackUtil.createItemArray(perk.getExtraItems()));
            }
            return true;
        }
    }
    return false;
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:16,代碼來源:IslandGenerator.java

示例11: openInventory

import org.bukkit.block.Chest; //導入方法依賴的package包/類
public static void openInventory(Player player, Block block) {
	
	// if block is null or not a death chest block, do nothing and return
	if (block == null || ! isDeathChestBlock(block)) {
		return;
	}
	
	// if block is wall sign, set block to attached block
	if (block.getType().equals(Material.WALL_SIGN)) {
	    Sign sign = (Sign)block.getState().getData();
	    block = block.getRelative(sign.getAttachedFace());
	}
	// if block is sign post, set block to one block below
	else if (block.getType().equals(Material.SIGN_POST)) {
		block = block.getRelative(0, 1, 0);
	}
	
	// confirm block is a death chest
	if (! block.getType().equals(Material.CHEST) || ! DeathChestBlock.isDeathChestBlock(block)) {
		return;
	}
	
	// open chest inventory
	BlockState state = block.getState();
	Chest chest = (Chest)state;
	Inventory inventory = chest.getInventory();
	player.openInventory(inventory);
}
 
開發者ID:tim-savage,項目名稱:SavageDeathChest,代碼行數:29,代碼來源:DeathChestBlock.java

示例12: createFactory

import org.bukkit.block.Chest; //導入方法依賴的package包/類
public InteractionResponse createFactory(Location factoryLocation, Location inventoryLocation, Location powerSourceLocation) 
{
	if (!factoryExistsAt(factoryLocation))
	{
		HashMap<String, ProductionProperties> properties = plugin.productionProperties;
		Block inventoryBlock = inventoryLocation.getBlock();
		Chest chest = (Chest) inventoryBlock.getState();
		Inventory chestInventory = chest.getInventory();
		String subFactoryType = null;
		for (Map.Entry<String, ProductionProperties> entry : properties.entrySet())
		{
			ItemList<NamedItemStack> inputs = entry.getValue().getInputs();
			if(inputs.exactlyIn(chestInventory))
			{
				subFactoryType = entry.getKey();
			}
		}
		if (subFactoryType != null)
		{
			ProductionFactory production = new ProductionFactory(factoryLocation, inventoryLocation, powerSourceLocation,subFactoryType);
			if (properties.get(subFactoryType).getInputs().allIn(production.getInventory()))
			{
				addFactory(production);
				properties.get(subFactoryType).getInputs().removeFrom(production.getInventory());
				return new InteractionResponse(InteractionResult.SUCCESS, "Successfully created " + production.getProductionFactoryProperties().getName());
			}
		}
		return new InteractionResponse(InteractionResult.FAILURE, "Incorrect materials in chest! Stacks must match perfectly.");
	}
	return new InteractionResponse(InteractionResult.FAILURE, "There is already a factory there!");
}
 
開發者ID:gmlaxfanatic,項目名稱:FactoryMod,代碼行數:32,代碼來源:ProductionManager.java

示例13: getInventory

import org.bukkit.block.Chest; //導入方法依賴的package包/類
/**
 * returns the factory Inventory(normally a chest), updates the inventory variable aswell.
 */
public Inventory getInventory()
{
	Chest chestBlock = (Chest)factoryInventoryLocation.getBlock().getState();
	factoryInventory = chestBlock.getInventory();
	return factoryInventory;
}
 
開發者ID:gmlaxfanatic,項目名稱:FactoryMod,代碼行數:10,代碼來源:FactoryObject.java

示例14: fillChest

import org.bukkit.block.Chest; //導入方法依賴的package包/類
public void fillChest(Block block){
	Chest chest = ( Chest ) block.getState();
	Inventory inventory = chest.getInventory();
	ItemStack itemstack = new ItemStack( Material.GLOWSTONE_DUST, 1);
	ItemMeta meta = itemstack.getItemMeta();
	meta.setDisplayName("�bChristmas Essence");
	itemstack.setItemMeta(meta);
	
	inventory.addItem( itemstack );
}
 
開發者ID:EmilHernvall,項目名稱:tregmine,代碼行數:11,代碼來源:OldChristmasTreePopulator.java

示例15: DPChest

import org.bukkit.block.Chest; //導入方法依賴的package包/類
/**
 * Creates a new DPChest.
 *
 * @param dropParty The DropParty instance.
 * @param party     The party of the DPChest.
 * @param chest     The chest.
 */
public DPChest(DropParty dropParty, Party party, Chest chest) {
    this.dropParty = dropParty;
    this.party = party;
    this.chest = chest;
    this.inventory = chest.getInventory();
    this.isDoubleChest = inventory.getHolder() instanceof DoubleChest;
}
 
開發者ID:Amperial,項目名稱:DropParty,代碼行數:15,代碼來源:DPChest.java


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