From 3604c83797ef87f0b22e7976a3ea0d9ebbf3c1c8 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 14 May 2014 10:43:13 +1200 Subject: [PATCH] Ensure they use the right disguise for the disguisetype --- .../libraryaddict/disguise/disguisetypes/MiscDisguise.java | 5 +++++ .../libraryaddict/disguise/disguisetypes/MobDisguise.java | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java index 862ea150..4978f666 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.disguisetypes; +import java.security.InvalidParameterException; import java.util.Random; import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher; @@ -42,6 +43,10 @@ public class MiscDisguise extends TargetedDisguise { } 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); switch (disguiseType) { // The only disguises which should use a custom data. diff --git a/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java index 139221be..e1b3c3c5 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java @@ -1,5 +1,7 @@ package me.libraryaddict.disguise.disguisetypes; +import java.security.InvalidParameterException; + import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; @@ -14,6 +16,10 @@ public class MobDisguise extends TargetedDisguise { } 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; createDisguise(disguiseType); }