diff --git a/README.md b/README.md index 87060b42d..5ed0cee39 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,13 @@ maven("https://repo.panda-lang.org/releases") ### Dependency ```kts - implementation("dev.rollczi:{artifact}:3.0.2-SNAPSHOT") + implementation("dev.rollczi:{artifact}:3.0.2") ``` ```xml dev.rollczi {artifact} - 3.0.2-SNAPSHOT + 3.0.2 ``` `{artifact}` replace with [platform artifact](https://github.com/Rollczi/LiteCommands#platform-artifacts) diff --git a/buildSrc/src/main/kotlin/litecommands-publish.gradle.kts b/buildSrc/src/main/kotlin/litecommands-publish.gradle.kts index 8d3e69bc1..1b4e6cf4a 100644 --- a/buildSrc/src/main/kotlin/litecommands-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/litecommands-publish.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "dev.rollczi" -version = "3.0.2-SNAPSHOT" +version = "3.0.2" java { withSourcesJar() diff --git a/examples/bukkit-adventure-platform/build.gradle.kts b/examples/bukkit-adventure-platform/build.gradle.kts index 6ae286806..d116280d5 100644 --- a/examples/bukkit-adventure-platform/build.gradle.kts +++ b/examples/bukkit-adventure-platform/build.gradle.kts @@ -18,8 +18,8 @@ repositories { dependencies { compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") - // implementation("dev.rollczi:litecommands-bukkit:3.0.2-SNAPSHOT") // <-- uncomment in your project - // implementation("dev.rollczi:litecommands-adventure-platform:3.0.2-SNAPSHOT") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-bukkit:3.0.2") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-adventure-platform:3.0.2") // <-- uncomment in your project implementation("net.kyori:adventure-platform-bukkit:4.3.0") implementation("net.kyori:adventure-text-minimessage:4.14.0") diff --git a/examples/bukkit-chatgpt/build.gradle.kts b/examples/bukkit-chatgpt/build.gradle.kts index 79da0573c..e70348b4a 100644 --- a/examples/bukkit-chatgpt/build.gradle.kts +++ b/examples/bukkit-chatgpt/build.gradle.kts @@ -18,8 +18,8 @@ repositories { dependencies { compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") - // implementation("dev.rollczi:litecommands-bukkit:3.0.2-SNAPSHOT") // <-- uncomment in your project - // implementation("dev.rollczi:litecommands-chatgpt:3.0.2-SNAPSHOT") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-bukkit:3.0.2") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-chatgpt:3.0.2") // <-- uncomment in your project implementation(project(":litecommands-bukkit")) // don't use this line in your build.gradle implementation(project(":litecommands-chatgpt")) // don't use this line in your build.gradle } diff --git a/examples/bukkit/build.gradle.kts b/examples/bukkit/build.gradle.kts index 66f95b0d1..40e49e210 100644 --- a/examples/bukkit/build.gradle.kts +++ b/examples/bukkit/build.gradle.kts @@ -18,7 +18,7 @@ repositories { dependencies { compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") - // implementation("dev.rollczi:litecommands-bukkit:3.0.2-SNAPSHOT") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-bukkit:3.0.2") // <-- uncomment in your project implementation(project(":litecommands-bukkit")) // don't use this line in your build.gradle } diff --git a/examples/velocity/build.gradle.kts b/examples/velocity/build.gradle.kts index 0c5b202e4..b339541d5 100644 --- a/examples/velocity/build.gradle.kts +++ b/examples/velocity/build.gradle.kts @@ -19,7 +19,7 @@ dependencies { compileOnly("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT") annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT") - // implementation("dev.rollczi:litecommands-velocity:3.0.2-SNAPSHOT") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-velocity:3.0.2") // <-- uncomment in your project implementation(project(":litecommands-velocity")) // don't use this line in your build.gradle } diff --git a/litecommands-annotations/test/dev/rollczi/litecommands/annotations/suggestion/CustomSuggestionTest.java b/litecommands-annotations/test/dev/rollczi/litecommands/annotations/suggestion/CustomSuggestionTest.java index fb540d543..a1b39375d 100644 --- a/litecommands-annotations/test/dev/rollczi/litecommands/annotations/suggestion/CustomSuggestionTest.java +++ b/litecommands-annotations/test/dev/rollczi/litecommands/annotations/suggestion/CustomSuggestionTest.java @@ -29,6 +29,16 @@ void testDefault() { .assertSuggest("default-suggestion"); } + @Test + @DisplayName("should suggest default suggestion with ignore case") + void testIgnoreCase() { + platform.suggest("test D") + .assertSuggest("default-suggestion"); + + platform.suggest("test DEFAULT-SUGGESTION") + .assertSuggest("default-suggestion"); + } + @Test @DisplayName("should suggest custom suggestion") void testCustom() { diff --git a/litecommands-core/src/dev/rollczi/litecommands/suggestion/SuggestionResult.java b/litecommands-core/src/dev/rollczi/litecommands/suggestion/SuggestionResult.java index f490ed199..17f4c8b4e 100644 --- a/litecommands-core/src/dev/rollczi/litecommands/suggestion/SuggestionResult.java +++ b/litecommands-core/src/dev/rollczi/litecommands/suggestion/SuggestionResult.java @@ -1,6 +1,7 @@ package dev.rollczi.litecommands.suggestion; import dev.rollczi.litecommands.shared.IterableMutableArray; +import dev.rollczi.litecommands.util.StringUtil; import java.util.Collection; import java.util.Collections; @@ -32,7 +33,7 @@ public void addAll(SuggestionResult result) { public SuggestionResult filterBy(Suggestion suggestion) { String multilevel = suggestion.multilevel(); Set filtered = this.suggestions.stream() - .filter(suggestion1 -> suggestion1.multilevel().startsWith(multilevel)) + .filter(current -> StringUtil.startsWithIgnoreCase(current.multilevel(), multilevel)) .map(suggestion1 -> suggestion1.slashLevel(suggestion.lengthMultilevel() - 1)) .collect(Collectors.toSet()); diff --git a/litecommands-core/src/dev/rollczi/litecommands/suggestion/SuggestionService.java b/litecommands-core/src/dev/rollczi/litecommands/suggestion/SuggestionService.java index 1ec633a35..64f2642f4 100644 --- a/litecommands-core/src/dev/rollczi/litecommands/suggestion/SuggestionService.java +++ b/litecommands-core/src/dev/rollczi/litecommands/suggestion/SuggestionService.java @@ -11,6 +11,7 @@ import dev.rollczi.litecommands.command.CommandRoute; import dev.rollczi.litecommands.flow.Flow; import dev.rollczi.litecommands.invocation.Invocation; +import dev.rollczi.litecommands.util.StringUtil; import dev.rollczi.litecommands.validator.ValidatorService; public class SuggestionService { @@ -64,7 +65,7 @@ private > SuggestionResult sugge for (CommandRoute child : commandRoute.getChildren()) { for (String name : child.names()) { - if (!name.startsWith(current)) { + if (!StringUtil.startsWithIgnoreCase(name, current)) { continue; } diff --git a/litecommands-core/src/dev/rollczi/litecommands/util/StringUtil.java b/litecommands-core/src/dev/rollczi/litecommands/util/StringUtil.java index 020ff15db..5f19ad298 100644 --- a/litecommands-core/src/dev/rollczi/litecommands/util/StringUtil.java +++ b/litecommands-core/src/dev/rollczi/litecommands/util/StringUtil.java @@ -16,4 +16,13 @@ public static String repeat(String text, int length) { return builder.toString(); } + public static boolean startsWithIgnoreCase(String text, String prefix) { + return text.regionMatches(true, 0, prefix, 0, prefix.length()); + } + + public static boolean endsWithIgnoreCase(String str, String suffix) { + int suffixLength = suffix.length(); + return str.regionMatches(true, str.length() - suffixLength, suffix, 0, suffixLength); + } + }