Solved Switching betwen inventories

Discussion in 'Plugin Development' started by krypek, Nov 3, 2019.

  1. Offline

    krypek

    Problem: I don't now how to switch between inventories.
    I was searching for an anwser but I didn't find it. So i go to the forums.
    I was trying to close an inventory then open other, but there was an error on console.
    I find tutorial that you need to wait 1 or more ticks to open another inventory, else it won't work. I do it, it still doesn't work. Thanks for any help.
     
  2. Offline

    KarimAKL

    @krypek Could you post the error and your code? Waiting 1 or more ticks is usually if it doesn't open, not because of errors.
     
  3. Offline

    krypek

    Closing inventory before opening anather one don't make any diffrents.

    Error without waiting 1 tick:
    Code:
    org.bukkit.event.EventException: null
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:529) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:514) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.PlayerConnection.a(PlayerConnection.java:2133) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.PacketPlayInWindowClick.a(SourceFile:33) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.PacketPlayInWindowClick.a(SourceFile:10) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.TickTask.run(SourceFile:18) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeTask(SourceFile:144) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.executeNext(SourceFile:118) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.MinecraftServer.aX(MinecraftServer.java:909) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.MinecraftServer.executeNext(MinecraftServer.java:902) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.IAsyncTaskHandler.awaitTasks(SourceFile:127) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.MinecraftServer.sleepForTick(MinecraftServer.java:886) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:819) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_211]
    Caused by: java.lang.NullPointerException
            at org.bukkit.craftbukkit.v1_14_R1.entity.CraftHumanEntity.openInventory(CraftHumanEntity.java:321) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at me.krypek.StoneCraft.commands.drop.onClick(drop.java:317) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_211]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_211]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_211]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_211]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            ... 17 more




    With waiting 1 tick and more:
    Code:
    java.lang.NullPointerException: null
            at org.bukkit.craftbukkit.v1_14_R1.entity.CraftHumanEntity.openInventory(CraftHumanEntity.java:321) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at me.krypek.StoneCraft.commands.drop$1.run(drop.java:320) ~[?:?]
            at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftTask.run(CraftTask.java:81) ~[spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at org.bukkit.craftbukkit.v1_14_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:394) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1022) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:393) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:970) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:815) [spigot-1.14.4.jar:git-Spigot-56f8471-7554e08]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_211]
     
    Last edited by a moderator: Nov 4, 2019
  4. Online

    timtower Moderator Moderator

    @krypek Please post your code.
     
  5. Offline

    krypek

    Everything in Main class, plugin.yml and config.yml is correct and working.
    I am also wondering how to change e.g. item in 17 slot or somefing like that in open inventory.
    Like if I click e.g. grass block, it changes to stone block.
    In code, go ahead and skip all start code, its just setting up items in inventory and setting up two inventories.
    Go to OnClick() Event and find "See a mineral multiplier with a fortune", here if you click it I want to open inv_fortune inventory.
    Code:
    Code:
    package me.krypek.StoneCraft.commands;
    
    import java.util.ArrayList;
    import java.util.List;
    import java.util.UUID;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    
    import me.krypek.StoneCraft.Main.Main;
    
    
    public class test implements CommandExecutor, Listener {
      
      
        static Main plugin;
        public test(Main main) {
            plugin = main;
        }
      
        static Boolean check=true;
      
      
      
      
      
        float diamond_chance;
        float coal_chance;
        float iron_ore_chance;
        float gold_ore_chance;
        float lapis_chance;
        float emerald_chance;
        float clay_chance;
        float redstone_chance;
      
        public void set_chance() {
          
            diamond_chance = plugin.getConfig().getInt("chance.diamond_chance");
            coal_chance = plugin.getConfig().getInt("chance.coal_chance");
            iron_ore_chance =plugin.getConfig().getInt("chance.iron_ore_chance");
            gold_ore_chance =plugin.getConfig().getInt("chance.gold_ore_chance");
            lapis_chance =plugin.getConfig().getInt("chance.lapis_chance");
            emerald_chance = plugin.getConfig().getInt("chance.emerald_chance");
            clay_chance =plugin.getConfig().getInt("chance.clay_chance");
            redstone_chance = plugin.getConfig().getInt("chance.redstone_chance");
        }
      
      
      
      
        Inventory inv_main;
      
        ItemStack disable_drops_all;
        ItemStack enable_drops_all;
          
      
      
        public void set_GUI_main() {
            inv_main = Bukkit.createInventory(null, 45, ChatColor.GREEN + "Drop");
          
            ItemStack glass = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
            ItemMeta glass_meta = glass.getItemMeta();
            glass_meta.setDisplayName(" ");
            glass.setItemMeta(glass_meta);
          
            for(int i=0; i<9; i++) {
                inv_main.setItem(i, glass);
            }
            for(int i=36; i<45; i++) {
                inv_main.setItem(i, glass);
            }
          
            ItemStack coal = new ItemStack(Material.COAL);
            ItemMeta coal_meta = coal.getItemMeta();
            coal_meta.setDisplayName(ChatColor.DARK_GRAY +"Coal");
            List<String> coal_lore = new ArrayList<String>();
            coal_lore.add(ChatColor.translateAlternateColorCodes('&', "&2Can be mined by: &be&ev&7e&br&ey &2pickaxe"));
            coal_lore.add(ChatColor.DARK_AQUA+"Chance: "+ coal_chance/10000 + "%");
            coal_meta.setLore(coal_lore);
            coal.setItemMeta(coal_meta);
          
            ItemStack iron_ore = new ItemStack(Material.IRON_ORE);
            ItemMeta iron_ore_meta = iron_ore.getItemMeta();
            iron_ore_meta.setDisplayName(ChatColor.GRAY +"Iron ore");
            List<String> iron_ore_lore = new ArrayList<String>();
            iron_ore_lore.add(ChatColor.translateAlternateColorCodes('&', "&2Can be mined by: &7stone&2, &egold&2, &7iron &2and &bdiamond &2pickaxe"));
            iron_ore_lore.add(ChatColor.DARK_AQUA+"Chance: "+ iron_ore_chance/10000 + "%");
            iron_ore_meta.setLore(iron_ore_lore);
            iron_ore.setItemMeta(iron_ore_meta);
          
            ItemStack lapis = new ItemStack(Material.LAPIS_LAZULI);
            ItemMeta lapis_meta = lapis.getItemMeta();
            lapis_meta.setDisplayName(ChatColor.BLUE +"Lapis Lazuli");
            List<String> lapis_lore = new ArrayList<String>();
            lapis_lore.add(ChatColor.translateAlternateColorCodes('&', "&2Can be mined by: &7stone&2, &egold&2, &7iron &2and &bdiamond &2pickaxe"));
            lapis_lore.add(ChatColor.DARK_AQUA+"Chance: "+ lapis_chance/10000 + "%");
            lapis_meta.setLore(lapis_lore);
            lapis.setItemMeta(lapis_meta);
          
            ItemStack emerald = new ItemStack(Material.EMERALD);
            ItemMeta emerald_meta = emerald.getItemMeta();
            emerald_meta.setDisplayName(ChatColor.GREEN +"Emerald");
            List<String> emerald_lore = new ArrayList<String>();
            emerald_lore.add(ChatColor.translateAlternateColorCodes('&', "&2Can be mined by: &7iron &2and &bdiamond &2pickaxe"));
            emerald_lore.add(ChatColor.DARK_AQUA+"Chance: "+ emerald_chance/10000 + "%");
            emerald_meta.setLore(emerald_lore);
            emerald.setItemMeta(emerald_meta);
          
            ItemStack gold_ore = new ItemStack(Material.GOLD_ORE);
            ItemMeta gold_ore_meta = gold_ore.getItemMeta();
            gold_ore_meta.setDisplayName(ChatColor.GOLD +"Gold ore");
            List<String> gold_ore_lore = new ArrayList<String>();
            gold_ore_lore.add(ChatColor.translateAlternateColorCodes('&', "&2Can be mined by: &7iron &2and &bdiamond &2pickaxe"));
            gold_ore_lore.add(ChatColor.DARK_AQUA+"Chance: "+ gold_ore_chance/10000 + "%");
            gold_ore_meta.setLore(gold_ore_lore);
            gold_ore.setItemMeta(gold_ore_meta);
          
            ItemStack diamond = new ItemStack(Material.DIAMOND);
            ItemMeta diamond_meta = diamond.getItemMeta();
            diamond_meta.setDisplayName(ChatColor.AQUA+"Diamond");
            List<String> diamond_lore = new ArrayList<String>();
            diamond_lore.add(ChatColor.translateAlternateColorCodes('&', "&2Can be mined by: &7iron &2and &bdiamond &2pickaxe"));
            diamond_lore.add(ChatColor.DARK_AQUA+"Chance: "+ diamond_chance/10000 + "%");
            diamond_meta.setLore(diamond_lore);
            diamond.setItemMeta(diamond_meta);
          
            ItemStack clay = new ItemStack(Material.CLAY_BALL);
            ItemMeta clay_meta = clay.getItemMeta();
            clay_meta.setDisplayName(ChatColor.WHITE+"Clay");
            List<String> clay_lore = new ArrayList<String>();
            clay_lore.add(ChatColor.translateAlternateColorCodes('&', "&2Can be mined by: &bdiamond &2pickaxe"));
            clay_lore.add(ChatColor.DARK_AQUA+"Chance: "+ clay_chance/10000 + "%");
            clay_meta.setLore(clay_lore);
            clay.setItemMeta(clay_meta);
          
            ItemStack redstone = new ItemStack(Material.REDSTONE);
            ItemMeta redstone_meta = redstone.getItemMeta();
            redstone_meta.setDisplayName(ChatColor.RED+"Redstone");
            List<String> redstone_lore = new ArrayList<String>();
            redstone_lore.add(ChatColor.translateAlternateColorCodes('&', "&2Can be mined by: &7iron &2and &bdiamond &2pickaxe"));
            redstone_lore.add(ChatColor.DARK_AQUA+"Chance: "+ redstone_chance/10000 + "%");
            redstone_meta.setLore(redstone_lore);
            redstone.setItemMeta(redstone_meta);
          
            disable_drops_all = new ItemStack(Material.BLUE_STAINED_GLASS_PANE);
            ItemMeta diasble_drops_all_meta = disable_drops_all.getItemMeta();
            diasble_drops_all_meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&l&eClick, to &cdisable &eall drops."));
            disable_drops_all.setItemMeta(diasble_drops_all_meta);
          
            enable_drops_all = new ItemStack(Material.BLUE_STAINED_GLASS_PANE);
            ItemMeta enable_drops_all_meta = enable_drops_all.getItemMeta();
            enable_drops_all_meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&l&eClick, to &aenable &eall drops."));
            enable_drops_all.setItemMeta(enable_drops_all_meta);
          
          
            ItemStack fortune_multiplayer = new ItemStack(Material.BLUE_STAINED_GLASS_PANE);
            ItemMeta fortune_multiplayer_meta = fortune_multiplayer.getItemMeta();
            fortune_multiplayer_meta.setDisplayName(ChatColor.GOLD+""+ChatColor.BOLD+"See a mineral multiplier with a fortune");
            fortune_multiplayer_meta.addEnchant(Enchantment.LOOT_BONUS_BLOCKS, 10, true);
            fortune_multiplayer.setItemMeta(fortune_multiplayer_meta);
          
          
          
          
          
          
          
            inv_main.setItem(18, coal);
            inv_main.setItem(19, iron_ore);
            inv_main.setItem(20, gold_ore);
            inv_main.setItem(21, lapis);
            inv_main.setItem(22, emerald);
            inv_main.setItem(23, redstone);
            inv_main.setItem(24, diamond);
            inv_main.setItem(25, clay);
            inv_main.setItem(17, disable_drops_all);
          
            inv_main.setItem(0, fortune_multiplayer);
          
          
        }
      
      
      
      
      
      
      
        Inventory inv_fortune;
      
        public void set_GUI_fortune() {
            inv_fortune = Bukkit.createInventory(null, 45, ChatColor.GREEN + "Fortune multiplayers");
          
            ItemStack glass = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
            ItemMeta glass_meta = glass.getItemMeta();
            glass_meta.setDisplayName(" ");
            glass.setItemMeta(glass_meta);
          
            for(int i=0; i<9; i++) {
                inv_fortune.setItem(i, glass);
            }
            for(int i=36; i<45; i++) {
                inv_fortune.setItem(i, glass);
            }
          
          
            ItemStack book1 = new ItemStack(Material.ENCHANTED_BOOK);
            ItemMeta book1_meta = book1.getItemMeta();
            book1_meta.setDisplayName(ChatColor.GOLD +"Fortune I");
            List<String> book1_lore = new ArrayList<String>();
            book1_lore.add(ChatColor.AQUA+"1x : 66%");
            book1_lore.add(ChatColor.AQUA+"2x : 33%");
            book1_meta.setLore(book1_lore);
            book1.setItemMeta(book1_meta);
            inv_fortune.setItem(19, book1);
          
          
            ItemStack book2 = new ItemStack(Material.ENCHANTED_BOOK);
            ItemMeta book2_meta = book2.getItemMeta();
            book2_meta.setDisplayName(ChatColor.GOLD +"Fortune II");
            List<String> book2_lore = new ArrayList<String>();
            book2_lore.add(ChatColor.AQUA+"1x : 50%");
            book2_lore.add(ChatColor.AQUA+"2x : 25%");
            book2_lore.add(ChatColor.AQUA+"3x : 25%");
            book2_meta.setLore(book2_lore);
            book2.setItemMeta(book2_meta);
            inv_fortune.setItem(21, book2);
          
            ItemStack book3 = new ItemStack(Material.ENCHANTED_BOOK);
            ItemMeta book3_meta = book3.getItemMeta();
            book3_meta.setDisplayName(ChatColor.GOLD +"Fortune III");
            List<String> book3_lore = new ArrayList<String>();
            book3_lore.add(ChatColor.AQUA+"1x : 40%");
            book3_lore.add(ChatColor.AQUA+"2x : 20%");
            book3_lore.add(ChatColor.AQUA+"3x : 20%");
            book3_lore.add(ChatColor.AQUA+"4x : 20%");
            book3_meta.setLore(book3_lore);
            book3.setItemMeta(book3_meta);
            inv_fortune.setItem(23, book3);
          
          
            ItemStack book4 = new ItemStack(Material.ENCHANTED_BOOK);
            ItemMeta book4_meta = book4.getItemMeta();
            book4_meta.setDisplayName(ChatColor.GOLD +"Fortune IV");
            List<String> book4_lore = new ArrayList<String>();
            book4_lore.add(ChatColor.AQUA+"2x : 40%");
            book4_lore.add(ChatColor.AQUA+"3x : 30%");
            book4_lore.add(ChatColor.AQUA+"4x : 30%");
            book4_meta.setLore(book4_lore);
            book4.setItemMeta(book4_meta);
            inv_fortune.setItem(25, book4);
                
                
            ItemStack back = new ItemStack(Material.BLUE_STAINED_GLASS_PANE, 1);
            ItemMeta back_meta = back.getItemMeta();
            back_meta.setDisplayName(ChatColor.GOLD+"Back");
            back.setItemMeta(back_meta);
            inv_fortune.setItem(36, back);
        }
      
    
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
          
            if (label.equalsIgnoreCase("test")) {
                if (check=true) {check=false;
                set_chance();
                set_GUI_main();
                set_GUI_fortune();
              
                }
                if (!(sender instanceof Player)) {
                    sender.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("not_a_player")));
                    return true;    }
              
                    Player player = (Player) sender;
                  
                    UUID uuid = player.getUniqueId();
                    if (plugin.getConfig().getInt("ore_drop."+uuid+".drop.button") == 0 ) {
                        inv_main.setItem(17, disable_drops_all);
                    } else {
                        inv_main.setItem(17, enable_drops_all);
                    }
                  
                  
                  
                    player.openInventory(inv_main);
              
          
          
            }
            return false;
        }
      
      
    
    @EventHandler
        public void onClick(InventoryClickEvent e) {
          
            if (!ChatColor.stripColor(e.getView().getTitle().toString()).equalsIgnoreCase("Drop")) return;
            if (e.getCurrentItem() == null) return;
            if (e.getCurrentItem().getItemMeta() == null) return;
            if (e.getCurrentItem().getItemMeta().getDisplayName() == null) return;
            Player player = (Player) e.getWhoClicked();
            UUID uuid = player.getUniqueId();
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase(" ")) {
                   e.setCancelled(true);
            return;
        }
          
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase(" ")) {
                   //here I try this:
                    e.setCancelled(true);
                    player.openInventory(inv_fortune);
            //but player.openInventory(inv_fortune) don't work
    ;
            return;
        }
          
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Click, to enable all drops.")) {
                   e.setCancelled(true);
                
                   plugin.getConfig().set("ore_drop."+uuid+".drop.coal", 0);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.iron_ore", 0);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.gold_ore", 0);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.lapis", 0);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.redstone", 0);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.emerald", 0);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.clay", 0);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.diamond", 0);
                  
                   plugin.getConfig().set("ore_drop."+uuid+".drop.button", 0);
                   plugin.saveConfig();
                  player.getInventory().setItem(26, enable_drops_all);
                  player.updateInventory();
                  
            return;
        }
          
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Click, to disable all drops.")) {
                   e.setCancelled(true);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.coal", 1);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.iron_ore", 1);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.gold_ore", 1);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.lapis", 1);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.redstone", 1);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.emerald", 1);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.clay", 1);
                   plugin.getConfig().set("ore_drop."+uuid+".drop.diamond", 1);
                  
                   plugin.getConfig().set("ore_drop."+uuid+".drop.button", 1);
                   plugin.saveConfig();
                  player.getInventory().setItem(26, disable_drops_all);
                  player.updateInventory();
                  
                  
            return;
        }
          
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Coal")) {e.setCancelled(true);return;}
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Iron ore")) {e.setCancelled(true);return;}
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Gold ore")) {e.setCancelled(true);return;}
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Lapis Lazuli")) {e.setCancelled(true);return;}
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Emerald")) {e.setCancelled(true);return;}
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Redstone")) {e.setCancelled(true);return;}
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Diamond")) {e.setCancelled(true);return;}
            if (ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Clay")) {e.setCancelled(true);return;}
      
        }
      
          
    }
     
  6. Offline

    KarimAKL

    @krypek I think the inventory you are trying to open might be null.
     
  7. Offline

    krypek

    I run a void that sets up inventory, and it did open! But an error shows on console. THANK YOU so much for giving me this idea!

    Problem solved!
     
    Last edited: Nov 5, 2019

Share This Page