Could not pass event InventoryClickEvent

Discussion in 'Plugin Development' started by GuardianNinja, Feb 21, 2015.

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

    GuardianNinja

    Okay, I've been looking around the Bukkit forums for the solution to this problem but I can't find it.
    The problem I have is when the player is in the inventory and they click their personal inventory it sends this error :
    Error (open)
    [21:32:11 ERROR]: Could not pass event InventoryClickEvent to PantheonCore v1.0 org.bukkit.event.EventException at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:294) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:1364) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at net.minecraft.server.v1_7_R3.PacketPlayInWindowClick.a(SourceFile:32) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at net.minecraft.server.v1_7_R3.PacketPlayInWindowClick.handle(SourceFile:10) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] Caused by: java.lang.NullPointerException at me.GuardianNinja.GUI.MainGUI.onKitClick(MainGUI.java:287) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_05] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_05] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_05] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_05] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:292) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks] ... 13 more


    Code:
    Code:
    @SuppressWarnings("deprecation")
          @EventHandler
          public void onKitClick(InventoryClickEvent e) {
              Player p = Bukkit.getPlayer(e.getWhoClicked().getName());
              ItemStack previous = (new ItemStack(Material.CARPET));
              ItemMeta name = (ItemMeta)previous.getItemMeta();
              name.setDisplayName(ChatColor.GRAY + "Previous Page");
              previous.setItemMeta(name);
              if (!e.getInventory().getName().equals(maing.getName())) {
                return; 
              }
              if (!(e.getSlotType() != SlotType.OUTSIDE)) {
                  return;
              }
             if (e.getCurrentItem().getItemMeta().getDisplayName() == "") {
                     return;
                 }
             if (e.getClick() == ClickType.NUMBER_KEY) {
                 e.setCancelled(true);
             }
             if (e.getCurrentItem() == null) {
                 p.closeInventory();
                 return;
             }
             if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "<--")) {
                 p.closeInventory();
                 e.setCancelled(true);
             }
             if (e.getCurrentItem().getItemMeta().getDisplayName().equals(" ")) {
                 p.getOpenInventory().close();
                 p.closeInventory();
                 e.setCancelled(true);
             }
             if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "-->")) {
                 p.closeInventory();
                 e.setCancelled(true);
             }
             if (e.getCurrentItem().getType() == Material.EMERALD_BLOCK) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.openInventory(WarpGUI.warps);
                 p.playSound(p.getLocation(), Sound.FIZZ, 1, 0);
             }
             if (e.getCurrentItem().getType() == Material.DIAMOND_BLOCK) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.openInventory(CustomGUI.customs);
                
             }
             if (e.getCurrentItem().getType() == Material.GOLD_BLOCK) {
                 p.closeInventory();
                 e.setCancelled(true);
                
             }
             if (e.getCurrentItem().getType() == Material.DIAMOND_SWORD) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.performCommand("pvp");
             }
             if (e.getCurrentItem().getType() == Material.BOW) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.performCommand("archer");
             }
             if (e.getCurrentItem().getType() == Material.LEATHER_BOOTS) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.performCommand("forerunner");
             }
             if (e.getCurrentItem().getType() == Material.DRAGON_EGG) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.performCommand("babydragon");
             }
             if (e.getCurrentItem().getType() == Material.STONE_HOE) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.performCommand("spartan");
             }
             if (e.getCurrentItem().getType() == Material.DIAMOND) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.performCommand("timewizard");
             }
             if (e.getCurrentItem().getType() == Material.TNT) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.performCommand("terrorist");
             }
             if (e.getCurrentItem().getType() == Material.WATER) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.performCommand("gyarados");
             }
             if (e.getCurrentItem().getType() == Material.SNOW_BALL) {
                 p.closeInventory();
                 e.setCancelled(true);
                 p.performCommand("switcher");
             }
             if (e.getCurrentItem().getType() == Material.THIN_GLASS) {
                 p.closeInventory();
                 e.setCancelled(true);
             }
          }
     
  2. Offline

    Qwertyness_

    What is line 287?
     
  3. Offline

    GuardianNinja

    if (e.getCurrentItem().getItemMeta().getDisplayName() == "") {
     
  4. Offline

    Qwertyness_

    Never use == when comparing strings. Instead use String.equalsIgnoreCase() or String.equals()

    EDIT:
    Though in your case, you are checking for an empty string. In that case, you would use string == null
     
  5. Offline

    GuardianNinja

    I didn't know that (I'm also fairly new to coding in general) but would fix my problem?
     
  6. Offline

    Qwertyness_

    If that is the only reason for the exception, yes, it should.
     
  7. Offline

    GuardianNinja

    Okay, thank you for the help :) It was the only error I couldn't fix on my server, if it doesn't fix it may I ask for your help again?
     
  8. Offline

    Konato_K

    @GuardianNinja With no intention to sound mean, you should start by learning java, it will help you a lot and you will be able to solve this kind of easy problems, otherwise you'll end up here making 10 threads about simple things that can be easily solved by learning the language first
     
  9. Offline

    GuardianNinja

    @Konato_K That didn't sound mean, and I honestly agree, I know the most basic Java, but I jumped right into bukkit, I can fix my other errors but this one I couldn't figure out.
     
  10. Offline

    Qwertyness_

    Learning a language is great, but the best way to truly learn a language is by doing projects like Minecraft plugins. Its hard to just sit down and learn a language before you actually try to do anything with it.
     
  11. Offline

    Konato_K

    @GuardianNinja Well, your problem it's kinda basic, anyway, you have a NullPointerException, try googling what that is and how to solve it

    I'm pretty sure getCurrentItem can return null and even in the case it doesn't getItemMeta will return null if the ItemStack type it's Material.AIR
     
Thread Status:
Not open for further replies.

Share This Page