Could not Pass Inventory Event Error in Console

Discussion in 'Plugin Development' started by _Fliegenklatsche, Oct 9, 2019.

Thread Status:
Not open for further replies.
  1. Hii,

    i need some help.


    Code:
    public class InventoryEvents implements Listener {
    
       public static String casename;
       public static Inventory inv;
       
       File file = FileListener.file;
       
       static YamlConfiguration c = FileListener.cfg;
       
       @EventHandler
       public static void onInvClose(InventoryCloseEvent e) {
         Inventory inv = e.getInventory();
         if (inv.getName().equals("§9" + casename));
           
         
         List<ItemStack> invs = Arrays.asList(inv.getContents());
      FileListener.cfg.set(casename, invs);
      FileListener.fileSave(FileListener.file, FileListener.cfg);
         
      
    
         
       }
       
      @SuppressWarnings("unchecked")
      public static void restoreInv(Player p, String casename){
       
      ItemStack[] content = ((List<ItemStack>)  c.get(casename)).toArray(new ItemStack[0]);
      Inventory inven = Bukkit.createInventory(null, 36, "§9" + casename);
      inven.setContents(content);
      p.openInventory(inven);
      }
       
       
       public static void casenameGetter(String cn) {
         casename = cn;
       }
       public static void invGetter(Inventory caseinv) {
         inv = caseinv;
       }
    }
    
    

    The inventory close Event should only pass if i create a case, but not if i close my creative inventory....


    Error log:

    Could not pass event InventoryCloseEvent to SuperCases v1.0
    org.bukkit.event.EventException: null
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.handleInventoryCloseEvent(CraftEventFactory.java:895) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1671) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at net.minecraft.server.v1_12_R1.PacketPlayInCloseWindow.a(PacketPlayInCloseWindow.java:18) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at net.minecraft.server.v1_12_R1.PacketPlayInCloseWindow.a(PacketPlayInCloseWindow.java:1) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_181]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_181]
    at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
    Caused by: java.lang.IllegalArgumentException: Cannot set to an empty path
    at org.apache.commons.lang.Validate.notEmpty(Validate.java:321) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at org.bukkit.configuration.MemorySection.set(MemorySection.java:168) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    at de.fliege.scasesListeners.InventoryEvents.onInvClose(InventoryEvents.java:32) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_181]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_181]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_181]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34]
    ... 16 more


    Please help me.
    Sry i am german and my english isnt very well lol
     
    Last edited by a moderator: Oct 9, 2019
  2. Offline

    Kars

    PHP:
    FileListener.cfg.set(casenameinvs);
    is causing the error because casename is not set.
     
  3. Offline

    robertlit

    Unless something has to be static don't make it static.
     
    Strahan likes this.
  4. Offline

    Strahan

    +1. Static doesn't exist just to simply you accessing data from other classes. Only use it where it's actually warranted. Use dependency injection instead. Also don't embed the color code; use the ChatColor enum. That's why it exists.
     
Thread Status:
Not open for further replies.

Share This Page