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