diff --git a/src/de/steamwar/command/SWCommandUtils.java b/src/de/steamwar/command/SWCommandUtils.java index 8ebfec7..871439a 100644 --- a/src/de/steamwar/command/SWCommandUtils.java +++ b/src/de/steamwar/command/SWCommandUtils.java @@ -103,10 +103,12 @@ public class SWCommandUtils { Class varArgType = parameter.isVarArgs() ? parameter.getType().getComponentType() : null; AbstractSWCommand.OptionalValue optionalValue = parameter.getAnnotation(AbstractSWCommand.OptionalValue.class); AbstractSWCommand.AllowNull allowNull = parameter.getAnnotation(AbstractSWCommand.AllowNull.class); + AbstractSWCommand.Quotable quotable = parameter.getAnnotation(AbstractSWCommand.Quotable.class); CommandPart commandPart = new CommandPart<>(command, typeMapper, validator, varArgType, optionalValue != null ? optionalValue.value() : null, parameter, i); commandPart.setOnlyUseIfNoneIsGiven(optionalValue != null && optionalValue.onlyUINIG()); commandPart.setAllowNullValues(allowNull != null); + commandPart.setQuotable(quotable != null); if (current != null) { current.setNext(commandPart); } diff --git a/testsrc/de/steamwar/command/ArgumentCommand.java b/testsrc/de/steamwar/command/ArgumentCommand.java index a107270..ad1c1ec 100644 --- a/testsrc/de/steamwar/command/ArgumentCommand.java +++ b/testsrc/de/steamwar/command/ArgumentCommand.java @@ -54,7 +54,7 @@ public class ArgumentCommand extends TestSWCommand { } @Register - public void argument(String sender, String arg) { + public void argument(String sender, @Quotable String arg) { throw new ExecutionIdentifier("RunArgument with String"); } } diff --git a/testsrc/de/steamwar/command/ArgumentCommandTest.java b/testsrc/de/steamwar/command/ArgumentCommandTest.java index 013e035..fd4fb5f 100644 --- a/testsrc/de/steamwar/command/ArgumentCommandTest.java +++ b/testsrc/de/steamwar/command/ArgumentCommandTest.java @@ -44,6 +44,7 @@ public class ArgumentCommandTest { ArgumentCommand cmd = new ArgumentCommand(); try { cmd.execute("test", "", new String[]{"true", "false"}); + assert false; } catch (Exception e) { assertCMDFramework(e, ExecutionIdentifier.class, "RunArgument with Boolean"); } @@ -54,6 +55,7 @@ public class ArgumentCommandTest { ArgumentCommand cmd = new ArgumentCommand(); try { cmd.execute("test", "", new String[]{"0.0", "0.0", "0.0"}); + assert false; } catch (Exception e) { assertCMDFramework(e, ExecutionIdentifier.class, "RunArgument with Float"); } @@ -64,6 +66,7 @@ public class ArgumentCommandTest { ArgumentCommand cmd = new ArgumentCommand(); try { cmd.execute("test", "", new String[]{"0.0", "0.0", "0.0", "0.0"}); + assert false; } catch (Exception e) { assertCMDFramework(e, ExecutionIdentifier.class, "RunArgument with Double"); } @@ -74,6 +77,7 @@ public class ArgumentCommandTest { ArgumentCommand cmd = new ArgumentCommand(); try { cmd.execute("test", "", new String[]{"0"}); + assert false; } catch (Exception e) { assertCMDFramework(e, ExecutionIdentifier.class, "RunArgument with Integer"); } @@ -84,6 +88,7 @@ public class ArgumentCommandTest { ArgumentCommand cmd = new ArgumentCommand(); try { cmd.execute("test", "", new String[]{"0", "0"}); + assert false; } catch (Exception e) { assertCMDFramework(e, ExecutionIdentifier.class, "RunArgument with Long"); } @@ -94,11 +99,22 @@ public class ArgumentCommandTest { ArgumentCommand cmd = new ArgumentCommand(); try { cmd.execute("test", "", new String[]{"Hello World"}); + assert false; + } catch (Exception e) { + assertCMDFramework(e, ExecutionIdentifier.class, "RunArgument with String"); + } + try { + cmd.execute("test", "", new String[]{"\"Hello World\""}); + assert false; + } catch (Exception e) { + assertCMDFramework(e, ExecutionIdentifier.class, "RunArgument with String"); + } + try { + cmd.execute("test", "", new String[]{"\"Hello", "World\""}); + assert false; } catch (Exception e) { assertCMDFramework(e, ExecutionIdentifier.class, "RunArgument with String"); } - cmd.execute("test", "", new String[]{"\"Hello World\""}); - cmd.execute("test", "", new String[]{"\"Hello", "World\""}); } @Test