From e9a968fe7b871299fef7a672230e007db6ad878e Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 20 Apr 2020 22:00:51 +1200 Subject: [PATCH] Fix potential issue with wrong disguise parameter --- .../me/libraryaddict/disguise/disguisetypes/Disguise.java | 5 +++-- .../me/libraryaddict/disguise/disguisetypes/FlagWatcher.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java index 5e84baf1..f0425352 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -563,8 +563,9 @@ public abstract class Disguise { @Deprecated public Disguise setWatcher(FlagWatcher newWatcher) { if (!getType().getWatcherClass().isInstance(newWatcher)) { - throw new IllegalArgumentException(newWatcher.getClass().getSimpleName() + " is not a instance of " + - getType().getWatcherClass().getSimpleName() + " for DisguiseType " + getType().name()); + throw new IllegalArgumentException( + (newWatcher == null ? "null" : newWatcher.getClass().getSimpleName()) + " is not a instance of " + + getType().getWatcherClass().getSimpleName() + " for DisguiseType " + getType().name()); } watcher = newWatcher; diff --git a/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index 18dc3f8e..5617ed07 100644 --- a/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/src/main/java/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -69,11 +69,11 @@ public class FlagWatcher { FlagWatcher cloned; try { - cloned = getClass().getConstructor(Disguise.class).newInstance(getDisguise()); + cloned = getClass().getConstructor(Disguise.class).newInstance(owningDisguise); } catch (Exception e) { e.printStackTrace(); - cloned = new FlagWatcher(getDisguise()); + cloned = new FlagWatcher(owningDisguise); } cloned.entityValues = (HashMap) entityValues.clone();