diff --git a/Launcher/runtime/dialog/dialog.fxml b/Launcher/runtime/dialog/dialog.fxml index 1f7a49d..91fd239 100755 --- a/Launcher/runtime/dialog/dialog.fxml +++ b/Launcher/runtime/dialog/dialog.fxml @@ -5,11 +5,9 @@ - - diff --git a/Launcher/runtime/dialog/profileCell.fxml b/Launcher/runtime/dialog/profileCell.fxml index 1f5ca69..6945e7d 100755 --- a/Launcher/runtime/dialog/profileCell.fxml +++ b/Launcher/runtime/dialog/profileCell.fxml @@ -1,10 +1,9 @@ + - - diff --git a/compat/auth/uuid/ReversibleUUIDs.java b/compat/auth/uuid/ReversibleUUIDs.java new file mode 100644 index 0000000..137704f --- /dev/null +++ b/compat/auth/uuid/ReversibleUUIDs.java @@ -0,0 +1,19 @@ +public static UUID toUUID(String username) { + ByteBuffer buffer = ByteBuffer.wrap(Arrays.copyOf(username.getBytes(StandardCharsets.US_ASCII), 16)); + return new UUID(buffer.getLong(), buffer.getLong()); // MOST, LEAST +} + +public static String toUsername(UUID uuid) { + byte[] bytes = ByteBuffer.allocate(16). + putLong(uuid.getMostSignificantBits()). + putLong(uuid.getLeastSignificantBits()).array(); + + // Find username end + int length = 0; + while(length < bytes.length && bytes[length] != 0) { + length++; + } + + // Decode and verify + return VerifyHelper.verifyUsername(new String(bytes, 0, length, StandardCharsets.US_ASCII)); +} \ No newline at end of file diff --git a/compat/auth/uuid/uuidgen.sql b/compat/auth/uuid/uuidgen.sql new file mode 100644 index 0000000..8c8e726 --- /dev/null +++ b/compat/auth/uuid/uuidgen.sql @@ -0,0 +1,8 @@ +DELIMITER // +CREATE TRIGGER setUUID BEFORE INSERT ON users +FOR EACH ROW BEGIN + IF NEW.uuid IS NULL THEN + SET NEW.uuid = UUID(); + END IF; +END; // +DELIMITER ; \ No newline at end of file diff --git a/compat/auth/uuid/uuidgen_offline.sql b/compat/auth/uuid/uuidgen_offline.sql new file mode 100644 index 0000000..608635d --- /dev/null +++ b/compat/auth/uuid/uuidgen_offline.sql @@ -0,0 +1,11 @@ +-- WARNING! Usage of this generation method is NOT recommended + +DELIMITER // +CREATE TRIGGER setUUID BEFORE INSERT ON users +FOR EACH ROW BEGIN + IF NEW.uuid IS NULL THEN + SET @md5 = MD5(CONCAT("OfflinePlayer:", NEW.username)); + SET NEW.uuid = CONCAT_WS('-', LEFT(@md5, 8), MID(@md5, 9, 4), MID(@md5, 13, 4), MID(@md5, 17, 4), RIGHT(@md5, 12)); + END IF; +END; // +DELIMITER ; \ No newline at end of file