uuid formatting

master
Alex 2021-12-29 14:31:31 +01:00
parent 8aa6d60f2f
commit c0dd200e24
2 changed files with 22 additions and 3 deletions

View File

@ -0,0 +1,18 @@
package earth.krakatao;
import java.math.BigInteger;
import java.util.UUID;
public class Formatter {
public static String formatUuid(String uuid) {
return uuid.replaceAll("-", "");
}
public static UUID stringToUuid(String s) {
BigInteger bigInteger = new BigInteger(s.substring(0, 16), 16);
BigInteger bigInteger1 = new BigInteger(s.substring(16, 32), 16);
return new UUID(bigInteger.longValue(), bigInteger1.longValue());
}
}

View File

@ -1,6 +1,8 @@
package earth.krakatao.protocol;
import earth.krakatao.Formatter;
import earth.krakatao.KraSocketClient;
import earth.krakatao.SocketClient;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
@ -54,7 +56,7 @@ public class KraSocketClientProtocol {
raw[5] = (byte) dest;
byte[] uuidBytes = uuid.getBytes();
byte[] uuidBytes = Formatter.formatUuid(uuid).getBytes();
/* for (int i = 0; i < 32; i++) {
raw[6 + i] = uuidBytes[i];
@ -114,7 +116,6 @@ public class KraSocketClientProtocol {
KraSocketClient.getLogger().info( "decoded message " + status + " " + cmdID + " " + dest + " " + playerUuid + " "
+ cmdNumber + " " + args + " ");
return new KraSocketClientProtocolMessage(status, cmdID, dest, playerUuid, cmdNumber, args);
return new KraSocketClientProtocolMessage(status, cmdID, dest, Formatter.stringToUuid(playerUuid).toString(), cmdNumber, args);
}
}