[Solved]Unknown Error (null pointer exeption) AFTER plugin loading

Discussion in 'Plugin Development' started by Jobi, Apr 7, 2012.

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

    Jobi

    In my Plugin i have the following error, i do something, but I don' t know when this happens and why maby someone has an Idea:
    Code:
    12:07:46 [SCHWERWIEGEND] Could not pass event PlayerInteractEvent to NoGamemodeC
    heat
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:303)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:459)
            at org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEven
    t(CraftEventFactory.java:175)
            at org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEven
    t(CraftEventFactory.java:145)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:889)
            at net.minecraft.server.Packet18ArmAnimation.handle(SourceFile:38)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:229)
            at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:113)
            at net.minecraft.server.NetworkListenThread.a(NetworkListenThread.java:7
    8)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:554)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:452)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    Caused by: java.lang.NullPointerException
            at joba97.NoGamemodeCheat.main.PlayerListener.Open(PlayerListener.java:5
    7)
            at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:301)
            ... 12 more
    >
    And this is my Player Interact Class:

    Code:
    @EventHandler
        public void Open (PlayerInteractEvent event)  {
            String block = event.getClickedBlock().getType().toString();
            if ((block.equalsIgnoreCase("Dispenser") || block.equalsIgnoreCase("workbench") || block.equalsIgnoreCase("Chest") || block.equalsIgnoreCase("Furnace")) && event.getPlayer().getGameMode() == GameMode.CREATIVE && joba97.NoGamemodeCheat.main.main.adminmode.get(event.getPlayer()) == false && CheckWorld(event.getPlayer().getWorld().getName())) {
                event.setCancelled(true);
            }
        }
    The whole plugin works, but there is this annoying error and i don't know, how to fix this...
     
  2. Offline

    Lolmewn

    event.getClickedBlock probably is null. If a player right clicks in the air, this event also fires. Find out if the player clicked a block by doing
    Code:java
    1. Action a = event.getAction();
    2. if(a.equals(Action.RIGHT_CLICK_BLOCK)){
    3. //code
    4. }

    It might be a bit different, I did this from my head.
     
  3. Offline

    adde

    Remove the space between Open and (PlayerInteractEvent event)
     
  4. doesn't matter.

    Why do you get the string of the type and then compare it instead of just using the enum values to compare?
     
  5. Offline

    Jobi

    Everything works fine with your version Lolmewn, but i decidet to just write
    Code:
    if (event.getPlayer().getGameMode() == GameMode.CREATIVE && joba97.NoGamemodeCheat.main.main.adminmode.get(event.getPlayer()) == false && CheckWorld(event.getPlayer().getWorld().getName())) {
    //code
    }
    Now i have an other question: what means this error:

    Code:
    14:45:30 [INFORMATION] [FunnyThings] enabled!
    14:45:30 [INFORMATION] Server permissions file permissions.yml is empty, ignorin
    g it
    14:45:30 [SCHWERWIEGEND] java.lang.NullPointerException
    14:45:30 [SCHWERWIEGEND]        at org.bukkit.craftbukkit.help.SimpleHelpMap.ini
    tializeCommands(SimpleHelpMap.java:120)
    14:45:30 [SCHWERWIEGEND]        at org.bukkit.craftbukkit.CraftServer.enablePlug
    ins(CraftServer.java:240)
    14:45:30 [SCHWERWIEGEND]        at net.minecraft.server.MinecraftServer.t(Minecr
    aftServer.java:374)
    14:45:30 [SCHWERWIEGEND]        at net.minecraft.server.MinecraftServer.a(Minecr
    aftServer.java:361)
    14:45:30 [SCHWERWIEGEND]        at net.minecraft.server.MinecraftServer.init(Min
    ecraftServer.java:187)
    14:45:30 [SCHWERWIEGEND]        at net.minecraft.server.MinecraftServer.run(Mine
    craftServer.java:425)
    14:45:30 [SCHWERWIEGEND]        at net.minecraft.server.ThreadServerApplication.
    run(SourceFile:490)
    14:45:30 [SCHWERWIEGEND] Unexpected exception
    java.lang.NullPointerException
            at org.bukkit.craftbukkit.help.SimpleHelpMap.initializeCommands(SimpleHe
    lpMap.java:120)
            at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:240
    )
            at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:374)
            at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:361)
            at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:187)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    This only happens, when I use the plugin "FunnyThings", but it is already enabled. Do you have an idea what this could be or do you need more information?

    kumpelblase2
    It has a reason why i did it...

    JoBi9

    Ps: how do you make Java code
     
  6. You mind telling why?
    Code:
    [syntax=java][/syntax]
     
  7. Offline

    Jobi

    Im sorry, i was just writing a post in a different forum and someone asked a similar question... You are right, it doesn' t makes much sense, but do you have an idea how to fix my bug, or causes my bug?
     
  8. Not really no. There could be some reasons, but I'm not totally sure.
     
  9. Offline

    Jobi

    should i post my main class for you?
     
  10. Offline

    AJAW

    It is caused by: Caused by: java.lang.NullPointerException
    Sorry if it did not help.
     
  11. Offline

    Jobi

    thats not realy helping...
     
  12. Offline

    Jobi

    has nobody an answer?
     
  13. Offline

    dsmyth1915

    Here is a start. Whatever you did to create the NPE; is where you need to look. whatever you did is causing SOMETHING in your code to be null; not existing.
     
  14. Offline

    Jobi

    Two realy good plugin programmer had already seen my code; it should be clean. Anywhay the bug happens, when the Plugin is full loaded and prevents the full server to start.
     
  15. Offline

    Darkman2412

    There are 2 possible cases:
    - it's a CraftBukkit bug (since it throws a NPE in SimpleHelpMap)
    - you registrate your commands wrong.

    If you don't register any commands, then it's a CB bug.
     
  16. Offline

    Jobi

    Ok, it works now! It was a mistake in the command registration...
     
Thread Status:
Not open for further replies.

Share This Page