Solved How to check if string is a player

Discussion in 'Spigot Plugin Development' started by Lifeonblack, May 17, 2017.

  1. How to check if a string playername is a player or not?
    do I have to check it using
    Code (Java):
    Bukkit.getOfflinePlayers().equals(String name);
    • Winner Winner x 1
  2. Online: call Bukkit::getPlayer(String) and check if it doesn't return null
    Offline: call Bukkit::getOfflinePlayer(String) and check whether its UUID isn't null (online-mode=true) or iterate over the offline players and compare named (online-mode=false, doesn't guarantee there isn't a player with the name though, since cracked servers accept anyone).

    Please do note that checking offline players is a [likely] heavy operation, and should be done asynchronously.
    • Useful Useful x 1
  3. alright got it thank you for your help