Could not pass event InventoryClickEvent

Discussion in 'Plugin Development' started by falscherIdiot, May 7, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    falscherIdiot

    So i wanted to open an Inventory which hold an Item that allow to save the Spawn Location in the Config

    Code:
    Could not pass event InventoryClickEvent to Lobby v1.0
    org.bukkit.event.EventException: null
       at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-Spigot-dcd1643-e60fc34]
       at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[server.jar:git-Spigot-dcd1643-e60fc34]
       at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) [server.jar:git-Spigot-dcd1643-e60fc34]
       at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) [server.jar:git-Spigot-dcd1643-e60fc34]
       at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1891) [server.jar:git-Spigot-dcd1643-e60fc34]
       at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:33) [server.jar:git-Spigot-dcd1643-e60fc34]
       at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:10) [server.jar:git-Spigot-dcd1643-e60fc34]
       at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [server.jar:git-Spigot-dcd1643-e60fc34]
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
       at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
       at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [server.jar:git-Spigot-dcd1643-e60fc34]
       at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [server.jar:git-Spigot-dcd1643-e60fc34]
       at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [server.jar:git-Spigot-dcd1643-e60fc34]
       at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [server.jar:git-Spigot-dcd1643-e60fc34]
       at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [server.jar:git-Spigot-dcd1643-e60fc34]
       at java.lang.Thread.run(Thread.java:834) [?:?]
    Caused by: java.lang.NullPointerException
       at Items.InventoryClick.clickEvent(InventoryClick.java:99) ~[?:?]
       at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
       at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
       at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
       at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
       at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[server.jar:git-Spigot-dcd1643-e60fc34]
       ... 15 more
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    falscherIdiot

    Code:
    package Items;
    
    import org.bukkit.Location;
    import org.bukkit.Sound;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    import me.Lobby.Main;
    
    public class InventoryClick implements Listener {
       
        private Main main;
       
        @EventHandler
        public void clickEvent(InventoryClickEvent e) {
            Player p = null;
            if(e.getWhoClicked() instanceof Player) {
                p = (Player) e.getWhoClicked();
            }
            if(e.getCurrentItem().hasItemMeta()) {
                //########################################################################################################################
                //                                                                                       Normal Inventory
                //########################################################################################################################
                if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§8>>§5§3Back to Lobby§8<<")) {
                    if(!p.getWorld().getName().equals("Lobby")) {
                        Location loc = (Location) main.getConfig().get("Spawn");
                        p.teleport(loc);
                        p.sendMessage(Main.prefix + "§bYou are back in the Lobby");
                    }
                    else {
                        p.sendMessage(Main.prefix + "§bYou are already in the Lobby");
                    }
                    e.setCancelled(true);           
                }
                if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§8>>§5§3Perks§8<<")) {
                    e.setCancelled(true);
                    p.openInventory(Main.StarInventory);
                }
                if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§8>>§5§3Teleporter§8<<")) {
                    e.setCancelled(true);
                    p.openInventory(Main.CompassInventory);
                }
                //########################################################################################################################
                //                                                                                       Perks Panel
                //########################################################################################################################
                if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§f§lSPEED")) {
                    if(p.hasPotionEffect(PotionEffectType.SPEED)) {
                        p.removePotionEffect(PotionEffectType.SPEED);
                        p.sendMessage(Main.prefix + "§bThe SpeedEffect got disabled!");
                        p.playSound(p.getLocation(), Sound.ITEM_TOTEM_USE, 10, 1);
                    }else {
                        p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
                        p.sendMessage(Main.prefix + "§bThe SpeedEffect got enabled!");
                        p.playSound(p.getLocation(), Sound.ITEM_TOTEM_USE, 10, 1);
                    }
                    e.setCancelled(true);
                }
               
                if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§b§lJump-BOOST")) {
                    if(p.hasPotionEffect(PotionEffectType.JUMP)) {
                        p.removePotionEffect(PotionEffectType.JUMP);
                        p.sendMessage(Main.prefix + "§bThe Jump-BOOST got disabled!");
                        p.playSound(p.getLocation(), Sound.ITEM_TOTEM_USE, 10, 1);
                    }else {
                        p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 1));
                        p.sendMessage(Main.prefix + "§bThe Jump-BOOST got enabled!");
                        p.playSound(p.getLocation(), Sound.ITEM_TOTEM_USE, 10, 1);
                    }
                    e.setCancelled(true);
                }
                //########################################################################################################################
                //                                                                                       Teleporter Panel
                //########################################################################################################################
                if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§cBed§fWars")) {
                    e.setCancelled(true);
                    Location loc = (Location) main.getConfig().get("BedWars");
                    p.teleport(loc);
                    p.sendMessage(Main.prefix + "§cBed§fWars§8§l: §cIs coming soon!");
                    p.playSound(p.getLocation(), Sound.BLOCK_PORTAL_TRAVEL, 10, 1);
                }
               
                if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§5GunGame")) {
                    e.setCancelled(true);
                    Location loc = (Location) main.getConfig().get("GunGame");
                    p.teleport(loc);
                    p.sendMessage(Main.prefix + "§5GunGame§8§l: §cIs coming soon!");
                    p.playSound(p.getLocation(), Sound.BLOCK_PORTAL_TRAVEL , 10, 1);
                }
                //########################################################################################################################
                //                                                                                       Admin-Setup Panel
                //########################################################################################################################
                if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§csetSpawn")) {
                    p.sendMessage(Main.prefix + "§cLobby Spawn got set");
                    e.setCancelled(true);
                    main.getConfig().set("Spawn", p.getLocation());
                    main.saveConfig();
                }
                if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§csetBedWars")) {
                    //main.getConfig().set("BedWars", p.getLocation());
                    //main.saveConfig();
                    p.sendMessage(Main.prefix + "§cBedWars Spawn got set");
                    e.setCancelled(true);
                }
                if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§csetGunGame")) {
                    //main.getConfig().set("GunGame", p.getLocation());
                    //main.saveConfig();
                    p.sendMessage(Main.prefix + "§cGunGame Spawn got set");
                    e.setCancelled(true);
                }
            }
        }
    }
     
  4. Online

    timtower Administrator Administrator Moderator

    @falscherIdiot You are not checking if there is a displayname, that can return null.
     
  5. Offline

    falscherIdiot

    ? where
     
  6. Online

    timtower Administrator Administrator Moderator

    @falscherIdiot
    e.getCurrentItem().getItemMeta().getDisplayName()
    That line can return null.
    So my advice would be changing the check with the hasItemMeta to also check hasDisplayName
     
  7. Offline

    falscherIdiot

    Could you send me how?
    because im not getting it
     
  8. Online

    timtower Administrator Administrator Moderator

    @falscherIdiot
    e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName()
     
  9. Offline

    falscherIdiot

    still the same but this time when i started the server i got this
    Code:
    Error occurred while enabling Lobby v1.0 (Is it up to date?)
    java.lang.NullPointerException: null
        at me.Lobby.Main.onEnable(Main.java:54) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381) [server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:422) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:383) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:338) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:272) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [server.jar:git-Spigot-dcd1643-e60fc34]
        at java.lang.Thread.run(Thread.java:834) [?:?]
    
    The Main-Error
    Code:
    Could not pass event InventoryClickEvent to Lobby v1.0
    org.bukkit.event.EventException: null
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) [server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1891) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:33) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:10) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [server.jar:git-Spigot-dcd1643-e60fc34]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [server.jar:git-Spigot-dcd1643-e60fc34]
        at java.lang.Thread.run(Thread.java:834) [?:?]
    Caused by: java.lang.NullPointerException
        at Items.InventoryClick.clickEvent(InventoryClick.java:94) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        ... 15 more
    
     
  10. Online

    timtower Administrator Administrator Moderator

    @falscherIdiot Please post your main class and your updated InventoryClick class. They are probably related.

    Your main in InventoryClick is empty.
     
  11. Offline

    falscherIdiot

    MAIN
    Code:java
    1. package me.Lobby;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.Difficulty;
    5. import org.bukkit.event.inventory.InventoryType;
    6. import org.bukkit.inventory.Inventory;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. import Commands.Admin;
    10. import Commands.Build;
    11. import Commands.Hub;
    12. import Listener.Join;
    13. import Listener.antiFallDamage;
    14. import Listener.antiHunger;
    15. import Listener.antiRain;
    16. import Listener.Chat;
    17. //import Listener.DevTool;
    18.  
    19. import Items.JoinEvent;
    20. import Items.DropListener;
    21. import Items.Funktionen;
    22. import Items.Interact;
    23. import Items.InventoryClick;
    24.  
    25. public class Main extends JavaPlugin {
    26.  
    27. public static String world = "Lobby";
    28. public static String prefix = "§6Lobby §8>> ";
    29.  
    30. public static Inventory CompassInventory = Bukkit.createInventory(null, InventoryType.HOPPER, "§8>>§5§3Teleporter§8<<");
    31. public static Inventory StarInventory = Bukkit.createInventory(null, InventoryType.HOPPER, "§8>>§5§3Perks§8<<");
    32. public static Inventory AdminSetup = Bukkit.createInventory(null, InventoryType.HOPPER,"§cLobby Setup");
    33.  
    34.  
    35. @Override
    36. public void onEnable() {
    37. Bukkit.getPluginManager().registerEvents(new Join(), this);
    38. Bukkit.getPluginManager().registerEvents(new Chat(), this);
    39. //Bukkit.getPluginManager().registerEvents(new DevTool(), this); // Needs rework //
    40. Bukkit.getPluginManager().registerEvents(new antiFallDamage(), this);
    41. Bukkit.getPluginManager().registerEvents(new antiRain(), this);
    42. Bukkit.getPluginManager().registerEvents(new antiHunger(), this);
    43. Bukkit.getPluginManager().registerEvents(new JoinEvent(), this);
    44. Bukkit.getPluginManager().registerEvents(new DropListener(), this);
    45. Bukkit.getPluginManager().registerEvents(new InventoryClick(), this);
    46. Bukkit.getPluginManager().registerEvents(new Interact(), this);
    47.  
    48. getCommand("hub").setExecutor(new Hub());
    49. getCommand("lobby").setExecutor(new Hub());
    50. getCommand("setup").setExecutor(new Admin());
    51. getCommand("build").setExecutor(new Build());
    52.  
    53. Funktionen.fill();
    54. Bukkit.getWorld(world).setPVP(false);
    55. Bukkit.getWorld(world).setDifficulty(Difficulty.PEACEFUL);
    56.  
    57. loadConfig();
    58. }
    59.  
    60. public void loadConfig() {
    61. getConfig().options().copyDefaults(true);
    62. saveConfig();
    63. }
    64. }


    InventoryClick
    Code:java
    1. package Items;
    2.  
    3. import org.bukkit.Location;
    4. import org.bukkit.Sound;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.event.inventory.InventoryClickEvent;
    9. import org.bukkit.potion.PotionEffect;
    10. import org.bukkit.potion.PotionEffectType;
    11.  
    12. import me.Lobby.Main;
    13.  
    14. public class InventoryClick implements Listener {
    15.  
    16. private Main main;
    17.  
    18. @EventHandler
    19. public void clickEvent(InventoryClickEvent e) {
    20. Player p = null;
    21. if(e.getWhoClicked() instanceof Player) {
    22. p = (Player) e.getWhoClicked();
    23. }
    24. if(e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName()) {
    25. //########################################################################################################################
    26. // Normal Inventory
    27. //########################################################################################################################
    28. if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§8>>§5§3Back to Lobby§8<<")) {
    29. Location loc = (Location) main.getConfig().get("Spawn");
    30. p.teleport(loc);
    31. p.sendMessage(Main.prefix + "§bYou are back in the Lobby");
    32. e.setCancelled(true);
    33. }
    34. if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§8>>§5§3Perks§8<<")) {
    35. e.setCancelled(true);
    36. p.openInventory(Main.StarInventory);
    37. }
    38. if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§8>>§5§3Teleporter§8<<")) {
    39. e.setCancelled(true);
    40. p.openInventory(Main.CompassInventory);
    41. }
    42. //########################################################################################################################
    43. // Perks Panel
    44. //########################################################################################################################
    45. if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§f§lSPEED")) {
    46. if(p.hasPotionEffect(PotionEffectType.SPEED)) {
    47. p.removePotionEffect(PotionEffectType.SPEED);
    48. p.sendMessage(Main.prefix + "§bThe SpeedEffect got disabled!");
    49. p.playSound(p.getLocation(), Sound.ITEM_TOTEM_USE, 10, 1);
    50. }else {
    51. p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
    52. p.sendMessage(Main.prefix + "§bThe SpeedEffect got enabled!");
    53. p.playSound(p.getLocation(), Sound.ITEM_TOTEM_USE, 10, 1);
    54. }
    55. e.setCancelled(true);
    56. }
    57.  
    58. if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§b§lJump-BOOST")) {
    59. if(p.hasPotionEffect(PotionEffectType.JUMP)) {
    60. p.removePotionEffect(PotionEffectType.JUMP);
    61. p.sendMessage(Main.prefix + "§bThe Jump-BOOST got disabled!");
    62. p.playSound(p.getLocation(), Sound.ITEM_TOTEM_USE, 10, 1);
    63. }else {
    64. p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 1));
    65. p.sendMessage(Main.prefix + "§bThe Jump-BOOST got enabled!");
    66. p.playSound(p.getLocation(), Sound.ITEM_TOTEM_USE, 10, 1);
    67. }
    68. e.setCancelled(true);
    69. }
    70. //########################################################################################################################
    71. // Teleporter Panel
    72. //########################################################################################################################
    73. if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§cBed§fWars")) {
    74. e.setCancelled(true);
    75. Location loc = (Location) main.getConfig().get("BedWars");
    76. p.teleport(loc);
    77. p.sendMessage(Main.prefix + "§cBed§fWars§8§l: §cIs coming soon!");
    78. p.playSound(p.getLocation(), Sound.BLOCK_PORTAL_TRAVEL, 10, 1);
    79. }
    80.  
    81. if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§5GunGame")) {
    82. e.setCancelled(true);
    83. Location loc = (Location) main.getConfig().get("GunGame");
    84. p.teleport(loc);
    85. p.sendMessage(Main.prefix + "§5GunGame§8§l: §cIs coming soon!");
    86. p.playSound(p.getLocation(), Sound.BLOCK_PORTAL_TRAVEL , 10, 1);
    87. }
    88. //########################################################################################################################
    89. // Admin-Setup Panel
    90. //########################################################################################################################
    91. if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§csetSpawn")) {
    92. p.sendMessage(Main.prefix + "§cLobby Spawn got set");
    93. e.setCancelled(true);
    94. main.getConfig().set("Spawn", p.getLocation());
    95. main.saveConfig();
    96. }
    97. if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§csetBedWars")) {
    98. //main.getConfig().set("BedWars", p.getLocation());
    99. //main.saveConfig();
    100. p.sendMessage(Main.prefix + "§cBedWars Spawn got set");
    101. e.setCancelled(true);
    102. }
    103. if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§csetGunGame")) {
    104. //main.getConfig().set("GunGame", p.getLocation());
    105. //main.saveConfig();
    106. p.sendMessage(Main.prefix + "§cGunGame Spawn got set");
    107. e.setCancelled(true);
    108. }
    109. }
    110. }
    111. }
     
  12. Online

    timtower Administrator Administrator Moderator

    @falscherIdiot Your world is not loaded yet, so getWorld(world) is returning null.
    Your other error is because main is null in your InventoryClick class.
     
  13. Offline

    KarimAKL

  14. Offline

    falscherIdiot

    where is the getWorld(world) you mean

    so i removed the setDifficulty and the pvp thing, so i got rid of the error when starting the server
    but the main error is still there
    Code:
    Could not pass event InventoryClickEvent to Lobby v1.0
    org.bukkit.event.EventException: null
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) [server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1891) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:33) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.PacketPlayInWindowClick.a(SourceFile:10) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [server.jar:git-Spigot-dcd1643-e60fc34]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
        at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [server.jar:git-Spigot-dcd1643-e60fc34]
        at java.lang.Thread.run(Thread.java:834) [?:?]
    Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:183) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:60) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at me.Lobby.Main.<init>(Main.java:25) ~[?:?]
        at Items.InventoryClick.clickEvent(InventoryClick.java:23) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        ... 15 more
    Caused by: java.lang.IllegalStateException: Initial initialization
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:186) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:60) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at me.Lobby.Main.<init>(Main.java:25) ~[?:?]
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
        at java.lang.Class.newInstance(Class.java:584) ~[?:?]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:90) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:327) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:248) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:305) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:205) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) ~[server.jar:git-Spigot-dcd1643-e60fc34]
        ... 1 more
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 7, 2020
  15. Online

    timtower Administrator Administrator Moderator

    @falscherIdiot Ylj are calling new Main(), don't do that.
    Use a constructor to pass the main instance along instead.
     
  16. Offline

    falscherIdiot

    i noticed that and removed that but now it has a problem with
    Code:
    main.getConfig().set("Spawn", p.getLocation());
                    main.saveConfig();
    these two

    So I solved the Problem and everything is working fine now
    i needed to add
    Code:
    Plugin main = Main.getPlugin(Main.class);
    Plugin main = Main.getPlugin(Main.class);

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 7, 2020
  17. Online

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page