Ensure they use the right disguise for the disguisetype

This commit is contained in:
libraryaddict 2014-05-14 10:43:13 +12:00
parent 8db338f533
commit 3604c83797
2 changed files with 11 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package me.libraryaddict.disguise.disguisetypes; package me.libraryaddict.disguise.disguisetypes;
import java.security.InvalidParameterException;
import java.util.Random; import java.util.Random;
import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher;
@ -42,6 +43,10 @@ public class MiscDisguise extends TargetedDisguise {
} }
public MiscDisguise(DisguiseType disguiseType, int id, int data) { public MiscDisguise(DisguiseType disguiseType, int id, int data) {
if (!disguiseType.isMisc()) {
throw new InvalidParameterException("Expected a non-living DisguiseType while constructing MiscDisguise. Received "
+ disguiseType + " instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") + " instead");
}
createDisguise(disguiseType); createDisguise(disguiseType);
switch (disguiseType) { switch (disguiseType) {
// The only disguises which should use a custom data. // The only disguises which should use a custom data.

View File

@ -1,5 +1,7 @@
package me.libraryaddict.disguise.disguisetypes; package me.libraryaddict.disguise.disguisetypes;
import java.security.InvalidParameterException;
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
@ -14,6 +16,10 @@ public class MobDisguise extends TargetedDisguise {
} }
public MobDisguise(DisguiseType disguiseType, boolean isAdult) { public MobDisguise(DisguiseType disguiseType, boolean isAdult) {
if (!disguiseType.isMob()) {
throw new InvalidParameterException("Expected a living DisguiseType while constructing MobDisguise. Received "
+ disguiseType + " instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MiscDisguise") + " instead");
}
this.isAdult = isAdult; this.isAdult = isAdult;
createDisguise(disguiseType); createDisguise(disguiseType);
} }