How to get 1.13 new item's type

Discussion in 'Spigot Plugin Development' started by wayne870602, Aug 18, 2018.

  1. I have a problem, I can't get 1.13 versions item type ,the new item type always AIR
    somebody know why?
     
  2. Can you show some examples of what you have tried? This seems way too generic to be answered.
     
  3. Code (Text):
    @EventHandler
        public void onClose(InventoryCloseEvent e) throws IOException {
            if (Objects.equal(e.getInventory().getName(), main.getConfig().getString("BagName"))) {
                Player p = (Player) e.getPlayer();
                String PlayerName = p.getName();
                File file = new File("plugins/MoreBag/Player/" + PlayerName + ".yml");
                YamlConfiguration y = YamlConfiguration.loadConfiguration(file);
                for (int i = 0; i < e.getInventory().getSize(); i++) {
                    if (e.getInventory().getItem(i) != null) {
                        if (e.getInventory().getItem(i).equals(data.item)) {

                            y.set(i + ".Inventory.Data", null);
                            y.set(i + ".Inventory.Item", null);
                            y.set(i + ".Inventory.Amount", null);

                        } else {
                            y.set(i + ".Inventory.Data", e.getInventory().getItem(i).getType().toString());
                            y.set(i + ".Inventory.Item", e.getInventory().getItem(i).getItemMeta());
                            y.set(i + ".Inventory.Amount", e.getInventory().getItem(i).getAmount());
                        }
                    } else {
                        y.set(i + ".Inventory.Data", null);
                        y.set(i + ".Inventory.Item", null);
                        y.set(i + ".Inventory.Amount", null);
                    }
                    y.save(file);

                }

            }
            return;
        }
    this is my code , and e.getInventory().getItem(i).getType().toString() always save AIR when item is 1.13 versions new item
     
  4. Are you sure there are items in the inventory that has been closed?
     
  5. yeah, I pretty sure
    Other items can be save, just 1.13 version new item can't.
     
    #5 wayne870602, Aug 18, 2018
    Last edited: Aug 19, 2018
  6. I have this problem too :(
     
    • Agree Agree x 1