Fix potential issue

This commit is contained in:
libraryaddict 2022-01-17 10:40:40 +13:00
parent b5fb5054a2
commit 95b3d9f231

View File

@ -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;
}