Implement API for dealing with player UUIDs. Adds BUKKIT-5071

This commit is contained in:
Travis Watkins
2014-03-28 23:48:15 -05:00
parent acc9f20b00
commit 21e7ba8d22
3 changed files with 101 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import java.io.File;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import net.minecraft.server.BanEntry;
import net.minecraft.server.EntityPlayer;
@@ -41,6 +42,20 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
return name;
}
// TODO: In 1.7.6+ OfflinePlayer lookup should be by UUID and store it like it does the name now
public UUID getUniqueId() {
NBTTagCompound data = getData();
if (data == null) {
return null;
}
if (data.hasKeyOfType("UUIDMost", 4) && data.hasKeyOfType("UUIDLeast", 4)) {
return new UUID(data.getLong("UUIDMost"), data.getLong("UUIDLeast"));
}
return null;
}
public Server getServer() {
return server;
}