PlayerJoinEvent instance error

Discussion in 'Plugin Development' started by edocsyl, May 1, 2012.

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

    edocsyl

    Hi
    I think i have a problem with a instance, an i don't know how to fix it.
    This are the errors:
    Code:
    Caused by: java.lang.NullPointerException
        at ch.edocsyl.CraftingTerritory.GSMListener.onPlayerJoin(GSMListener.java:20)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.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.java:301)
        ... 12 more
    
    my listener

    Code:
    package ch.edocsyl.CraftingTerritory;
     
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.EventPriority;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
     
    public class GSMListener implements Listener {
     
        private CraftingTerritory plugin;
     
        private funcs fu = new funcs();
     
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onPlayerJoin(PlayerJoinEvent e){
        Player p = e.getPlayer();
     
        if(plugin.gsmMysql.playerExists(p)){
            plugin.gsmMysql.exStatemen("UPDATE spieler SET lastlogin_mc = '" + fu.getTime() + "' WHERE mcname = '" + p.getName() + "'");
            }
        }
     
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onPlayerQuit(PlayerQuitEvent e){
        Player p = e.getPlayer();
        }
    }
    

    Main Class
    https://github.com/Edocsyl/Crafting...csyl/CraftingTerritory/CraftingTerritory.java
     
  2. Offline

    Mr Burkes

    Is there source code for your playerExists() method?
     
  3. Offline

    edocsyl

  4. Offline

    r0306

    Try this. In your GSMMysql, change this:
    Code:
    st = conn.prepareStatement("SELECT mcname FROM spieler WHERE mcname='"+p.getName()+"'");
    to this:
    Code:
    st = conn.prepareStatement("SELECT mcname FROM spieler WHERE mcname");
    and just run it and see if it works.
     
  5. Offline

    edocsyl

    r0306 This should not be the problem. In the Main class (craftingterritory.class) the method works..
     
Thread Status:
Not open for further replies.

Share This Page