From ad47108567c79ec79a0224edb2578a045b695d40 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 23 Jul 2013 01:30:21 +1200 Subject: [PATCH] Allowed .equals() to be used on disguises and watcher --- .../libraryaddict/disguise/DisguiseTypes/FlagWatcher.java | 4 ++++ .../libraryaddict/disguise/DisguiseTypes/MobDisguise.java | 6 +++++- .../disguise/DisguiseTypes/PlayerDisguise.java | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java b/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java index 7bfad4c6..4e705205 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/FlagWatcher.java @@ -38,6 +38,10 @@ public class FlagWatcher { this.disguise = disguise; } + public boolean equals(FlagWatcher flagWatcher) { + return entityValues.equals(flagWatcher.entityValues); + } + public FlagWatcher clone() { FlagWatcher cloned = new FlagWatcher(disguise); cloned.entityValues = (HashMap) entityValues.clone(); diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/MobDisguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/MobDisguise.java index 1060f01d..6c9c2bfd 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/MobDisguise.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/MobDisguise.java @@ -21,13 +21,17 @@ public class MobDisguise extends Disguise { return disguise; } + public boolean equals(MobDisguise mobDisguise) { + return isAdult == mobDisguise.isAdult && this.equals(mobDisguise); + } + public boolean isAdult() { if (getWatcher() != null) { if (getWatcher() instanceof AgeableWatcher) return ((AgeableWatcher) getWatcher()).isAdult(); else if (getWatcher() instanceof ZombieWatcher) return ((ZombieWatcher) getWatcher()).isAdult(); - return isAdult; + return false; } return isAdult; } diff --git a/src/me/libraryaddict/disguise/DisguiseTypes/PlayerDisguise.java b/src/me/libraryaddict/disguise/DisguiseTypes/PlayerDisguise.java index 2768e8dd..a7daa2b6 100644 --- a/src/me/libraryaddict/disguise/DisguiseTypes/PlayerDisguise.java +++ b/src/me/libraryaddict/disguise/DisguiseTypes/PlayerDisguise.java @@ -19,6 +19,10 @@ public class PlayerDisguise extends Disguise { return disguise; } + public boolean equals(PlayerDisguise playerDisguise) { + return getName().equals(playerDisguise.getName()) && this.equals(playerDisguise); + } + public String getName() { return playerName; }