getPlayerExact() for offline players

Discussion in 'Plugin Development' started by Briggybros, Nov 16, 2013.

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

    Briggybros

    Hello, I'm trying to get the Player object of a player by username, regardless if they're online or not. I know that the name of the player (myself) is in the world data, and therefore should be classified as an offline player. However, when the username gets passed through the getPlayerExact() method, it returns null (and then goes on to break everything). How can I always get an instance of Player, regardless of whether the player is online?
     
  2. Offline

    GusGold

    Briggybros
    It may be case sensitive if you haven't already tried that?
     
  3. Offline

    Briggybros

    GusGold I am using case sensitivity in case it is, and to no avail.
     
  4. Offline

    GusGold

    Jhtzb likes this.
  5. Offline

    Briggybros

    GusGold I looked into it yes, and it is what I am currently using. The problem with it is that it will always return an object, even if there's no such player. I was..
    Never mind, just though of a solution. :D
     
  6. Offline

    GusGold

    Briggybros
    Code:java
    1. if (offlinePlayer == null){
    2. //nope!
    3. }
     
  7. Offline

    Briggybros

    GusGold
    But you can check the name against the names of the dat files in the main world's folder.
     
  8. Offline

    GusGold

    Briggybros
    my way sounds easier... but yeah, that would work
     
Thread Status:
Not open for further replies.

Share This Page