uuid formatting
parent
8aa6d60f2f
commit
c0dd200e24
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue