diff --git a/litecommands-annotations/test/dev/rollczi/litecommands/annotations/quoted/QuotedStringTest.java b/litecommands-annotations/test/dev/rollczi/litecommands/annotations/quoted/QuotedStringTest.java index 1b931895a..dbc4f52ec 100644 --- a/litecommands-annotations/test/dev/rollczi/litecommands/annotations/quoted/QuotedStringTest.java +++ b/litecommands-annotations/test/dev/rollczi/litecommands/annotations/quoted/QuotedStringTest.java @@ -16,6 +16,11 @@ String test(@Arg String before, @Arg("message") @Quoted String message, @Arg("af return before + "-" + message + "-" + after; } + @Execute(name = "end-quoted") + String test2(@Arg String before, @Arg("message") @Quoted String message) { + return before + "-" + message; + } + } @Test @@ -24,6 +29,14 @@ void testSingle() { .assertSuccess("before-test-after"); } + @Test + void testNoQuoted() { + platform.execute("test before test after") + .assertSuccess("before-test-after"); + platform.execute("test end-quoted before \"test after end") + .assertSuccess("before-test after end"); + } + @Test void testMultiple() { platform.execute("test before \"siema co tam\" after") diff --git a/litecommands-core/src/dev/rollczi/litecommands/message/LiteMessages.java b/litecommands-core/src/dev/rollczi/litecommands/message/LiteMessages.java index 3bd4cc004..fe20ff029 100644 --- a/litecommands-core/src/dev/rollczi/litecommands/message/LiteMessages.java +++ b/litecommands-core/src/dev/rollczi/litecommands/message/LiteMessages.java @@ -3,7 +3,6 @@ import dev.rollczi.litecommands.argument.resolver.standard.InstantArgumentResolver; import dev.rollczi.litecommands.invalidusage.InvalidUsage; import dev.rollczi.litecommands.permission.MissingPermissions; -import dev.rollczi.litecommands.quoted.QuotedError; public class LiteMessages { @@ -45,16 +44,6 @@ public class LiteMessages { input -> "Invalid date format '" + input + "'! Use: (INSTANT_INVALID_FORMAT)" ); - /** - * Invalid quoted string format. - * e.g. when user doesn't provide start or end quote. - * @see dev.rollczi.litecommands.quoted.QuotedStringArgumentResolver - */ - public static final MessageKey QUOTED_STRING_INVALID_FORMAT = MessageKey.of( - "quoted-string-invalid-format", - error -> "Invalid quoted string format '" + error.getContent() + "'! Use: \"hello world\" (QUOTED_STRING_INVALID_FORMAT)" - ); - protected LiteMessages() { } diff --git a/litecommands-core/src/dev/rollczi/litecommands/quoted/QuotedError.java b/litecommands-core/src/dev/rollczi/litecommands/quoted/QuotedError.java deleted file mode 100644 index fdb3ad8cc..000000000 --- a/litecommands-core/src/dev/rollczi/litecommands/quoted/QuotedError.java +++ /dev/null @@ -1,34 +0,0 @@ -package dev.rollczi.litecommands.quoted; - -public class QuotedError { - - private final String content; - private final Cause cause; - - public QuotedError(String content, Cause cause) { - this.content = content; - this.cause = cause; - } - - public String getContent() { - return content; - } - - public Cause getCause() { - return cause; - } - - public enum Cause { - FIRST_QUOTE, - LAST_QUOTE, - } - - @Override - public String toString() { - return "QuotedError{" + - "content='" + content + '\'' + - ", cause=" + cause + - '}'; - } - -} diff --git a/litecommands-core/src/dev/rollczi/litecommands/quoted/QuotedStringArgumentResolver.java b/litecommands-core/src/dev/rollczi/litecommands/quoted/QuotedStringArgumentResolver.java index 96d3ad44a..c041c9418 100644 --- a/litecommands-core/src/dev/rollczi/litecommands/quoted/QuotedStringArgumentResolver.java +++ b/litecommands-core/src/dev/rollczi/litecommands/quoted/QuotedStringArgumentResolver.java @@ -8,7 +8,6 @@ import dev.rollczi.litecommands.argument.suggester.SuggesterRegistry; import dev.rollczi.litecommands.input.raw.RawInput; import dev.rollczi.litecommands.invocation.Invocation; -import dev.rollczi.litecommands.message.LiteMessages; import dev.rollczi.litecommands.message.MessageRegistry; import dev.rollczi.litecommands.range.Range; import dev.rollczi.litecommands.suggestion.Suggestion; @@ -45,8 +44,7 @@ public ParseResult parse(Invocation invocation, Argument String first = rawInput.next(); if (!first.startsWith(quote)) { - QuotedError error = new QuotedError(first, QuotedError.Cause.FIRST_QUOTE); - return ParseResult.failure(this.messageRegistry.getInvoked(LiteMessages.QUOTED_STRING_INVALID_FORMAT, invocation, error)); + return ParseResult.success(first); } if (first.length() > 1 && first.endsWith(quote)) { @@ -69,8 +67,7 @@ public ParseResult parse(Invocation invocation, Argument return ParseResult.success(builder.toString()); } - QuotedError error = new QuotedError(builder.toString(), QuotedError.Cause.LAST_QUOTE); - return ParseResult.failure(this.messageRegistry.getInvoked(LiteMessages.QUOTED_STRING_INVALID_FORMAT, invocation, error)); + return ParseResult.success(builder.toString()); } @Override