Load Method Player return null

Discussion in 'Plugin Development' started by Irantwomiles, Oct 19, 2016.

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

    Irantwomiles

    So my problem is that I'm trying to create a load method so I dont have to read and write all the time from the config and I have everything setup, but when I try to load a player from the UUID that isn't online it throws a NPE. I know that I can use OfflinePlayer but the method I'm trying to load in takes the parameters of Player. Now unless I have two methods of which one takes OfflinePlayer and one takes Player I don't know what to do.

    TD;LR: Is there a way to get player with out having to use offline player even though the player isnt online.

    if anything is unclear please tell me and I'll try to explain it better.
     
  2. Offline

    Zombie_Striker

    @Irantwomiles
    So, you want to be able to get a player even though the player does not exist? No, there is no way to do this.

    However, there maybe there is a way around this. Can you tell me what method you are trying to use and what you want to achieve?
     
  3. Offline

    Irantwomiles

    No, so let me explain. I'm working on a team/faction plugin and I want to load all of the teams in on onEnable instead of constantly reading and writing from the file. So I store the members/leaders etc UUID in the config and use Bukkits method of turning uuid into player. but my problem is that if the player is not online when the server reloads (which will be 99% of the time) it will throw an error saying that player is null. The solution to that is to you offline player instead, but I dont want to/know how to make it so it works with both offlineplayer and regular player.
     
  4. Offline

    Zombie_Striker

    @Irantwomiles
    'Regular players' extends offline players, so you should store all the players as Offline players. When you want to turn the offline players to players, use OfflinePlayer.isOnline()
     
  5. Offline

    Irantwomiles

    So I should change my team creation method to offlineplayer?
     
  6. Offline

    Zombie_Striker

  7. Offline

    Irantwomiles

    Ok, I'll try that. Thanks for your help!
     
  8. Offline

    Zombie_Striker

    @Irantwomiles
    If your problem has been solved, mark this thread as solved.
     
    Irantwomiles likes this.
  9. Offline

    Irantwomiles

    I dont want to mark it solved just yet. I'm going to test this tomorrow and if it works I'll mark it solved.
     
Thread Status:
Not open for further replies.

Share This Page