Changed the disguisetype fetching to try without _ as well
This commit is contained in:
parent
d84121c4eb
commit
09e353213e
@ -66,10 +66,14 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
sendCommandUsage(sender);
|
||||
throw new Exception();
|
||||
}
|
||||
DisguiseType disguiseType;
|
||||
try {
|
||||
disguiseType = DisguiseType.valueOf(args[0].toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
DisguiseType disguiseType = null;
|
||||
for (DisguiseType type : DisguiseType.values()) {
|
||||
if (args[0].equalsIgnoreCase(type.name()) || type.name().replace("_", "").equalsIgnoreCase(args[0])) {
|
||||
disguiseType = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (disguiseType == null) {
|
||||
throw new Exception(ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + args[0] + ChatColor.RED
|
||||
+ " doesn't exist!");
|
||||
}
|
||||
|
@ -32,41 +32,43 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
||||
// sender.sendMessage(ChatColor.RED + "/disguisehelp <Disguise> <Option>");
|
||||
} else {
|
||||
DisguiseType type = null;
|
||||
try {
|
||||
type = DisguiseType.valueOf(args[0].toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
for (DisguiseType disguiseType : DisguiseType.values()) {
|
||||
if (args[0].equalsIgnoreCase(disguiseType.name())
|
||||
|| disguiseType.name().replace("_", "").equalsIgnoreCase(args[0])) {
|
||||
type = disguiseType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (type == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Cannot find the disguise " + args[0]);
|
||||
return true;
|
||||
}
|
||||
if (type != null) {
|
||||
ArrayList<String> methods = new ArrayList<String>();
|
||||
Class watcher = type.getWatcherClass();
|
||||
try {
|
||||
for (Method method : watcher.getMethods()) {
|
||||
if (!method.getName().startsWith("get") && method.getParameterTypes().length == 1) {
|
||||
Class c = method.getParameterTypes()[0];
|
||||
String valueType = null;
|
||||
if (c == String.class)
|
||||
valueType = "String";
|
||||
else if (boolean.class == c)
|
||||
valueType = "True/False";
|
||||
else if (float.class == c || double.class == c || int.class == c) {
|
||||
valueType = "Number";
|
||||
}
|
||||
if (valueType != null) {
|
||||
methods.add(ChatColor.RED + method.getName() + ChatColor.DARK_RED + " ("
|
||||
+ ChatColor.GREEN + valueType + ChatColor.DARK_RED + ")");
|
||||
}
|
||||
ArrayList<String> methods = new ArrayList<String>();
|
||||
Class watcher = type.getWatcherClass();
|
||||
try {
|
||||
for (Method method : watcher.getMethods()) {
|
||||
if (!method.getName().startsWith("get") && method.getParameterTypes().length == 1) {
|
||||
Class c = method.getParameterTypes()[0];
|
||||
String valueType = null;
|
||||
if (c == String.class)
|
||||
valueType = "String";
|
||||
else if (boolean.class == c)
|
||||
valueType = "True/False";
|
||||
else if (float.class == c || double.class == c || int.class == c) {
|
||||
valueType = "Number";
|
||||
}
|
||||
if (valueType != null) {
|
||||
methods.add(ChatColor.RED + method.getName() + ChatColor.DARK_RED + " (" + ChatColor.GREEN
|
||||
+ valueType + ChatColor.DARK_RED + ")");
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
Collections.sort(methods, String.CASE_INSENSITIVE_ORDER);
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Options: "
|
||||
+ StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
Collections.sort(methods, String.CASE_INSENSITIVE_ORDER);
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Options: " + StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user