Fixed up the option checking codes
This commit is contained in:
parent
ff5426ffb8
commit
742b072c2b
@ -141,21 +141,20 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
Method methodToUse = null;
|
||||
Object value = null;
|
||||
for (Method method : disguise.getWatcher().getClass().getMethods()) {
|
||||
if (method.getName().equalsIgnoreCase(methodName)) {
|
||||
if (!method.getName().startsWith("get") && method.getName().equalsIgnoreCase(methodName)) {
|
||||
methodToUse = method;
|
||||
methodName = method.getName();
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
if (types.length == 1) {
|
||||
Class param = types[0];
|
||||
if (Float.class.isAssignableFrom(param) || Double.class.isAssignableFrom(param)
|
||||
|| Integer.class.isAssignableFrom(param)) {
|
||||
if (float.class == param || double.class == param || int.class == param) {
|
||||
if (isDouble(valueString)) {
|
||||
value = param.cast(Float.parseFloat(valueString));
|
||||
} else {
|
||||
throw new Exception(ChatColor.RED + "Expected a number, received " + valueString
|
||||
+ " instead for " + methodName);
|
||||
}
|
||||
} else if (Boolean.class.isAssignableFrom(param)) {
|
||||
} else if (boolean.class == param) {
|
||||
try {
|
||||
Boolean.parseBoolean(valueString);
|
||||
} catch (Exception ex) {
|
||||
|
@ -43,15 +43,14 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
||||
Class watcher = type.getWatcherClass();
|
||||
try {
|
||||
for (Method method : watcher.getMethods()) {
|
||||
if (method.getParameterTypes().length == 1) {
|
||||
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.isAssignableFrom(c))
|
||||
else if (boolean.class == c)
|
||||
valueType = "True/False";
|
||||
else if (Float.class.isAssignableFrom(c) || Double.class.isAssignableFrom(c)
|
||||
|| Integer.class.isAssignableFrom(c)) {
|
||||
else if (float.class == c || double.class == c || int.class == c) {
|
||||
valueType = "Number";
|
||||
}
|
||||
if (valueType != null) {
|
||||
@ -63,7 +62,8 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Options: " + StringUtils.join(methods, ", "));
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Options: "
|
||||
+ StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user