From 42f04766b1cadf851d282461471768e67e69ff65 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 23 May 2021 10:17:46 +1200 Subject: [PATCH] Do uuid version 3 warning --- .../disguise/commands/utils/GrabHeadCommand.java | 1 + .../disguise/commands/utils/GrabSkinCommand.java | 1 + .../commands/utils/SaveDisguiseCommand.java | 14 ++++++++------ .../disguise/utilities/DisguiseUtilities.java | 16 ++++++++++++++++ .../disguise/utilities/translations/LibsMsg.java | 5 ++--- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/commands/utils/GrabHeadCommand.java b/src/main/java/me/libraryaddict/disguise/commands/utils/GrabHeadCommand.java index 2e489399..5361912e 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/utils/GrabHeadCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/utils/GrabHeadCommand.java @@ -80,6 +80,7 @@ public class GrabHeadCommand implements CommandExecutor { @Override public void onSuccess(WrappedGameProfile profile) { runnable.cancel(); + DisguiseUtilities.doSkinUUIDWarning(sender); DisguiseUtilities.setGrabHeadCommandUsed(); diff --git a/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java b/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java index 547b75c7..f5561557 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/utils/GrabSkinCommand.java @@ -90,6 +90,7 @@ public class GrabSkinCommand implements CommandExecutor { @Override public void onSuccess(WrappedGameProfile profile) { runnable.cancel(); + DisguiseUtilities.doSkinUUIDWarning(sender); String nName = name; diff --git a/src/main/java/me/libraryaddict/disguise/commands/utils/SaveDisguiseCommand.java b/src/main/java/me/libraryaddict/disguise/commands/utils/SaveDisguiseCommand.java index 0fb1c9b7..91db6733 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/utils/SaveDisguiseCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/utils/SaveDisguiseCommand.java @@ -30,7 +30,9 @@ public class SaveDisguiseCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) { if (sender instanceof Player && !sender.isOp() && (!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) { - sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!"); + sender.sendMessage(ChatColor.RED + + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " + + "non-admin usage!"); return true; } @@ -68,8 +70,7 @@ public class SaveDisguiseCommand implements CommandExecutor { DisguiseAPI.addCustomDisguise(name, disguiseString); LibsMsg.CUSTOM_DISGUISE_SAVED.send(sender, name); - } - catch (DisguiseParseException e) { + } catch (DisguiseParseException e) { if (e.getMessage() != null) { DisguiseUtilities.sendMessage(sender, e.getMessage()); } else { @@ -85,8 +86,9 @@ public class SaveDisguiseCommand implements CommandExecutor { int i = 2; for (; i < args.length; i++) { - if (!args[i].equalsIgnoreCase("setskin")) + if (!args[i].equalsIgnoreCase("setskin")) { continue; + } break; } @@ -138,6 +140,7 @@ public class SaveDisguiseCommand implements CommandExecutor { @Override public void onSuccess(WrappedGameProfile profile) { runnable.cancel(); + DisguiseUtilities.doSkinUUIDWarning(sender); finalArgs[skinId] = DisguiseUtilities.getGson().toJson(profile); @@ -166,8 +169,7 @@ public class SaveDisguiseCommand implements CommandExecutor { LibsMsg.CUSTOM_DISGUISE_SAVED.send(sender, name); DisguiseUtilities.setSaveDisguiseCommandUsed(); - } - catch (DisguiseParseException e) { + } catch (DisguiseParseException e) { if (e.getMessage() != null) { DisguiseUtilities.sendMessage(sender, e.getMessage()); } else { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index f0c7c21f..1862c939 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -196,6 +196,7 @@ public class DisguiseUtilities { private final static ConcurrentHashMap teams = new ConcurrentHashMap<>(); private final static boolean java16; private static boolean criedOverJava16; + private static HashSet warnedSkin = new HashSet<>(); static { final Matcher matcher = Pattern.compile("(?:1\\.)?(\\d+)").matcher(System.getProperty("java.version")); @@ -214,6 +215,21 @@ public class DisguiseUtilities { } } + public static void doSkinUUIDWarning(CommandSender sender) { + if (!(sender instanceof Player)) { + return; + } + + UUID uuid = ((Player) sender).getUniqueId(); + + if (uuid.version() == 4 || warnedSkin.contains(uuid)) { + return; + } + + warnedSkin.add(uuid); + LibsMsg.SKIN_API_UUID_3.send(sender); + } + /** * Only allow saves every 2 minutes */ diff --git a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java index 6da72de6..76373660 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/translations/LibsMsg.java @@ -198,9 +198,8 @@ public enum LibsMsg { COPY_DISGUISE_NO_COPY(ChatColor.GREEN + "Data: " + ChatColor.YELLOW + "%s"), CLICK_TO_COPY_HOVER(ChatColor.GOLD + "Click to Copy"), CLICK_COPY(ChatColor.YELLOW + "" + ChatColor.BOLD + "%s"), - SKIN_API_UUID_3(ChatColor.RED + - "You seem to be using a Minecraft account with an UUID version of 3. If the skin is not as expected, you can change 'UUIDVersion' in protocol.yml" + - " to 3 which may fix this. If you are using a Minecraft account that was not purchased, then there is nothing further we can do to fix this."), + SKIN_API_UUID_3(ChatColor.RED + "Using account with UUID version 3. If skin is incorrect, try change 'UUIDVersion' in protocol.yml" + + " to 3. If skin is still incorrect and you did not purchase Minecraft, this cannot be fixed."), SKIN_API_IN_USE(ChatColor.RED + "mineskin.org is currently in use, please try again"), SKIN_API_TIMER(ChatColor.RED + "mineskin.org can be used again in %s seconds"), SKIN_API_FAIL(ChatColor.RED + "Unexpected error while accessing mineskin.org, please try again"),