Add RabbitType
This commit is contained in:
		| @@ -9,6 +9,7 @@ import java.util.HashMap; | ||||
| import me.libraryaddict.disguise.disguisetypes.AnimalColor; | ||||
| import me.libraryaddict.disguise.disguisetypes.DisguiseType; | ||||
| import me.libraryaddict.disguise.disguisetypes.FlagWatcher; | ||||
| import me.libraryaddict.disguise.disguisetypes.RabbitType; | ||||
| import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; | ||||
| 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 | ||||
|                 + "- 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 | ||||
|   | ||||
							
								
								
									
										23
									
								
								src/me/libraryaddict/disguise/disguisetypes/RabbitType.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/me/libraryaddict/disguise/disguisetypes/RabbitType.java
									
									
									
									
									
										Normal 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; | ||||
|     } | ||||
| } | ||||
| @@ -15,6 +15,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher; | ||||
| import me.libraryaddict.disguise.disguisetypes.MiscDisguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.MobDisguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; | ||||
| import me.libraryaddict.disguise.disguisetypes.RabbitType; | ||||
| import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion; | ||||
|  | ||||
| import org.bukkit.ChatColor; | ||||
| @@ -583,11 +584,26 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { | ||||
|                         } else if (param == BlockFace.class) { | ||||
|                             try { | ||||
|                                 BlockFace face = BlockFace.valueOf(valueString.toUpperCase()); | ||||
|                                 if (face.ordinal() > 3) | ||||
|                                 if (face.ordinal() > 4) | ||||
|                                     throw new DisguiseParseException(); | ||||
|                                 value = face; | ||||
|                             } 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); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user