Could not pass event/null pointer

Discussion in 'Plugin Development' started by civ77, Mar 31, 2014.

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


    I'm getting an error called "Could not pass event SignChangeEvent to TownPortal v1" further down in the error message it says "Caused by: java.lang.NullPointerException at civ77.plugins.townportal.TownPortal.TownPortal.onSign(". I have debug messages which print all of the variables, and none of them are null. Any ideas about what could be causing this? Also, what exactly causes an error to say "could not pass event..." instead of just NullPointerException?

    Line 97 (TPHomeLocations is a hashmap K is a String, V is a Location)
    1. TPHomeLocations.put(event.getPlayer().getName(), event.getBlock().getState().getLocation());
    Server Log
    Show Spoiler
    [16:29:50] [Server thread/INFO]: Starting minecraft server version 1.7.5
    [16:29:50] [Server thread/INFO]: Loading properties
    [16:29:50] [Server thread/INFO]: Default game type: SURVIVAL
    [16:29:50] [Server thread/INFO]: Generating keypair
    [16:29:51] [Server thread/INFO]: Starting Minecraft server on *:25565
    [16:29:51] [Server thread/INFO]: This server is running CraftBukkit version git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks (MC: 1.7.5) (Implementing API version 1.7.5-R0.1-SNAPSHOT)
    [16:29:51] [Server thread/INFO]: [TownPortal] Loading TownPortal v1
    [16:29:51] [Server thread/INFO]: Preparing level "false"
    [16:29:51] [Server thread/INFO]: Preparing start region for level 0 (Seed: 4671879424174103411)
    [16:29:52] [Thread-7/INFO]: ----- Bukkit Auto Updater -----
    [16:29:52] [Thread-7/INFO]: It appears that you're running a Development Build, when you've specified in bukkit.yml that you prefer to run Recommended Builds.
    [16:29:52] [Thread-7/INFO]: If you would like to be kept informed about new Development Build releases, it is recommended that you change 'preferred-channel' in your bukkit.yml to 'dev'.
    [16:29:52] [Thread-7/INFO]: With that set, you will be told whenever a new version is available for download, so that you can always keep up to date and secure with the latest fixes.
    [16:29:52] [Thread-7/INFO]: If you would like to disable this warning, simply set 'suggest-channels' to false in bukkit.yml.
    [16:29:52] [Thread-7/INFO]: ----- ------------------- -----
    [16:29:52] [Server thread/INFO]: Preparing spawn area: 29%
    [16:29:53] [Server thread/INFO]: Preparing spawn area: 87%
    [16:29:53] [Server thread/INFO]: Preparing start region for level 1 (Seed: 4671879424174103411)
    [16:29:54] [Server thread/INFO]: Preparing spawn area: 53%
    [16:29:55] [Server thread/INFO]: Preparing start region for level 2 (Seed: 4671879424174103411)
    [16:29:56] [Server thread/INFO]: [TownPortal] Enabling TownPortal v1
    [16:29:56] [Server thread/INFO]: [TownPortal] Enabling TownPortal...
    [16:29:56] [Server thread/INFO]: [TownPortal] TownPortal has been enabled.
    [16:29:56] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [16:29:56] [Server thread/INFO]: Done (5.041s)! For help, type "help" or "?"
    [16:30:51] [User Authenticator #1/INFO]: UUID of player civ77 is 5f9c395ddbdb4c45ab752ee3a25eb8e5
    [16:30:51] [Server thread/INFO]: civ77[/] logged in with entity id 431 at ([world] -188.07499998807907, 64.0, 170.61712696560784)
    [16:31:12] [Server thread/INFO]: [TownPortal] [TP DEBUG] on sign called
    [16:31:12] [Server thread/INFO]: [TownPortal] [TP DEBUG] [TP]
    [16:31:12] [Server thread/INFO]: [TownPortal] [TP DEBUG] CREATE
    [16:31:12] [Server thread/INFO]: [TownPortal] [TP DEBUG] portal is being set by civ77.
    [16:31:12] [Server thread/INFO]: [TownPortal] [TP DEBUG] portal location: Location{world=CraftWorld{name=world},x=-189.0,y=65.0,z=170.0,pitch=0.0,yaw=0.0}
    [16:31:12] [Server thread/ERROR]: Could not pass event SignChangeEvent to TownPortal v1
    at$1.execute( ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at org.bukkit.plugin.RegisteredListener.callEvent( ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at org.bukkit.plugin.SimplePluginManager.fireEvent( [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at org.bukkit.plugin.SimplePluginManager.callEvent( [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at net.minecraft.server.v1_7_R2.PlayerConnection.a( [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at net.minecraft.server.v1_7_R2.PacketPlayInUpdateSign.a(SourceFile:48) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at net.minecraft.server.v1_7_R2.PacketPlayInUpdateSign.handle(SourceFile:9) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at net.minecraft.server.v1_7_R2.NetworkManager.a( [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at net.minecraft.server.v1_7_R2.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at net.minecraft.server.v1_7_R2.MinecraftServer.v( [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at net.minecraft.server.v1_7_R2.DedicatedServer.v( [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at net.minecraft.server.v1_7_R2.MinecraftServer.u( [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    at [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    Caused by: java.lang.NullPointerException
    at civ77.plugins.townportal.TownPortal.TownPortal.onSign( ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_45]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_45]
    at$1.execute( ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-8-ga662658-b3032jnks]
    ... 13 more
    [16:31:25] [Server thread/INFO]: civ77 lost connection: Disconnected
    [16:31:25] [Server thread/INFO]: civ77 left the game.
    [16:31:29] [Server thread/INFO]: CONSOLE: Stopping the server..
    [16:31:29] [Server thread/INFO]: Stopping server
    [16:31:29] [Server thread/INFO]: [TownPortal] Disabling TownPortal v1
    [16:31:29] [Server thread/INFO]: [TownPortal] Disabling TownPortal...
    [16:31:29] [Server thread/INFO]: [TownPortal] TownPortal has been disabled.
    [16:31:29] [Server thread/INFO]: Saving players
    [16:31:29] [Server thread/INFO]: Saving worlds
    [16:31:29] [Server thread/INFO]: Saving chunks for level 'world'/Overworld
    [16:31:29] [Server thread/INFO]: Saving chunks for level 'world_nether'/Nether
    [16:31:29] [Server thread/INFO]: Saving chunks for level 'world_the_end'/The End
    [16:31:29] [Thread-4/INFO]: Stopping server
    [16:31:29] [Thread-4/INFO]: Saving players
    [16:31:29] [Thread-4/INFO]: Saving worlds
    [16:31:29] [Thread-4/INFO]: Saving chunks for level 'world'/Overworld

    Trimmed version of
    1. public class TownPortal extends JavaPlugin implements Listener{
    3. boolean debugging = true;
    4. public HashMap<String, Location> TPHomeLocations = new HashMap<String, Location>();
    5. public HashMap<String, Location> TPRemoteLocations = new HashMap<String, Location>();
    7. @Override
    8. public void onEnable(){
    9. getLogger().info("Enabling TownPortal...");
    10. this.saveDefaultConfig();
    11. getServer().getPluginManager().registerEvents(this, this);
    12. TPHomeLocations = load(getDataFolder() + File.separator + "TPHomeLocations.bin");
    13. TPRemoteLocations = load(getDataFolder() + File.separator + "TPRemoteLocations.bin");
    14. getLogger().info("TownPortal has been enabled.");
    15. }
    17. @Override
    18. public void onDisable(){
    19. getLogger().info("Disabling TownPortal...");
    20. save((HashMap<String, Location>) TPHomeLocations, getDataFolder() + File.separator + "TPHomeLocations.bin");
    21. save((HashMap<String, Location>) TPRemoteLocations, getDataFolder() + File.separator + "TPRemoteLocations.bin");
    22. getLogger().info("TownPortal has been disabled.");
    23. }
    25. @EventHandler
    26. public void onSign(SignChangeEvent event){
    27. //portal creation
    28. debugLog("on sign called");
    29. debugLog(event.getLine(0));
    30. debugLog(event.getLine(1));
    31. if(event.getLine(0).equals("[TP]") && event.getLine(1).equals("CREATE")){
    32. //debug text
    33. debugLog("portal is being set by "+ event.getPlayer().getName() +".");
    34. debugLog("portal location: " + event.getBlock().getLocation());
    35. TPHomeLocations.put(event.getPlayer().getName(), event.getBlock().getState().getLocation());
    36. event.getPlayer().sendMessage("Town Portal set.");
    37. }
    38. }
  2. Offline


    I think your problem is with

    'cause when I run it, it works just fine.
  3. Offline


    How could that be? I'm not getting any errors when enabling. Am I forgetting something to do with initializing hashmaps?
  4. Offline


    Maybe changing

    will work?
  5. Offline


    I've tried that now and I'm still getting the same error.

    Bump. I've had another look at it and tried a couple of changes, to no effect.
    (I've edited the code from the original post to reflect the change I made)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page