p.getGetServer().getInfo().getName() always returns NPE

Discussion in 'BungeeCord Plugin Development' started by xMoose_10, Sep 12, 2018.

  1. Hi! I'm trying to send a message to all online staff members that another staff member has connected and to what server. However, I cannot get it to work as the p.getServer().getInfo().getName() section will always return as null.

    Stack Trace:
    https://pastebin.com/mSMsZG8X

    Code:
    https://pastebin.com/hEaK1skS

    Thanks in advance to all who can help me <3!
     
  2. Hello.
    When the proxy calls PostLoginEvent, player is not connected to any server yet, that's why player.getServer().getInfo().getName() returns null, you can try to add a player or player name (to save some memory) to some List on PreLoginEvent, and then, on ServerConnectedEvent, if that List contains player name, remove it from that List and send the message to online staff members (to get the server name just do ServerConnectedEvent#getTarget().getName()). Hope that this helps.