From 407975f41f98dbe8b9350477b0a26ecee21baf20 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 22 Jun 2020 19:39:02 +1200 Subject: [PATCH] Actually fix multi names --- .../libraryaddict/disguise/disguisetypes/Disguise.java | 9 +++++++-- .../disguise/utilities/DisguiseUtilities.java | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java index 579260f0..10a8fd73 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -77,7 +77,7 @@ public abstract class Disguise { @Getter private BarStyle bossBarStyle = DisguiseConfig.getBossBarStyle(); @Getter(value = AccessLevel.PRIVATE) - private transient final NamespacedKey bossBar = new NamespacedKey(LibsDisguises.getInstance(), UUID.randomUUID().toString()); + private final NamespacedKey bossBar = new NamespacedKey(LibsDisguises.getInstance(), UUID.randomUUID().toString()); private FlagWatcher watcher; /** * If set, how long before disguise expires @@ -114,7 +114,7 @@ public abstract class Disguise { } public int getMultiNameLength() { - return multiName == null ? 0 : multiName.length; + return multiName.length; } @RandomDefaultValue @@ -1090,6 +1090,11 @@ public abstract class Disguise { throw new IllegalStateException("No entity is assigned to this disguise!"); } + // Fix for old LD updates to new LD where gson hates missing fields + if (multiName == null) { + multiName = new String[0]; + } + if (LibsPremium.getUserID().equals("123" + "45") || !LibsMsg.OWNED_BY.getRaw().contains("'")) { ((TargetedDisguise) this).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS); diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index c1645da2..dd7d8547 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -1788,6 +1788,10 @@ public class DisguiseUtilities { } public static String[] reverse(String[] array) { + if (array == null) { + return new String[0]; + } + String[] newArray = new String[array.length]; for (int i = 1; i <= array.length; i++) {