From f431b619fefc453fd80c04ef46ea8fbebc37fc86 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 6 Nov 2013 04:56:23 +1300 Subject: [PATCH] Fixed casting issues and more boolean issues --- .../disguise/BaseDisguiseCommand.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/me/libraryaddict/disguise/BaseDisguiseCommand.java b/src/me/libraryaddict/disguise/BaseDisguiseCommand.java index 9323ef0c..31b00592 100644 --- a/src/me/libraryaddict/disguise/BaseDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/BaseDisguiseCommand.java @@ -147,19 +147,23 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { Class param = types[0]; if (float.class == param || double.class == param || int.class == param) { if (isDouble(valueString)) { - value = param.cast(Float.parseFloat(valueString)); + float obj = Float.parseFloat(valueString); + if (param == float.class) { + value = (float) obj; + } else if (param == int.class) { + value = (int) obj; + } else if (param == double.class) { + value = (double) obj; + } } else { throw new Exception(ChatColor.RED + "Expected a number, received " + valueString + " instead for " + methodName); } } else if (boolean.class == param) { - try { - Boolean.parseBoolean(valueString); - } catch (Exception ex) { + if (!("true".equalsIgnoreCase(valueString) || "false".equalsIgnoreCase(valueString))) throw new Exception(ChatColor.RED + "Expected true/false, received " + valueString + " instead for " + methodName); - } - value = param.cast(Boolean.parseBoolean(valueString)); + value = (boolean) "true".equalsIgnoreCase(valueString); } else if (param == String.class) { value = valueString; }