{do something} on player login?

Discussion in 'Plugin Development' started by stargateanubis14, Jan 17, 2012.

Thread Status:
Not open for further replies.
  1. what is the procedure for when a player logs into the server, to get their Player name, and do something from within the method?

    (basically, when a user logs in, it checks their permissions, and then attempts to 'update' certain settings)
    --this is needed by me, only because u cant get a players permissions when they're offline :/


    I was looking at this , but i'm not 100% sure on the way to do it.

    Ok... for an update. I got somewhere with it.
    My source is all up athttp://pastebin.com/u/empirebattles (all files there are a part of the project)
    However, i have an error in the log here : http://pastebin.com/5thidtca

    The error says null pointer in checkingamePlayerListener.java on line 56... however i see no problems (unless plugin.getServer() isn't working right).

    Can anyone advise?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 23, 2016
  2. Offline

    Fyre

    public void BasicPlayerListener(checkingame instance)

    That's a constructor, so it should be the same as the class name.Yours should be,
    public void checkingamePlayerListener(checkingame instance)
     
  3. *facepalm*
    But even then, i'm still getting the error::

    Code:
    [SEVERE] Could not pass event PLAYER_JOIN to checkingame
    java.lang.NullPointerException
        at me.empirebattles.checkingame.checkingamePlayerListener.onPlayerJoin(checkingamePlayerListener.java:56)
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:265)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:339)
        at net.minecraft.server.ServerConfigurationManager.c(ServerConfigurationManager.java:129)
        at net.minecraft.server.NetLoginHandler.b(NetLoginHandler.java:113)
        at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:39)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:94)
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:527)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    Not sure why line 56 would contain a Null exception :/


    (i updated pastebin with modifications)


    (also... ignore the terrible formatting, and style of program... its just torn apart to visually see functionality)
     
  4. Offline

    Fyre

    Code:
    "+q_miner+" "+q_farmer+" "+q_fighter);
    Should be another quotation mark in there methinks.
     
  5. u mean +"" at the end? (if not, then idk... the quotes are even)
     
  6. Offline

    Fyre

    obviously
     
  7. well, i tried that too XD Its still givin the null error :/ (i'm gonna try replacing plugin.getServer() with Bukkit.getServer() ... we'll see if that gets rid of the error... if it does, then for some reason its not gtting the plugin)
     
  8. Offline

    Fyre

    Bukkit.getServer() would do nothing. The NullPointerException means you named a variable that doesn't exist and tried to do something with it. So you have to find out what that variable is.
     
  9. Nope... changing it to Bukkit.getServer() made it work perfectly :p
     
  10. Offline

    DusRonald

    @Stargateanubis14 Use
    Code:java
    1. @EventHandler
    2. public void onPlayerJoin(PlayerJoinEvent e){
    3. Player p = e.getPlayer();
    4. // Example:
    5. p.sendMessage(ChatColor.GREEN + "Hello " + p.getName() + "!");
    6. p.sendMessage(ChatColor.GREEN + "How are you?");
    7. }
     
Thread Status:
Not open for further replies.

Share This Page