Example #1
0
  /**
   * copies a map of Items to a chest
   *
   * @param toDrop the items to copy
   * @param chest
   * @return items copied
   */
  private LinkedList<ItemStack> copyInventoryToChest(
      HashMap<Integer, ItemStack> toDrop, Chest chest) {
    Inventory chestInv = chest.getInventory();

    Block doubleChestBlock = getDoubleChest(chest.getBlock());
    boolean isDoubleChest = !(doubleChestBlock == null);

    LinkedList<ItemStack> toRemove = new LinkedList<ItemStack>();

    if (chestInv == null) return toRemove;

    for (Integer key : toDrop.keySet()) {
      ItemStack item = toDrop.get(key);
      if (item == null) continue;
      if (chestInv.firstEmpty() == -1) {
        if (!isDoubleChest) break;
        isDoubleChest = false;

        chestInv = ((Chest) doubleChestBlock.getState()).getInventory();
        if (chestInv.firstEmpty() == -1) break;
      }
      chestInv.addItem(item);
      toRemove.add(item);
    }
    return toRemove;
  }
Example #2
0
  @Override
  public void setAmountsInventory(Inventory inventory, TEntityStatus status, StockItem item) {
    Trader trader = tNpcManager.instance().getTraderRelation(player);

    // debug info
    dB.info("Setting inventory, status: ", TEntityStatus.SELL_AMOUNTS.name().toLowerCase());

    // clear the inventory
    inventory.clear();
    for (Integer amount : item.getAmounts()) {
      // set new amount
      List<String> lore = item.getDescription(status);
      lore = Limit.loreRequest(player.getName(), item, lore, status);
      lore.addAll(new ShopSession(trader, player).getDescription("sell", item, amount));

      ItemStack itemStack = item.getItem(false, lore);
      itemStack.setAmount(amount);

      // set the lore
      ItemMeta meta = itemStack.getItemMeta();

      meta.setLore(lore);

      itemStack.setItemMeta(meta);

      // set the item
      inventory.setItem(inventory.firstEmpty(), NBTUtils.markItem(itemStack));
    }
    setUi(inventory, null, TEntityStatus.SELL_AMOUNTS);
  }
Example #3
0
  @Override
  public void setInventory(Inventory inventory, TEntityStatus status) {
    Trader trader = tNpcManager.instance().getTraderRelation(player);

    // debug info
    dB.info("Setting inventory, status: ", status.name().toLowerCase());

    // clear the inventory
    inventory.clear();
    for (StockItem item : this.stock.get(status.asStock())) {
      if (item.getSlot() < 0) item.setSlot(inventory.firstEmpty());

      // set the lore
      List<String> lore = item.getDescription(status);
      lore = Limit.loreRequest(player.getName(), item, lore, status);
      lore.addAll(
          new ShopSession(trader, player).getDescription(status.asStock(), item, item.getAmount()));

      ItemStack itemStack = item.getItem(false, lore);

      // set the item
      inventory.setItem(item.getSlot(), NBTUtils.markItem(itemStack));
    }
    setUi(inventory, null, status);
  }
Example #4
0
 public static void giveTool(Player player, int type) {
   final Inventory inv = player.getInventory();
   if (inv.contains(type))
     player.sendMessage(ChatColor.RED + "You have already a " + materialName(type));
   else {
     final int free = inv.firstEmpty();
     if (free >= 0) {
       if (player.getItemInHand() != null && player.getItemInHand().getTypeId() != 0)
         inv.setItem(free, player.getItemInHand());
       player.setItemInHand(new ItemStack(type, 1));
       player.sendMessage(ChatColor.GREEN + "Here's your " + materialName(type));
     } else player.sendMessage(ChatColor.RED + "You have no empty slot in your inventory");
   }
 }
  public Inventory inventoryView(String name) {
    Inventory view = Bukkit.createInventory(this, (bankTabs.get(0).getTabSize() + 1) * 9, name);
    for (BankItem item : bankTabs.get(0).getTabItems()) {

      ItemStack chk = item.getItemStack().clone(); // new
      // ItemStack(item.getItemStack().getType(),item.getItemStack().getAmount(),item.getItemStack().getDurability());
      //   chk.addEnchantments(item.getItemStack().getEnchantments());

      if (item.getSlot() < 0) item.setSlot(view.firstEmpty());
      view.setItem(item.getSlot(), chk);
    }

    tabSelectionView(view);
    return view;
  }
  public static void Demoman(Player p) {
    Inventory inv = Bukkit.getServer().createInventory(p, 54, "Kit Demoman");

    ItemStack vidro = new ItemStack(Material.THIN_GLASS);
    ItemMeta metav = vidro.getItemMeta();
    metav.setDisplayName("");
    vidro.setItemMeta(metav);

    ItemStack meio = new ItemStack(353);
    ItemMeta metam = meio.getItemMeta();
    metam.setDisplayName("§a§oVoltar");
    meio.setItemMeta(metam);
    inv.setItem(0, meio);

    inv.setItem(0, vidro);
    inv.setItem(1, vidro);
    inv.setItem(2, vidro);
    inv.setItem(3, vidro);
    inv.setItem(4, meio);
    inv.setItem(5, vidro);
    inv.setItem(6, vidro);
    inv.setItem(7, vidro);
    inv.setItem(8, vidro);
    inv.setItem(9, vidro);
    inv.setItem(10, vidro);
    inv.setItem(11, vidro);
    inv.setItem(12, vidro);
    inv.setItem(13, vidro);
    inv.setItem(14, vidro);
    inv.setItem(15, vidro);
    inv.setItem(16, vidro);
    inv.setItem(17, vidro);
    inv.setItem(18, vidro);
    inv.setItem(20, vidro);
    inv.setItem(22, vidro);
    inv.setItem(24, vidro);
    inv.setItem(26, vidro);
    inv.setItem(27, vidro);
    inv.setItem(28, vidro);
    inv.setItem(29, vidro);
    inv.setItem(30, vidro);
    inv.setItem(31, vidro);
    inv.setItem(32, vidro);
    inv.setItem(33, vidro);
    inv.setItem(35, vidro);
    inv.setItem(34, vidro);
    inv.setItem(37, vidro);
    inv.setItem(38, vidro);
    inv.setItem(39, vidro);
    inv.setItem(40, vidro);
    inv.setItem(41, vidro);
    inv.setItem(42, vidro);
    inv.setItem(43, vidro);
    {
      ItemStack pyro = new ItemStack(Material.MAP);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§aKit Demoman");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }
    {
      ItemStack pyro = new ItemStack(Material.BOOK);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oDescrição do Kit Demoman");
      ArrayList descpyro = new ArrayList();
      descpyro.add("§5§oUse sua placa de pressão para explodir seus inimigos");
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }
    {
      ItemStack pyro = new ItemStack(Material.COMPASS);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oEstrategias do Kit Demoman");
      ArrayList descpyro = new ArrayList();
      descpyro.add("§5§oCamufle a placa de pressão em blocos de stone e gravel!");
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    {
      ItemStack pyro = new ItemStack(Material.EMERALD);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oGroups que tem este kit");
      ArrayList descpyro = new ArrayList();
      descpyro.add("§5§oStaff,Youtuber,VIP,MVP e Pro");
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    {
      ItemStack pyro = new ItemStack(Material.SIGN);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oItens do kit Demoman");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    if ((p.hasPermission("planeta.hg.kit.Demoman")) || (p.hasPermission("sping.admin"))) {
      ItemStack pyro = new ItemStack(Material.FIRE);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("Usar este kit");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    } else {
      ItemStack pyro = new ItemStack(Material.FIREBALL);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("Comprar este kit");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    {
      ItemStack pyro = new ItemStack(Material.STONE_PLATE, 3);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§cStone Pressure Plate");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    {
      ItemStack pyro = new ItemStack(Material.GRAVEL, 3);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§cGravel");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    ItemStack[] arrayOfItemStack;
    int descpyro = (arrayOfItemStack = inv.getContents()).length;
    for (int metapyro = 0; metapyro < descpyro; metapyro++) {
      ItemStack item = arrayOfItemStack[metapyro];
      if (item == null) {
        inv.setItem(inv.firstEmpty(), vidro);
      }
    }
    p.openInventory(inv);
    p.playSound(p.getLocation(), Sound.CHEST_OPEN, 40.0F, 1.0F);
  }
Example #7
0
  public static void Boxer(Player p) {
    Inventory inv = Bukkit.getServer().createInventory(p, 54, "Kit Boxer");

    ItemStack vidro = new ItemStack(Material.THIN_GLASS);
    ItemMeta metav = vidro.getItemMeta();
    metav.setDisplayName("");
    vidro.setItemMeta(metav);

    ItemStack meio = new ItemStack(353);
    ItemMeta metam = meio.getItemMeta();
    metam.setDisplayName("§a§oVoltar");
    meio.setItemMeta(metam);
    inv.setItem(0, meio);

    inv.setItem(0, vidro);
    inv.setItem(1, vidro);
    inv.setItem(2, vidro);
    inv.setItem(3, vidro);
    inv.setItem(4, meio);
    inv.setItem(5, vidro);
    inv.setItem(6, vidro);
    inv.setItem(7, vidro);
    inv.setItem(8, vidro);
    inv.setItem(9, vidro);
    inv.setItem(10, vidro);
    inv.setItem(11, vidro);
    inv.setItem(12, vidro);
    inv.setItem(13, vidro);
    inv.setItem(14, vidro);
    inv.setItem(15, vidro);
    inv.setItem(16, vidro);
    inv.setItem(17, vidro);
    inv.setItem(18, vidro);
    inv.setItem(20, vidro);
    inv.setItem(22, vidro);
    inv.setItem(24, vidro);
    inv.setItem(26, vidro);
    inv.setItem(27, vidro);
    inv.setItem(28, vidro);
    inv.setItem(29, vidro);
    inv.setItem(30, vidro);
    inv.setItem(31, vidro);
    inv.setItem(32, vidro);
    inv.setItem(33, vidro);
    inv.setItem(35, vidro);
    inv.setItem(34, vidro);
    inv.setItem(37, vidro);
    inv.setItem(38, vidro);
    inv.setItem(39, vidro);
    inv.setItem(40, vidro);
    inv.setItem(41, vidro);
    inv.setItem(42, vidro);
    inv.setItem(43, vidro);
    {
      ItemStack pyro = new ItemStack(Material.MAP);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§aKit Boxer");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }
    {
      ItemStack pyro = new ItemStack(Material.BOOK);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oDescrição do Kit Boxer");
      ArrayList descpyro = new ArrayList();
      descpyro.add("§5§oCom este kit sua mão irar dar o dano de uma espada de pedra!");
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }
    {
      ItemStack pyro = new ItemStack(Material.COMPASS);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oEstrategias do Kit Boxer");
      ArrayList descpyro = new ArrayList();
      descpyro.add(
          "§5§oKit prático, pois não precisa fazer espada! E se feita a espada irá dar mais dano!");
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    {
      ItemStack pyro = new ItemStack(Material.EMERALD);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oGroups que tem este kit");
      ArrayList descpyro = new ArrayList();
      descpyro.add("§5§oStaff,Youtuber,VIP,MVP e Pro");
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    {
      ItemStack pyro = new ItemStack(Material.SIGN);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oItens do kit Boxer");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    if ((p.hasPermission("planeta.hg.kit.Boxer")) || (p.hasPermission("sping.admin"))) {
      ItemStack pyro = new ItemStack(Material.FIRE);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("Usar este kit");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    } else {
      ItemStack pyro = new ItemStack(Material.FIREBALL);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("Comprar este kit");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    ItemStack[] arrayOfItemStack;
    int descpyro = (arrayOfItemStack = inv.getContents()).length;
    for (int metapyro = 0; metapyro < descpyro; metapyro++) {
      ItemStack item = arrayOfItemStack[metapyro];
      if (item == null) {
        inv.setItem(inv.firstEmpty(), vidro);
      }
    }
    p.openInventory(inv);
    p.playSound(p.getLocation(), Sound.CHEST_OPEN, 40.0F, 1.0F);
  }
 /**
  * Check whether or not the inventory is absolutely full.
  *
  * @param inv inventory to check.
  * @return true if every slot in the inventory has an item in it. False Otherwise.
  */
 public static boolean isFull(Inventory inv) {
   return inv.firstEmpty() == -1;
 }
Example #9
0
  public static void Flash(Player p) {
    Inventory inv = Bukkit.getServer().createInventory(p, 54, "Kit Flash");

    ItemStack vidro = new ItemStack(Material.THIN_GLASS);
    ItemMeta metav = vidro.getItemMeta();
    metav.setDisplayName("");
    vidro.setItemMeta(metav);

    ItemStack meio = new ItemStack(353);
    ItemMeta metam = meio.getItemMeta();
    metam.setDisplayName("§a§oVoltar");
    meio.setItemMeta(metam);
    inv.setItem(0, meio);

    inv.setItem(0, vidro);
    inv.setItem(1, vidro);
    inv.setItem(2, vidro);
    inv.setItem(3, vidro);
    inv.setItem(4, meio);
    inv.setItem(5, vidro);
    inv.setItem(6, vidro);
    inv.setItem(7, vidro);
    inv.setItem(8, vidro);
    inv.setItem(9, vidro);
    inv.setItem(10, vidro);
    inv.setItem(11, vidro);
    inv.setItem(12, vidro);
    inv.setItem(13, vidro);
    inv.setItem(14, vidro);
    inv.setItem(15, vidro);
    inv.setItem(16, vidro);
    inv.setItem(17, vidro);
    inv.setItem(18, vidro);
    inv.setItem(20, vidro);
    inv.setItem(22, vidro);
    inv.setItem(24, vidro);
    inv.setItem(26, vidro);
    inv.setItem(27, vidro);
    inv.setItem(28, vidro);
    inv.setItem(29, vidro);
    inv.setItem(30, vidro);
    inv.setItem(31, vidro);
    inv.setItem(32, vidro);
    inv.setItem(33, vidro);
    inv.setItem(35, vidro);
    inv.setItem(34, vidro);
    inv.setItem(37, vidro);
    inv.setItem(38, vidro);
    inv.setItem(39, vidro);
    inv.setItem(40, vidro);
    inv.setItem(41, vidro);
    inv.setItem(42, vidro);
    inv.setItem(43, vidro);
    {
      ItemStack pyro = new ItemStack(Material.MAP);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§aKit Flash");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }
    {
      ItemStack pyro = new ItemStack(Material.BOOK);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oDescrição do Kit Flash");
      ArrayList descpyro = new ArrayList();
      descpyro.add("§5§oTeleporte para o bloco");
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }
    {
      ItemStack pyro = new ItemStack(Material.COMPASS);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oEstrategias do Kit Flash");
      ArrayList descpyro = new ArrayList();
      descpyro.add("§5§oRealize fugas rapidas");
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    {
      ItemStack pyro = new ItemStack(Material.EMERALD);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oGroups que tem este kit");
      ArrayList descpyro = new ArrayList();
      descpyro.add("§5§oStaff,Youtuber,VIP,MVP e Pro");
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    {
      ItemStack pyro = new ItemStack(Material.SIGN);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§a§oItens do kit Flash");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    if ((p.hasPermission("planeta.hg.kit.Flash")) || (p.hasPermission("sping.admin"))) {
      ItemStack pyro = new ItemStack(Material.FIRE);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("Usar este kit");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    } else {
      ItemStack pyro = new ItemStack(Material.FIREBALL);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("Comprar este kit");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }
    {
      ItemStack pyro = new ItemStack(Material.REDSTONE_TORCH_ON);
      ItemMeta metapyro = pyro.getItemMeta();
      metapyro.setDisplayName("§cFlash");
      ArrayList descpyro = new ArrayList();
      metapyro.setLore(descpyro);
      pyro.setItemMeta(metapyro);
      inv.addItem(new ItemStack[] {pyro});
    }

    ItemStack[] arrayOfItemStack;
    int descpyro = (arrayOfItemStack = inv.getContents()).length;
    for (int metapyro = 0; metapyro < descpyro; metapyro++) {
      ItemStack item = arrayOfItemStack[metapyro];
      if (item == null) {
        inv.setItem(inv.firstEmpty(), vidro);
      }
    }
    p.openInventory(inv);
    p.playSound(p.getLocation(), Sound.CHEST_OPEN, 40.0F, 1.0F);
  }