Solved Can someone tell me why this isn't working.

Discussion in 'Plugin Development' started by canemonster15, Mar 19, 2014.

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

    canemonster15

    I have an error in my PlayerJoinEvent. I have been stuck on it for while and can't figure out exactly why it isn't working. Any help would be appreciated.
    This is my code:
    Code:java
    1. package com.itscane.minerp;
    2.  
    3. import java.io.IOException;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.player.PlayerJoinEvent;
    11. import org.bukkit.scheduler.BukkitRunnable;
    12.  
    13. public class Event implements Listener {
    14.  
    15. public Main main;
    16.  
    17. @EventHandler
    18. public void join(PlayerJoinEvent e) {
    19.  
    20. final Player p = e.getPlayer();
    21.  
    22. if (main.players.contains(p.getName())) {
    23.  
    24. double a = main.config.getDouble("StartingMoney");
    25. main.players.set(p.getName() + ".Wallet", a);
    26. main.players.set(p.getName() + ".Bank", 0);
    27. try {
    28. main.players.save(main.playersFile);
    29. } catch (IOException e1) {
    30. e1.printStackTrace();
    31. }
    32. p.sendMessage(ChatColor.BLUE
    33. + "This server is running MineRP by ItsCane and Mark_Laymon");
    34. p.sendMessage(ChatColor.BLUE
    35. + "Your account was created and $100 was added to your account!");
    36. p.sendMessage(ChatColor.BLUE
    37. + "To prevent losing some of your money on death, deposit money into your bank.");
    38. p.sendMessage(ChatColor.BLUE
    39. + "You need to have your money on you to buy things!");
    40.  
    41. } else {
    42. p.sendMessage(ChatColor.BLUE + "Welcome back!");
    43. p.sendMessage(ChatColor.BLUE
    44. + "This server is running MineRP by ItsCane and Mark_Laymon");
    45. }
    46. }
    47.  
    48. }
    49.  


    This is my console error:
    Code:
    [19:57:40 ERROR]: Could not pass event PlayerJoinEvent to MineRP v0.1
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:320) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:486) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:471) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PlayerList.c(PlayerList.java:225) [craft
    bukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PlayerList.a(PlayerList.java:116) [craft
    bukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.LoginListener.c(LoginListener.java:78) [
    craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.LoginListener.a(LoginListener.java:42) [
    craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:149
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.NullPointerException
            at com.itscane.minerp.Event.join(Event.java:23) ~[?:?]
            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 org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            ... 14 more
    >
     
    
    Thanks ahead.
     
  2. Offline

    adam753

    I'm going to guess the Main variable is null. You'll need to set it in a constructor.
     
  3. Offline

    canemonster15

    That was it. Thanks.
     
Thread Status:
Not open for further replies.

Share This Page