Skip to content

Commit

Permalink
Added support for malformed UUIDs (missing the dashes)
Browse files Browse the repository at this point in the history
  • Loading branch information
TechnicallyCoded committed Jun 8, 2022
1 parent b6d0038 commit 738641c
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,27 @@ private void openBackupMenu(CommandSender sender, Player staff, String[] args) {
} else if(args.length == 2) {
OfflinePlayer rollbackPlayer;

String uuidStr = args[1];

// Handle input of UUID
if (args[1].length() == 36) {
if (uuidStr.length() == 36 || args[1].length() == 32) {

// Handle malformed UUID
if (args[1].length() == 32) {
String oldUuidStr = uuidStr;
uuidStr = oldUuidStr.substring(0, 8);
uuidStr += "-";
uuidStr += oldUuidStr.substring(8, 12);
uuidStr += "-";
uuidStr += oldUuidStr.substring(12, 16);
uuidStr += "-";
uuidStr += oldUuidStr.substring(16, 20);
uuidStr += "-";
uuidStr += oldUuidStr.substring(20);
}

try {
rollbackPlayer = Bukkit.getOfflinePlayer(UUID.fromString(args[1]));
rollbackPlayer = Bukkit.getOfflinePlayer(UUID.fromString(uuidStr));
} catch (IllegalArgumentException e) {
sender.sendMessage(MessageData.getPluginPrefix() + MessageData.getError());
return;
Expand Down

0 comments on commit 738641c

Please sign in to comment.