Fixed 1.7 UUID, oops. Thanks @MineTheCube

This commit is contained in:
Myles 2016-11-15 21:17:39 +00:00
parent b15c93c416
commit ff1554556e

View File

@ -114,9 +114,9 @@ public class BaseProtocol extends Protocol {
info.setState(State.PLAY);
// Save other info
String stringUUID = wrapper.get(Type.STRING, 0);
if (stringUUID.length() == 28) {
if (stringUUID.length() == 32) { // Trimmed UUIDs are 32 characters
// Trimmed
stringUUID = stringUUID.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5");
stringUUID = addDashes(stringUUID);
}
UUID uuid = UUID.fromString(stringUUID);
info.setUuid(uuid);
@ -237,4 +237,13 @@ public class BaseProtocol extends Protocol {
}
}
}
public static String addDashes(String trimmedUUID) {
StringBuffer idBuff = new StringBuffer(trimmedUUID);
idBuff.insert(20, '-');
idBuff.insert(16, '-');
idBuff.insert(12, '-');
idBuff.insert(8, '-');
return idBuff.toString();
}
}