1.15.2 Whitelist Problems

Discussion in 'Spigot Plugin Development' started by konsyr11, Feb 11, 2020.

Thread Status:
Not open for further replies.
  1. Hello! I have been trying to develop a whitelist plugin and I am running into a problem. You see, I have a source populating a Java arraylist, with some usernames. However, when I do player.setWhitelist(true); I get an error that player needs to be a Player object (while it is a String). Then, I tried converting the string to Player using
    Player p = Bukkit.getServer().getPlayer(player); and then continuing with the above setWhitelist, but I am getting a null exception. I have no idea what to do next, and after a lot of searching, Google knows nothing either. Any help appreciated! Thanks in advance!
     
  2. DevSnx

    DevSnx Previously Snx

    maybe offlineplayer?
     
  3. It needs UUID, if I try to use the simple username version it gives error. Also I think that OfflinePlayer with username instead of UUID is for players who have already joined once.
     
  4. DevSnx

    DevSnx Previously Snx

  5. upload_2020-2-11_20-7-27.png
    upload_2020-2-11_20-7-46.png
    And it asks for Player... OfflinePlayer does not work with UUID either...
    Bukkit.getPlayer(uuid); returns NullPointer too...
     
  6. DevSnx

    DevSnx Previously Snx

    hmh?
     
  7. upload_2020-2-11_20-16-28.png
    This is what I am getting...
     
  8. I found the way to do it!
    For future reference:
    Bukkit.getServer().getOfflinePlayer(<username>).setWhitelisted(true);
    Note: getOfflinePlayer will be strikethrough but will not show an error. Also do not forget to reload the whitelist once done!
     
Thread Status:
Not open for further replies.