From d66630460e24337d177683a99002a4167f1fac96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pani=C4=87?= Date: Sun, 7 Apr 2019 23:33:20 +0200 Subject: Added UUID support in commands --- .../bungeeBans/commands/GetBanCommand.java | 37 +++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'src/main/java/com/redstoner/bungeeBans/commands/GetBanCommand.java') diff --git a/src/main/java/com/redstoner/bungeeBans/commands/GetBanCommand.java b/src/main/java/com/redstoner/bungeeBans/commands/GetBanCommand.java index 5ff213a..f63fd74 100644 --- a/src/main/java/com/redstoner/bungeeBans/commands/GetBanCommand.java +++ b/src/main/java/com/redstoner/bungeeBans/commands/GetBanCommand.java @@ -26,22 +26,43 @@ public class GetBanCommand extends Command { new ComponentBuilder(ChatColor.RED + "Invalid command! ") .append("Usage: ") .append(ChatColor.AQUA + "/getban ") - .append(ChatColor.GOLD + " ") + .append(ChatColor.GOLD + " ") .create() ); return; } - Profile[] profiles = Util.findProfilesByNames(args[0]); + String uuid; + String name; - if (profiles.length != 1) { - sender.sendMessage(new TextComponent(ChatColor.RED + "Invalid name!")); - return; - } + if (Util.validateUUID(args[0])) { + uuid = args[0]; + + try { + Util.NameChange[] nameChanges = Util.findNameChangesByUUID(uuid); + + if (nameChanges.length == 0) { + sender.sendMessage(new TextComponent(ChatColor.RED + "Invalid UUID!")); + return; + } - String uuid = Util.dashUUID(profiles[0].getId()); - String name = profiles[0].getName(); + name = nameChanges[nameChanges.length - 1].name; + } catch (Util.MojangException e) { + sender.sendMessage(new TextComponent(ChatColor.RED + e.getMessage())); + return; + } + } else { + Profile[] profiles = Util.findProfilesByNames(args[0]); + + if (profiles.length != 1) { + sender.sendMessage(new TextComponent(ChatColor.RED + "Invalid name!")); + return; + } + + uuid = Util.dashUUID(profiles[0].getId()); + name = profiles[0].getName(); + } PlayerBan ban = bm.getBan(uuid); -- cgit v1.2.3