Add RabbitType

This commit is contained in:
libraryaddict 2014-09-27 15:50:38 +12:00
parent 66a454c6f4
commit fb09d93136
3 changed files with 44 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import java.util.HashMap;
import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.AnimalColor;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.RabbitType;
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.BaseDisguiseCommand; import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
@ -116,6 +117,8 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
} }
enumHelp.add(new EnumHelp("Direction", "Directions", ChatColor.RED + "/disguisehelp Directions " + ChatColor.GREEN enumHelp.add(new EnumHelp("Direction", "Directions", ChatColor.RED + "/disguisehelp Directions " + ChatColor.GREEN
+ "- View the five directions usable on player setsleeping disguise", Arrays.copyOf(BlockFace.values(), 5))); + "- View the five directions usable on player setsleeping disguise", Arrays.copyOf(BlockFace.values(), 5)));
enumHelp.add(new EnumHelp("RabbitType", "RabbitType", ChatColor.RED + "/disguisehelp RabbitType " + ChatColor.GREEN
+ "View the kinds of rabbits you can turn into", RabbitType.values()));
} }
@Override @Override

View File

@ -0,0 +1,23 @@
package me.libraryaddict.disguise.disguisetypes;
public enum RabbitType {
BLACK(2), BLACK_AND_WHITE(3), BROWN(0), GOLD(4), KILLER_BUNNY(99), PEPPER(5), WHITE(1);
public static RabbitType getType(int id) {
for (RabbitType type : values()) {
if (type.getTypeId() == id) {
return type;
}
}
return null;
}
private int type;
private RabbitType(int type) {
this.type = type;
}
public int getTypeId() {
return type;
}
}

View File

@ -15,6 +15,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.MiscDisguise; import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
import me.libraryaddict.disguise.disguisetypes.MobDisguise; import me.libraryaddict.disguise.disguisetypes.MobDisguise;
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
import me.libraryaddict.disguise.disguisetypes.RabbitType;
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion; import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -583,11 +584,26 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
} else if (param == BlockFace.class) { } else if (param == BlockFace.class) {
try { try {
BlockFace face = BlockFace.valueOf(valueString.toUpperCase()); BlockFace face = BlockFace.valueOf(valueString.toUpperCase());
if (face.ordinal() > 3) if (face.ordinal() > 4)
throw new DisguiseParseException(); throw new DisguiseParseException();
value = face; value = face;
} catch (Exception ex) { } catch (Exception ex) {
throw parseToException("a direction (north, east, south, west)", valueString, methodName); throw parseToException("a direction (north, east, south, west, up)", valueString, methodName);
}
} else if (param == RabbitType.class) {
try {
for (RabbitType type : RabbitType.values()) {
if (type.name().replace("_", "")
.equalsIgnoreCase(valueString.replace("_", "").replace(" ", ""))) {
value = type;
break;
}
}
if (value == null) {
throw new Exception();
}
} catch (Exception ex) {
throw parseToException("rabbit type (white, brown, salt and pepper...)", valueString, methodName);
} }
} }
} }