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);
|
sendCommandUsage(sender);
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
DisguiseType disguiseType;
|
DisguiseType disguiseType = null;
|
||||||
try {
|
for (DisguiseType type : DisguiseType.values()) {
|
||||||
disguiseType = DisguiseType.valueOf(args[0].toUpperCase());
|
if (args[0].equalsIgnoreCase(type.name()) || type.name().replace("_", "").equalsIgnoreCase(args[0])) {
|
||||||
} catch (Exception ex) {
|
disguiseType = type;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (disguiseType == null) {
|
||||||
throw new Exception(ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + args[0] + ChatColor.RED
|
throw new Exception(ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + args[0] + ChatColor.RED
|
||||||
+ " doesn't exist!");
|
+ " doesn't exist!");
|
||||||
}
|
}
|
||||||
|
@ -32,41 +32,43 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
|||||||
// sender.sendMessage(ChatColor.RED + "/disguisehelp <Disguise> <Option>");
|
// sender.sendMessage(ChatColor.RED + "/disguisehelp <Disguise> <Option>");
|
||||||
} else {
|
} else {
|
||||||
DisguiseType type = null;
|
DisguiseType type = null;
|
||||||
try {
|
for (DisguiseType disguiseType : DisguiseType.values()) {
|
||||||
type = DisguiseType.valueOf(args[0].toUpperCase());
|
if (args[0].equalsIgnoreCase(disguiseType.name())
|
||||||
} catch (Exception ex) {
|
|| disguiseType.name().replace("_", "").equalsIgnoreCase(args[0])) {
|
||||||
|
type = disguiseType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type == null) {
|
||||||
sender.sendMessage(ChatColor.RED + "Cannot find the disguise " + args[0]);
|
sender.sendMessage(ChatColor.RED + "Cannot find the disguise " + args[0]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (type != null) {
|
ArrayList<String> methods = new ArrayList<String>();
|
||||||
ArrayList<String> methods = new ArrayList<String>();
|
Class watcher = type.getWatcherClass();
|
||||||
Class watcher = type.getWatcherClass();
|
try {
|
||||||
try {
|
for (Method method : watcher.getMethods()) {
|
||||||
for (Method method : watcher.getMethods()) {
|
if (!method.getName().startsWith("get") && method.getParameterTypes().length == 1) {
|
||||||
if (!method.getName().startsWith("get") && method.getParameterTypes().length == 1) {
|
Class c = method.getParameterTypes()[0];
|
||||||
Class c = method.getParameterTypes()[0];
|
String valueType = null;
|
||||||
String valueType = null;
|
if (c == String.class)
|
||||||
if (c == String.class)
|
valueType = "String";
|
||||||
valueType = "String";
|
else if (boolean.class == c)
|
||||||
else if (boolean.class == c)
|
valueType = "True/False";
|
||||||
valueType = "True/False";
|
else if (float.class == c || double.class == c || int.class == c) {
|
||||||
else if (float.class == c || double.class == c || int.class == c) {
|
valueType = "Number";
|
||||||
valueType = "Number";
|
}
|
||||||
}
|
if (valueType != null) {
|
||||||
if (valueType != null) {
|
methods.add(ChatColor.RED + method.getName() + ChatColor.DARK_RED + " (" + ChatColor.GREEN
|
||||||
methods.add(ChatColor.RED + method.getName() + ChatColor.DARK_RED + " ("
|
+ valueType + ChatColor.DARK_RED + ")");
|
||||||
+ ChatColor.GREEN + valueType + ChatColor.DARK_RED + ")");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
}
|
||||||
Collections.sort(methods, String.CASE_INSENSITIVE_ORDER);
|
} catch (Exception ex) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Options: "
|
ex.printStackTrace();
|
||||||
+ StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
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