Try make scoreboard names a bit more unique
This commit is contained in:
parent
0ec2dab889
commit
b5fb5054a2
@ -1394,7 +1394,9 @@ public class DisguiseUtilities {
|
||||
// Gotta register all the flag watcher stuff before I make this one
|
||||
gsonBuilder.registerTypeAdapter(FlagWatcher.class, new SerializerFlagWatcher(gsonBuilder.create()));
|
||||
gsonBuilder.registerTypeAdapter(Disguise.class, new SerializerDisguise());
|
||||
gsonBuilder.registerTypeAdapter(Optional.class, (JsonSerializer<Optional>) (optional, type, jsonSerializationContext) -> jsonSerializationContext.serialize("<optional>(" + jsonSerializationContext.serialize(optional.orElse(null)) + ")"));
|
||||
gsonBuilder.registerTypeAdapter(Optional.class,
|
||||
(JsonSerializer<Optional>) (optional, type, jsonSerializationContext) -> jsonSerializationContext.serialize(
|
||||
"<optional>(" + jsonSerializationContext.serialize(optional.orElse(null)) + ")"));
|
||||
|
||||
gson = gsonBuilder.create();
|
||||
|
||||
@ -1902,14 +1904,12 @@ public class DisguiseUtilities {
|
||||
Scoreboard mainBoard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
String teamName = encode(System.nanoTime() / 100 % 100000) + "";
|
||||
String teamName = prefix + encode(getRandom().nextLong());
|
||||
|
||||
if (teamName.length() > 13) {
|
||||
teamName = teamName.substring(teamName.length() - 13);
|
||||
if (teamName.length() > 16) {
|
||||
teamName = teamName.substring(0, 16);
|
||||
}
|
||||
|
||||
teamName = prefix + teamName;
|
||||
|
||||
if (mainBoard.getTeam(teamName) != null) {
|
||||
continue;
|
||||
}
|
||||
@ -2091,10 +2091,9 @@ public class DisguiseUtilities {
|
||||
|
||||
if (playerName == null || !playerName.startsWith(namePrefix)) {
|
||||
String nameSuffix = "" + ChatColor.RESET;
|
||||
long time = System.nanoTime() / 100 % 10000;
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
String testName = namePrefix + colorize(encode(time + i)) + nameSuffix;
|
||||
String testName = namePrefix + colorize(encode(getRandom().nextInt(Integer.MAX_VALUE))) + nameSuffix;
|
||||
|
||||
if (testName.length() > 16) {
|
||||
break;
|
||||
@ -2585,8 +2584,9 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
public static void sendProtocolLibUpdateMessage(CommandSender p, String version, String requiredProtocolLib) {
|
||||
p.sendMessage(ChatColor.RED + "Please ask the server owner to update ProtocolLib! You are running " + version +
|
||||
" but the minimum version you should be on is " + requiredProtocolLib + "!");
|
||||
p.sendMessage(
|
||||
ChatColor.RED + "Please ask the server owner to update ProtocolLib! You are running " + version + " but the minimum version you should be on is " +
|
||||
requiredProtocolLib + "!");
|
||||
p.sendMessage(ChatColor.RED + "https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" + "/ProtocolLib" + ".jar");
|
||||
p.sendMessage(ChatColor.RED + "Or! Use " + ChatColor.DARK_RED + "/ld updatepl" + ChatColor.RED + " - To update to the latest development build");
|
||||
p.sendMessage(ChatColor.DARK_GREEN + "This message is `kindly` provided by Lib's Disguises on repeat to all players due to the sheer " +
|
||||
@ -2745,8 +2745,8 @@ public class DisguiseUtilities {
|
||||
|
||||
throw new IllegalArgumentException("Unable to find Serializer for " + value +
|
||||
(value instanceof Optional && ((Optional) value).isPresent() ? " (" + ((Optional) value).get().getClass().getName() + ")" :
|
||||
value instanceof Optional || value == null ? "" : " " + value.getClass().getName()) + "! Are you running " + "the latest " +
|
||||
"version of " + "ProtocolLib?");
|
||||
value instanceof Optional || value == null ? "" : " " + value.getClass().getName()) + "! Are you running " + "the latest " + "version of " +
|
||||
"ProtocolLib?");
|
||||
}
|
||||
|
||||
public static String serialize(NbtBase base) {
|
||||
@ -2966,8 +2966,9 @@ public class DisguiseUtilities {
|
||||
name = ChatColor.translateAlternateColorCodes('&', newNames[i]);
|
||||
}
|
||||
|
||||
WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager.createDataWatcherObject(
|
||||
NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD, name);
|
||||
WrappedDataWatcher.WrappedDataWatcherObject obj =
|
||||
ReflectionManager.createDataWatcherObject(NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD,
|
||||
name);
|
||||
|
||||
watcher.setObject(obj, ReflectionManager.convertInvalidMeta(name));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user