diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java b/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java index b1162f445..15d39a3dc 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/base/BaseProtocol.java @@ -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(); + } }