Examples of Inventory


Examples of net.sf.l2j.gameserver.model.Inventory

    }

    private List<TempItem> listItems(boolean remove)
    {
      L2RecipeInstance[] recipes = _recipeList.getRecipes();
      Inventory inv = _target.getInventory();
      List<TempItem> materials = new FastList<TempItem>();

      for (L2RecipeInstance recipe : recipes)
      {
        int quantity = _recipeList.isConsumable() ? (int) (recipe.getQuantity() * Config.RATE_CONSUMABLE_COST) : recipe.getQuantity();
        if (quantity > 0)
        {
          L2ItemInstance item = inv.getItemByItemId(recipe.getItemId());

          // check materials
          if (item==null || item.getCount() < quantity)
          {
            _target.sendMessage("You dont have the right elements for making this item"
                               + ((_recipeList.isConsumable() && Config.RATE_CONSUMABLE_COST != 1? ".\nDue to server rates you need "
                                                                                                     + Config.RATE_CONSUMABLE_COST
                                                                                                     + "x more material than listed in recipe"
                                                                                                     : ""));
            abort();
            return null;
          }

          // make new temporary object, just for counting puroses

          TempItem temp = new TempItem(item, quantity);
          materials.add(temp);
        }
      }

      if (remove)
      {
        for(TempItem tmp : materials)
          {
          inv.destroyItemByItemId("Manufacture", tmp.getItemId(), tmp.getQuantity(), _target, _player);
          }
      }
      return materials;
    }
View Full Code Here

Examples of org.bukkit.inventory.Inventory

        ConfigurationSection configGroups = f.getConfigurationSection("quizDiff." + quizWinners.get(pName));
        Set<String> s = configGroups.getKeys(false);
       
        // first of all, count all rewards and see if they'd fit into player's inventory
        Integer allBlocks = 0;
        Inventory pi = p.getInventory();
        Integer maxStackSize = pi.getMaxStackSize();
        for (String reward : s) {
          Integer blockCount = f.getInt("quizDiff." + quizWinners.get(pName) + "." + reward);
          if (blockCount > maxStackSize) {
            allBlocks = (int) (allBlocks + Math.ceil(blockCount / maxStackSize));
          } else {
            allBlocks++;
          }
        }
       
        // calculate available slots
        Integer fullSlots = 0;
        for (ItemStack istack : p.getInventory().getContents()) {
          if ((istack != null) && istack.getAmount() > 0) {
            fullSlots++;
          }
        }
 
        if ((pi.getSize() - fullSlots) >= allBlocks) {
          // fill player's inventory with the reward
          for (String reward : s) {
            try {
              if (reward.contains(":")) {
                String[] expl = reward.split(":");
                pi.addItem(new ItemStack(Integer.parseInt(expl[0]), f.getInt("quizDiff." + quizWinners.get(pName) + "." + reward), (short) 0, Byte.parseByte(expl[1])));
              } else {
                pi.addItem(new ItemStack(Integer.parseInt(reward), f.getInt("quizDiff." + quizWinners.get(pName) + "." + reward)));
              }
            } catch (Throwable e) {
              // unable to add item into inventory, inform server owner
              LogHelper.logSevere("[CommandsEX] " + _("quizUnableToAddItem", "") + reward + ":" + f.getInt("quizDiff." + quizWinners.get(pName) + "." + reward));
              LogHelper.logDebug("Message: " + e.getMessage() + ", cause: " + e.getCause());
View Full Code Here

Examples of org.bukkit.inventory.Inventory

                    s.remove("cooldown");
                    s.remove("onjoin");

                    // first of all, count all kit blocks and see if they'd fit into player's inventory
                    Integer allBlocks = 0;
                    Inventory pi = player.getInventory();
                    Integer maxStackSize = pi.getMaxStackSize();
                    for (String kitItem : s) {
                      Integer blockCount = f.getInt("kits." + group + "." + kit + "." + kitItem);
                      if (blockCount > maxStackSize) {
                        allBlocks = (int) (allBlocks + Math.ceil(blockCount / maxStackSize));
                      } else {
                        allBlocks++;
                      }
                    }

                    // calculate available slots
                    Integer fullSlots = 0;
                    for (ItemStack istack : player.getInventory().getContents()) {
                      if ((istack != null) && istack.getAmount() > 0) {
                        fullSlots++;
                      }
                    }

                    if ((pi.getSize() - fullSlots) >= allBlocks) {
                      // fill player's inventory with kit items
                      for (String kitItem : s) {
                        try {
                          if (kitItem.contains(":")) {
                            String[] expl = kitItem.split(":");
                            pi.addItem(new ItemStack(Integer.parseInt(expl[0]), f.getInt("kits." + group + "." + kit + "." + kitItem), (short) 0, Byte.parseByte(expl[1])));
                          } else {
                            pi.addItem(new ItemStack(Integer.parseInt(kitItem), f.getInt("kits." + group + "." + kit + "." + kitItem)));
                          }
                        } catch (Throwable e) {
                          // unable to add item into inventory, inform server owner
                          LogHelper.logSevere("[CommandsEX] " + _("kitsUnableToAddItem", "") + kitItem + ":" + f.getInt("kits." + group + "." + kit + "." + kitItem));
                          LogHelper.logDebug("Message: " + e.getMessage() + ", cause: " + e.getCause());
View Full Code Here

Examples of org.bukkit.inventory.Inventory

                LogHelper.showInfo("invalidPlayer", sender, ChatColor.RED);
                return true;
            }
        }

        Inventory inv = target.getInventory();
        player.openInventory(inv);
        LogHelper.showInfo("invSeeNowEditing#####[" + Nicknames.getNick(target.getName()), sender, ChatColor.AQUA);

        return true;
    }
View Full Code Here

Examples of org.bukkit.inventory.Inventory

                    signsWriter.newLine();
                  }
                } else if (state instanceof Chest) {
                  // Chests
                  Chest chest = (Chest) state;
                  Inventory inv = chest.getInventory();
                  List<ItemStack> items = VolumeMapper.getItemListFromInv(inv);
                  invsWriter.write(VolumeMapper.buildInventoryStringFromItemList(items));
                  invsWriter.newLine();
                } else if (state instanceof Dispenser) {
                  // Dispensers
                  Dispenser dispenser = (Dispenser) state;
                  Inventory inv = dispenser.getInventory();
                  List<ItemStack> items = VolumeMapper.getItemListFromInv(inv);
                  invsWriter.write(VolumeMapper.buildInventoryStringFromItemList(items));
                  invsWriter.newLine();
                }
                noOfSavedBlocks++;
View Full Code Here

Examples of org.bukkit.inventory.Inventory

        inv.setLeggings(null);
        inv.setBoots(null);
        InventoryView view = p.getOpenInventory();
        if (view != null) {
            view.setCursor(null);
            Inventory i = view.getTopInventory();
            if (i != null) {
                i.clear();
            }
        }
    }
View Full Code Here

Examples of org.bukkit.inventory.Inventory

   
    public RepairableContainer(BlockState state, boolean clear) {
        super(state);

        // Grab the inventory of the block
        Inventory inv = ((InventoryHolder) state).getInventory();
        ItemStack[] stacks = inv.getContents();

        // Manual copy is necessary due to "reduce to 0" bug in Bukkit
        contents = new ItemStack[stacks.length];
        for (int i = 0; i < contents.length; i++) {
            contents[i] = (stacks[i] != null) ? stacks[i].clone() : null;
        }
       
        // Clear the inventory if prompted
        if (clear) inv.clear();
    }
View Full Code Here

Examples of org.bukkit.inventory.Inventory

    public void repair() {
        super.repair();
       
        // Grab the inventory
        InventoryHolder cb = (InventoryHolder) getWorld().getBlockAt(getX(),getY(),getZ()).getState();
        Inventory chestInv = cb.getInventory();

        chestInv.setContents(contents);
    }
View Full Code Here

Examples of org.bukkit.inventory.Inventory

  public void fillChest(final Block block) {
    try {
      if (!(block.getState() instanceof Chest))
        return;
      Chest chestB = ((Chest) block.getState());
      Inventory chest = chestB.getBlockInventory();
      for (int i = 0; i < plugin.getSingleRandom().nextInt(
          chest.getSize()); i++) {
        ItemStack cis = getItem();
        while (cis == null) {
          cis = getItem();
        }
        chest.setItem(i, cis);
      }
    } catch (Exception e) {
    }
  }
View Full Code Here

Examples of org.bukkit.inventory.Inventory

  public void fillChest(final Block block, final int size) {
    try {
      if (!(block.getState() instanceof Chest))
        return;
      Chest chestB = ((Chest) block.getState());
      Inventory chest = chestB.getBlockInventory();
      for (int i = 0; i < size; i++) {
        ItemStack cis = getItem();
        while (cis == null) {
          cis = getItem();
        }
        chest.setItem(i, cis);
      }
    } catch (Exception e) {
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.