Solved Registering PlayerLogin Event

Discussion in 'Plugin Development' started by UltraMC, Jan 14, 2014.

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

    UltraMC

    System.out.prntln() gives no output. I am afraid that event I have registered is done with mistakes:

    Code:java
    1. public void onEnable() {
    2. this.playerLoginListener = new PlayerLoginListener(this, this.database);
    3. getServer().getPluginManager().registerEvents(this.playerLoginListener,
    4. this);
    5. }


    Code:java
    1. public class PlayerLoginListener implements Listener {
    2.  
    3. public PlayerLoginListener(Plugin plugin, Database database) {
    4. }
    5.  
    6. @EventHandler
    7. public void onPlayerLogin(PlayerLoginEvent event) {
    8. Player player = event.getPlayer();
    9.  
    10. System.out.println("debug " + player);
    11. }
     
  2. Offline

    NetherResident

    UltraMC Is the plugin being enabled on the server?
     
  3. Offline

    Alshain01

    Your println is outputing a player object, not a player name.

    System.out.println("debug " + player.getName());
     
    UltraMC likes this.
  4. Offline

    NetherResident

    Alshain01 I don't think that should matter, it would still end up printing something in the console.
     
  5. Offline

    Alshain01

    Not sure about that. Your basically doing String.valueOf(player), I'm not sure what that would output but I'm guessing null.
     
  6. Offline

    NetherResident

    Alshain01 It outputs something like, CRAFTPLAYER{name="NetherResident"}. So with this being said, either his plugin isn't being enabled, or there is some other problem happening. Possibly the database variable is null.
     
  7. Offline

    UltraMC

    Am not sure if it was refreshing error or player.getName() but now it works as Alshain01 stated.

    Thanks!
     
Thread Status:
Not open for further replies.

Share This Page