From 95b3d9f23152512464e70a3e4b7daac5564f7a92 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 17 Jan 2022 10:40:40 +1300 Subject: [PATCH] Fix potential issue --- .../disguise/utilities/DisguiseUtilities.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 37d47c70..aa8f1f57 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -2091,14 +2091,17 @@ public class DisguiseUtilities { if (playerName == null || !playerName.startsWith(namePrefix)) { String nameSuffix = "" + ChatColor.RESET; + int maxLength = namePrefix.length() + nameSuffix.length(); for (int i = 0; i < 1000; i++) { - String testName = namePrefix + colorize(encode(getRandom().nextInt(Integer.MAX_VALUE))) + nameSuffix; + String tName = colorize(encode(getRandom().nextInt(Integer.MAX_VALUE))); - if (testName.length() > 16) { - break; + if (tName.length() > maxLength) { + tName = tName.substring(0, maxLength); } + String testName = namePrefix + tName + nameSuffix; + if (!isValidPlayerName(board, testName)) { continue; }