private Inventory getFuelInventory(Player player) {

    if (isValidFuelJacket(player.getInventory().getChestplate())) {

      FileConfiguration fuelConfig = getFuelConfig(player);
      Material jacket = player.getInventory().getChestplate().getType();

      int jacketSize = getFuelJacketSize(jacket);
      String jacketType = getFuelJacketConfigString(jacket);

      if (fuelConfig.get(jacketType) != null) {

        Inventory fuelInventory;
        ArrayList<ItemStack> itemStack = new ArrayList<>();

        itemStack.addAll(
            fuelConfig
                .getList(jacketType)
                .stream()
                .map(fuelCurrentItem -> (ItemStack) fuelCurrentItem)
                .collect(Collectors.toList()));

        fuelInventory =
            Bukkit.createInventory(
                player,
                jacketSize,
                "" + ChatColor.DARK_RED + ChatColor.BOLD + "Rocket Boot Fuel Jacket");
        fuelInventory.setContents(itemStack.toArray(new ItemStack[itemStack.size()]));

        return fuelInventory;
      }
    }

    return null;
  }
 @Override
 public void run() {
   TARDISRegulatorInventory reg = new TARDISRegulatorInventory();
   ItemStack[] items = reg.getRegulator();
   Inventory inv = plugin.getServer().createInventory(player, 54, "Helmic Regulator");
   inv.setContents(items);
   player.openInventory(inv);
   // play inflight sound
   TARDISSounds.playTARDISSound(player.getLocation(), player, "interior_flight");
 }
 @EventHandler
 public void onEnderChestOpen(InventoryOpenEvent e) {
   if (!(e.getPlayer() instanceof Player)) return;
   Player p = (Player) e.getPlayer();
   Inventory i = e.getInventory();
   if (i.getType() != InventoryType.ENDER_CHEST) return;
   Inventory ender = getEnderInventory(p);
   if (ender == null || ender.getContents().length < 1) return;
   i.setContents(ender.getContents());
 }
Beispiel #4
0
 public static void _registerNPC(dNPC denizenNPC) {
   if (denizenNPC == null || !denizenNPC.isValid()) {
     return;
   }
   int id = denizenNPC.getId();
   if (!denizenNPCs.containsKey(id)) {
     denizenNPCs.put(id, denizenNPC);
     Inventory npcInventory = Bukkit.getServer().createInventory(denizenNPC, InventoryType.PLAYER);
     npcInventory.setContents(
         Arrays.copyOf(denizenNPC.getInventoryTrait().getContents(), npcInventory.getSize()));
     npcInventories.put(id, npcInventory);
   }
 }
  public static void setAllContents(Inventory from, Inventory to) {
    to.setContents(from.getContents());
    if (from instanceof PlayerInventory) {
      PlayerInventory pfrom = (PlayerInventory) from;
      if (to instanceof PlayerInventory) {
        PlayerInventory pto = (PlayerInventory) to;

        pto.setHelmet(pfrom.getHelmet());
        pto.setChestplate(pfrom.getChestplate());
        pto.setLeggings(pfrom.getLeggings());
        pto.setBoots(pfrom.getBoots());
      }
    }
  }
Beispiel #6
0
 public void setBankSize(Player player, int size) {
   bank = banks.get(player.getName());
   Inventory inv = bank.getInv();
   ItemStack gt = inv.getItem(inv.getSize() - 2);
   ItemStack st = inv.getItem(inv.getSize() - 1);
   inv.remove(gt);
   inv.remove(st);
   bank.setBankSize(size);
   Inventory in = Bukkit.createInventory(player, size, player.getName() + " - Bank Chest");
   in.setContents(inv.getContents());
   bank.setInv(in);
   in.setItem(in.getSize() - 1, st);
   in.setItem(in.getSize() - 2, gt);
   sql.updateInv(player.getName(), size, in);
 }
 // load inventory from db
 protected void loadInventory() {
   Connection conn = WebAuctionPlus.dataQueries.getConnection();
   PreparedStatement st = null;
   ResultSet rs = null;
   //		slotChanged.clear();
   chest.clear();
   tableRowIds.clear();
   try {
     if (WebAuctionPlus.isDebug()) WebAuctionPlus.log.info("WA Query: isLocked");
     st =
         conn.prepareStatement(
             "SELECT `id`, `itemId`, `itemDamage`, `qty`, `enchantments` "
                 + "FROM `"
                 + WebAuctionPlus.dataQueries.dbPrefix()
                 + "Items` WHERE `playerName` = ? ORDER BY `id` ASC LIMIT ?");
     st.setString(1, playerName);
     st.setInt(2, chest.getSize());
     rs = st.executeQuery();
     ItemStack[] stacks = new ItemStack[chest.getSize()];
     int i = -1;
     while (rs.next()) {
       if (rs.getInt("qty") < 1) continue;
       i++;
       if (i >= chest.getSize()) break;
       tableRowIds.put(i, rs.getInt("id"));
       // create/split item stack
       stacks[i] =
           getSplitItemStack(
               rs.getInt("id"),
               rs.getInt("itemId"),
               rs.getShort("itemDamage"),
               rs.getInt("qty"),
               rs.getString("enchantments"));
     }
     chest.setContents(stacks);
   } catch (SQLException e) {
     WebAuctionPlus.log.warning(WebAuctionPlus.logPrefix + "Unable to set inventory lock");
     e.printStackTrace();
   } finally {
     WebAuctionPlus.dataQueries.closeResources(conn, st);
   }
 }
  public static void setContentsAll(Inventory inventory, ItemStack[] all) {
    if (inventory == null) return;
    ItemStack[] contents = inventory.getContents();

    PlayerInventory playerInventory = asPlayerInventory(inventory);
    if (playerInventory == null) {
      inventory.setContents(range(all, 0, contents.length));
      return;
    }

    if (all.length < INDEX_PLAYER_STORAGE_TO) return;
    ItemStack[] storage = range(all, INDEX_PLAYER_STORAGE_FROM, INDEX_PLAYER_STORAGE_TO);
    setContentsStorage(playerInventory, storage);

    if (all.length < INDEX_PLAYER_ARMOR_TO) return;
    ItemStack[] armor = range(all, INDEX_PLAYER_ARMOR_FROM, INDEX_PLAYER_ARMOR_TO);
    setContentsArmor(playerInventory, armor);

    if (all.length < INDEX_PLAYER_EXTRA_TO) return;
    ItemStack[] extra = range(all, INDEX_PLAYER_EXTRA_FROM, INDEX_PLAYER_EXTRA_TO);
    setContentsExtra(playerInventory, extra);
  }
  @EventHandler
  public void onClickInventory(InventoryClickEvent ev) {
    if (ev.getInventory().getType() == InventoryType.HOPPER
        && ev.getInventory().getTitle().equalsIgnoreCase("Network Creator")) {
      if (ev.getCurrentItem() == null) {
        return;
      }
      if (ev.isShiftClick()) {
        ev.setCancelled(true);
        return;
      }
      if ((ev.getSlot() == 0 || ev.getSlot() == 1)
          && !CardNetworkListener.isModifier(ev.getCursor())
          && ev.getCursor().getType() != Material.AIR) {
        ev.setCancelled(true);
        return;
      }
      if (ev.getSlot() == 3
          && !pl.isCardNetwork(ev.getCursor())
          && ev.getCursor().getType() != Material.AIR) {
        ev.setCancelled(true);
        return;
      }

      Player p = (Player) ev.getWhoClicked();
      Inventory inv = ev.getInventory();

      if (ev.getCurrentItem().getType() == Material.ENDER_PORTAL_FRAME
          && ev.getCurrentItem().hasItemMeta()
          && ev.getCurrentItem().getItemMeta().hasDisplayName()
          && ev.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§rDéassablage")) {
        ev.setCancelled(true);

        List<String> lore = ev.getCurrentItem().getItemMeta().getLore();
        String[] cs = lore.get(0).split("/");

        Block b =
            new Location(
                    ev.getWhoClicked().getWorld(),
                    Integer.parseInt(cs[0]),
                    Integer.parseInt(cs[1]),
                    Integer.parseInt(cs[2]))
                .getBlock();

        b.setType(Material.AIR);
        pl.bs.remove(b);
        b.getWorld().dropItemNaturally(b.getLocation(), pl.nc);

        p.closeInventory();

        return;
      }

      if (ev.getSlot() == 2
          && ev.getCurrentItem().getType() == Material.STAINED_GLASS_PANE
          && ev.getCurrentItem().getDurability() == 15
          && ev.getCurrentItem().hasItemMeta()
          && ev.getCurrentItem().getItemMeta().hasDisplayName()
          && ev.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§r--->")) {
        ev.setCancelled(true);

        if (inv.getItem(0) == null && inv.getItem(1) == null && inv.getItem(3) == null) return;
        if (CardNetworkListener.whatNetwork(inv.getItem(3)) != null) return;

        ItemStack item;
        ItemStack m1 = inv.getItem(0);
        ItemStack m2 = inv.getItem(1);

        if (m1 != null || m2 != null) {
          item = inv.getItem(3);
          ItemMeta im = item.getItemMeta();
          List<String> lore = im.getLore();

          lore.add(" ");
          lore.add(ChatColor.GRAY + "Modifier :");

          if (m1 != null) {
            lore.add(ChatColor.GRAY + "- " + CardNetworkListener.whatModifier(m1));
            inv.setItem(0, new ItemStack(Material.AIR));
          }
          if (m2 != null && !m2.isSimilar(m1)) {
            lore.add(ChatColor.GRAY + "- " + CardNetworkListener.whatModifier(m2));
            inv.setItem(1, new ItemStack(Material.AIR));
          }

          im.setLore(lore);
          item.setItemMeta(im);

          inv.setItem(3, item);
        }

        p.playSound(p.getLocation(), Sound.WOOD_CLICK, 1, 1);

        Inventory icn = pl.getServer().createInventory(null, InventoryType.HOPPER, "NC");
        icn.setContents(inv.getContents());
        inv.clear();

        new ChatInventory(pl, p, null, ChatEtat.CREATE_NETWORK, icn);
        p.closeInventory();

        p.sendMessage(ChatColor.GRAY + "Entré le nom du réseau");

        return;
      }
    }
  }
    @Override
    protected void onPurchaseClick(
        InventoryClickEvent event,
        Player player,
        ItemStack[] usedRecipe,
        ItemStack offered1,
        ItemStack offered2) {
      super.onPurchaseClick(event, player, usedRecipe, offered1, offered2);
      if (event.isCancelled()) return;

      ItemStack book = usedRecipe[2];
      String title = getTitleOfBook(book);
      if (title == null) {
        // this should not happen.. because the recipes were created based on the shopkeeper's
        // offers
        event.setCancelled(true);
        return;
      }

      // get chest:
      Block chest = ((WrittenBookPlayerShopkeeper) shopkeeper).getChest();
      if (!Utils.isChest(chest.getType())) {
        event.setCancelled(true);
        return;
      }

      // remove blank book from chest:
      boolean removed = false;
      Inventory inv = ((Chest) chest.getState()).getInventory();
      ItemStack[] contents = inv.getContents();
      for (int i = 0; i < contents.length; i++) {
        if (contents[i] != null && contents[i].getType() == Material.BOOK_AND_QUILL) {
          if (contents[i].getAmount() == 1) {
            contents[i] = null;
          } else {
            contents[i].setAmount(contents[i].getAmount() - 1);
          }
          removed = true;
          break;
        }
      }
      if (!removed) {
        event.setCancelled(true);
        return;
      }

      // get price:
      Integer priceInt = ((WrittenBookPlayerShopkeeper) shopkeeper).offers.get(title);
      if (priceInt == null) {
        event.setCancelled(true);
        return;
      }
      int price = this.getAmountAfterTaxes(priceInt.intValue());

      // add earnings to chest:
      if (price > 0) {
        int highCost = price / Settings.highCurrencyValue;
        int lowCost = price % Settings.highCurrencyValue;
        if (highCost > 0) {
          if (Utils.addItems(contents, createHighCurrencyItem(highCost)) != 0) {
            event.setCancelled(true);
            return;
          }
        }
        if (lowCost > 0) {
          if (Utils.addItems(contents, createCurrencyItem(lowCost)) != 0) {
            event.setCancelled(true);
            return;
          }
        }
      }

      // set chest contents:
      inv.setContents(contents);
    }
 /**
  * Set the contents of the given inventory.
  *
  * @param inventory inventory to set the contents for
  * @param items contents to set for the inventory.
  */
 public static void setContents(Inventory inventory, ItemStack[] items) {
   inventory.setContents(items);
 }
Beispiel #12
0
  public static void shopGUI(
      Plugin plugin,
      Player player,
      Material shopType,
      short durability,
      int moneyPrice,
      int itemPrice,
      int sellNumber,
      int buyNumber,
      boolean itemSize,
      boolean moneySize) {
    itemPrice = itemPrice % 10000;
    moneyPrice = moneyPrice % 10000;
    if (itemPrice == 0) {
      itemPrice = 1;
    }
    if (moneyPrice == 0) {
      moneyPrice = 1;
    }

    sellNumber = sellNumber % 1000;
    buyNumber = buyNumber % 1000;
    if (sellNumber == 0) {
      sellNumber = 1;
    }
    if (buyNumber == 0) {
      buyNumber = 1;
    }
    Inventory menu = Bukkit.createInventory(null, 54, plugin.getConfig().getString("shop.name"));
    ItemStack[] itemStacks = menu.getContents();

    for (int i = 0; i < 4; i++) {
      itemStacks[12 - i] = ItemUtil.getNumberStack(itemPrice / (int) Math.pow(10, (double) i) % 10);
      itemStacks[17 - i] =
          ItemUtil.getNumberStack(moneyPrice / (int) Math.pow(10, (double) i) % 10);
      if (i != 3) {
        itemStacks[38 - i] =
            ItemUtil.getNumberStack(sellNumber / (int) Math.pow(10, (double) i) % 10);
        itemStacks[44 - i] =
            ItemUtil.getNumberStack(buyNumber / (int) Math.pow(10, (double) i) % 10);
      }
    }

    int[] upArrow = {0, 1, 2, 3, 5, 6, 7, 8, 27, 28, 29, 33, 34, 35};
    for (int i : upArrow) {
      itemStacks[i] = ItemUtil.getUpArrow();
    }

    int[] downArrow = {18, 19, 20, 21, 23, 24, 25, 26, 45, 46, 47, 51, 52, 53};
    for (int i : downArrow) {
      itemStacks[i] = ItemUtil.getDownArrow();
    }

    if (itemSize) {
      itemStacks[39] = new ItemStack(shopType, shopType.getMaxStackSize(), durability);
    } else {
      itemStacks[39] = new ItemStack(shopType, 1, durability);
    }

    if (moneySize) {
      itemStacks[41] =
          new ItemStack(ItemUtil.getCurrency(), ItemUtil.getCurrency().getMaxStackSize());
    } else {
      itemStacks[41] = new ItemStack(ItemUtil.getCurrency(), 1);
    }

    itemStacks[13] =
        ItemUtil.button(
            shopType,
            String.format(
                plugin.getConfig().getString("message.priceButton"),
                itemPrice,
                shopType.name(),
                moneyPrice));
    ItemMeta itemMeta13 = itemStacks[13].getItemMeta();
    List<String> list13 = new ArrayList<String>();
    list13.add(getLowest(plugin, shopType, durability));
    list13.add(getHighest(plugin, shopType, durability));
    itemMeta13.setLore(list13);
    itemStacks[13].setItemMeta(itemMeta13);
    itemStacks[13].setDurability(durability);

    itemStacks[40] =
        ItemUtil.getDetail(
            shopType.name(),
            durability,
            moneyPrice,
            itemPrice,
            sellNumber,
            buyNumber,
            itemSize,
            moneySize);

    if (itemSize) {
      sellNumber = sellNumber * shopType.getMaxStackSize();
    }
    if (moneySize) {
      buyNumber = buyNumber * ItemUtil.getCurrency().getMaxStackSize();
    }

    // 买卖键
    itemStacks[48] =
        ItemUtil.button(
            shopType,
            durability,
            String.format(
                plugin.getConfig().getString("message.sellButton"),
                sellNumber,
                shopType.name(),
                sellNumber * moneyPrice / itemPrice));
    itemStacks[50] =
        ItemUtil.button(
            ItemUtil.getCurrency(),
            String.format(
                plugin.getConfig().getString("message.buyButton"),
                shopType.name(),
                buyNumber,
                itemPrice,
                moneyPrice));

    // 库存显示
    itemStacks[30] =
        ItemUtil.button(
            Material.CHEST,
            String.format(
                plugin.getConfig().getString("message.itemOwned"),
                ItemUtil.getItemNumber(player, shopType, durability),
                shopType.name()));
    itemStacks[32] =
        ItemUtil.button(
            Material.TRAPPED_CHEST,
            String.format(
                plugin.getConfig().getString("message.moneyOwned"),
                ItemUtil.getItemNumber(player, ItemUtil.getCurrency())));

    //        // 最低卖价
    //        itemStacks[4] = getLowest(plugin, shopType);
    //
    //        // 最高售价
    //        itemStacks[22] = getHighest(plugin, shopType);

    menu.setContents(itemStacks);
    player.openInventory(menu);
  }
    @Override
    protected void onPurchaseClick(InventoryClickEvent event, Player player) {
      super.onPurchaseClick(event, player);
      if (event.isCancelled()) return;

      // get type and cost
      ItemStack item = event.getCurrentItem();
      ItemStack type = item.clone();
      type.setAmount(1);

      Cost cost = ((TradingPlayerShopkeeper) shopkeeper).costs.get(type);
      if (cost == null) {
        event.setCancelled(true);
        return;
      }

      if (cost.amount != item.getAmount()) {
        event.setCancelled(true);
        return;
      }

      // get chest
      Block chest = ((TradingPlayerShopkeeper) shopkeeper).getChest();
      if (!Utils.isChest(chest.getType())) {
        event.setCancelled(true);
        return;
      }

      // remove item from chest
      Inventory inventory = ((Chest) chest.getState()).getInventory();
      ItemStack[] contents = inventory.getContents();
      boolean removed = this.removeFromInventory(item, contents);
      if (!removed) {
        event.setCancelled(true);
        return;
      }

      // add traded items to chest
      if (cost.item1 == null) {
        event.setCancelled(true);
        return;
      } else {
        ItemStack c = cost.item1.clone();
        c.setAmount(this.getAmountAfterTaxes(c.getAmount()));
        if (c.getAmount() > 0) {
          boolean added = this.addToInventory(c, contents);
          if (!added) {
            event.setCancelled(true);
            return;
          }
        }
      }
      if (cost.item2 != null) {
        ItemStack c = cost.item2.clone();
        c.setAmount(this.getAmountAfterTaxes(c.getAmount()));
        if (c.getAmount() > 0) {
          boolean added = this.addToInventory(c, contents);
          if (!added) {
            event.setCancelled(true);
            return;
          }
        }
      }

      // save chest contents
      inventory.setContents(contents);
    }
  @EventHandler
  public void onClose(InventoryCloseEvent e) {
    if (e.getInventory().getName().equals("Donate To New Players Here!")) {
      if (DragonTest.testEgg(e.getInventory().getItem(0)) && (e.getPlayer() instanceof Player)) {

        ItemStack[] donation = e.getInventory().getContents();
        List<String> chestData = donation[0].getItemMeta().getLore();
        Chest chest =
            (Chest)
                new Location(
                        Bukkit.getWorld(chestData.get(0)),
                        Double.parseDouble(chestData.get(1)),
                        Double.parseDouble(chestData.get(2)),
                        Double.parseDouble(chestData.get(3)))
                    .getBlock()
                    .getState();

        ArrayList<ItemStack> toAdd = new ArrayList<ItemStack>();
        donation[0] = new ItemStack(Material.AIR); // ignore dragon egg
        for (ItemStack is : donation) {
          if (is == null) {
            continue;
          }
          if (is.getType() == Material.AIR || is.getAmount() == 0) {
            continue;
          }
          toAdd.add(is.clone());
        }
        Inventory chestInv = chest.getInventory();
        ItemStack[] chestContents = chestInv.getContents();
        int amountAdded = 0;
        for (int i = 0; i < chestContents.length && amountAdded < toAdd.size(); i++) {
          if (chestContents[i] == null) {
            chestContents[i] = toAdd.get(amountAdded);
            amountAdded++;
            continue;
          }
          if (chestContents[i].getType() == Material.AIR || chestContents[i].getAmount() == 0) {
            chestContents[i] = toAdd.get(amountAdded);
            amountAdded++;
            continue;
          }
        }
        chestInv.setContents(chestContents);

        Player p = (Player) e.getPlayer();

        if (amountAdded > 0) {
          p.sendMessage(
              CrystalChest.pluginStr
                  + ChatColor.LIGHT_PURPLE
                  + "Donation added- thank you for helping out the new players!");
        }
        if (amountAdded < toAdd.size()) {
          while (amountAdded < toAdd.size()) {
            p.getInventory().addItem(toAdd.get(amountAdded));
            amountAdded++;
          }
          p.sendMessage(
              CrystalChest.pluginStr
                  + ChatColor.YELLOW
                  + "The chest filled up - excess items have been "
                  + "returned to your inventory.");
        }
      }
    }
  }
  @Override
  public boolean execute(CommandSender sender, String[] args, Location location) {
    ArrayList<Inventory> inventoryList = new ArrayList<Inventory>();
    if ((args[0].startsWith("@l[") && args[0].endsWith("]"))
        || inventorySubs.containsKey(args[0])) {
      Location invLocation = LogiBlocksMain.parseLocation(args[0], location);
      for (int x = -1; x <= 1; x++) {
        for (int y = -1; y <= 1; y++) {
          for (int z = -1; z <= 1; z++) {
            Block testBlock = invLocation.clone().add(x, y, z).getBlock();
            if (testBlock.getState() instanceof InventoryHolder) {
              inventoryList.add(((InventoryHolder) testBlock.getState()).getInventory());
            }
          }
        }
      }
    } else {
      Player player = Bukkit.getPlayer(args[0]);
      if (player == null) {
        return false;
      }
      inventoryList.add(player.getInventory());
    }
    int subIndex = inventorySubs.containsKey(args[0]) ? 0 : 1;
    if (!inventorySubs.containsKey(args[subIndex])) {
      return false;
    }
    if (inventorySubs.get(args[subIndex]) + subIndex + 1 > args.length) {
      return false;
    }
    for (Inventory inventory : inventoryList) {
      switch (args[subIndex]) {
        case "add":
          for (int i = subIndex + 1; i < args.length; i++) {
            ItemStack item1 = LogiBlocksMain.parseItemStack(args[i]);
            if (item1 == null) {
              continue;
            }
            inventory.addItem(item1);
          }
          break;
        case "remove":
          for (int i = subIndex + 1; i < args.length; i++) {
            ItemStack removeItem = LogiBlocksMain.parseItemStack(args[i]);
            if (removeItem == null) {
              continue;
            }
            for (ItemStack targetItem : inventory.getContents()) {
              if (targetItem == null) {
                continue;
              }
              if (targetItem.isSimilar(removeItem)) {
                if (removeItem.getAmount() > targetItem.getAmount()) {
                  removeItem.setAmount(removeItem.getAmount() - targetItem.getAmount());
                  inventory.remove(removeItem);
                } else {
                  targetItem.setAmount(targetItem.getAmount() - removeItem.getAmount());
                  break;
                }
              }
            }
          }
          break;
        case "removeall":
          for (int i = subIndex + 1; i < args.length; i++) {
            ItemStack removeItem = LogiBlocksMain.parseItemStack(args[i]);
            for (int j = 1; j <= 64; j++) {
              removeItem.setAmount(j);
              inventory.remove(removeItem);
            }
          }
          break;
        case "clear":
          inventory.clear();
          break;
        case "refill":
          for (ItemStack itemStack : inventory.getContents()) {
            if (itemStack == null) {
              continue;
            }
            itemStack.setAmount(
                (args.length > subIndex + 1
                    ? Boolean.parseBoolean(args[subIndex + 1]) ? 64 : itemStack.getMaxStackSize()
                    : itemStack.getMaxStackSize()));
          }
          break;
        case "set":
          int slot = Integer.parseInt(args[subIndex + 1]);
          inventory.setItem(
              slot >= inventory.getSize() ? inventory.getSize() - 1 : slot,
              LogiBlocksMain.parseItemStack(args[subIndex + 2]));
          break;
        case "copy":
          Inventory targetInventory;
          if (args[subIndex + 1].startsWith("@l[") && args[subIndex + 1].endsWith("]")) {
            Block targetBlock =
                LogiBlocksMain.parseLocation(args[subIndex + 1], location).getBlock();
            if (targetBlock.getState() instanceof InventoryHolder) {
              targetInventory = ((InventoryHolder) targetBlock.getState()).getInventory();
            } else {
              return false;
            }
          } else {
            Player player = Bukkit.getPlayer(args[subIndex + 1]);
            if (player == null) {
              return false;
            }
            targetInventory = player.getInventory();
          }
          for (int i = 0; i < inventory.getSize() && i < targetInventory.getSize(); i++) {
            targetInventory.setItem(i, inventory.getItem(i));
          }
          break;
        case "show":
          Player player = Bukkit.getPlayer(args[subIndex + 1]);
          if (player == null) {
            return false;
          }
          if (args.length > subIndex + 2) {
            if (Boolean.parseBoolean(args[subIndex + 2])) {
              Inventory fakeInventory =
                  Bukkit.createInventory(inventory.getHolder(), inventory.getType());
              fakeInventory.setContents(inventory.getContents());
              player.openInventory(fakeInventory);
              return true;
            }
          } else {
            player.openInventory(inventory);
          }
          break;
      }
    }

    return true;
  }
 private PlayerShopInventoryMenu(PlayerShopSession session, PlayerShop shop) {
   super(session);
   this.shop = shop;
   this.inventory = getInventory();
   inventory.setContents(getIcons());
 }