Fix potential issue with wrong disguise parameter

This commit is contained in:
libraryaddict 2020-04-20 22:00:51 +12:00
parent f1653c0bb0
commit e9a968fe7b
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
2 changed files with 5 additions and 4 deletions

View File

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

View File

@ -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<Integer, Object>) entityValues.clone();