本文整理汇总了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();
}
}
}
示例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!"));
}
}
示例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));
}
}
}
示例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);
}
示例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();
}
示例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.");
}
示例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!");
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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!");
}
示例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;
}
示例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 );
}
示例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;
}