Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 74 lines 2.2 kB view raw
1package com.projectposeidon.api; 2 3import com.projectposeidon.johnymuffin.UUIDManager; 4 5import java.util.UUID; 6 7public final class PoseidonUUID { 8 9 private PoseidonUUID() { 10 11 } 12 13 /** 14 * @param username Username of a player who has connected 15 * @return A Mojang UUID if known, otherwise null 16 */ 17 public static UUID getPlayerMojangUUID(String username) { 18 return UUIDManager.getInstance().getUUIDFromUsername(username, true); 19 } 20 21 /** 22 * @param username Username of a player who has connected 23 * @return A Mojang UUID if known, otherwise a offline uuid 24 */ 25 public static UUID getPlayerGracefulUUID(String username) { 26 return UUIDManager.getInstance().getUUIDGraceful(username); 27 } 28 29 /** 30 * Get a UUID of a player IF they have joined before. 31 * 32 * @param username Username of a player who has connected 33 * @param onlineUUID Search for online or offline UUIDs? 34 * @return Returns a UUID if known in cache, otherwise null 35 */ 36 public static UUID getPlayerUUIDFromCache(String username, boolean onlineUUID) { 37 return UUIDManager.getInstance().getUUIDFromUsername(username, onlineUUID); 38 39 } 40 41 /** 42 * @param username Username of a player 43 * @return A offline UUID for a player 44 */ 45 public static UUID getPlayerOfflineUUID(String username) { 46 return UUIDManager.generateOfflineUUID(username); 47 } 48 49 //TODO: Maybe return an enum for if the UUID is an offline 50 51 /** 52 * @param username Username of a player 53 * @return A boolean of if the player's UUID is known in the cache. Will return true if they have a graceful UUID. 54 */ 55 public static UUIDType getPlayerUUIDCacheStatus(String username) { 56 if (getPlayerUUIDFromCache(username, true) != null) { 57 return UUIDType.ONLINE; 58 } 59 if (getPlayerUUIDFromCache(username, false) != null) { 60 return UUIDType.OFFLINE; 61 } 62 return UUIDType.UNKNOWN; 63 } 64 65 /** 66 * @param uuid UUID for a player 67 * @return A corresponding UUID if known, otherwise null 68 */ 69 public static String getPlayerUsernameFromUUID(UUID uuid) { 70 return UUIDManager.getInstance().getUsernameFromUUID(uuid); 71 } 72 73 74}