From 90b63e53f384fb81d0fa6e06f6504c9c3c065716 Mon Sep 17 00:00:00 2001 From: Pablo Herrera Date: Sat, 9 Sep 2023 08:42:27 +0200 Subject: [PATCH 01/10] Fix flags not tab-completing unless string is empty (#460) --- .../cloud/commandframework/CommandTree.java | 7 +--- .../CommandSuggestionsTest.java | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/cloud-core/src/main/java/cloud/commandframework/CommandTree.java b/cloud-core/src/main/java/cloud/commandframework/CommandTree.java index 615c6d3c..41b789a1 100644 --- a/cloud-core/src/main/java/cloud/commandframework/CommandTree.java +++ b/cloud-core/src/main/java/cloud/commandframework/CommandTree.java @@ -41,7 +41,6 @@ import cloud.commandframework.keys.SimpleCloudKey; import cloud.commandframework.permission.CommandPermission; import cloud.commandframework.permission.OrPermission; import cloud.commandframework.types.tuples.Pair; -import io.leangen.geantyref.GenericTypeReflector; import io.leangen.geantyref.TypeToken; import java.util.ArrayList; import java.util.Arrays; @@ -613,10 +612,6 @@ public final class CommandTree { if (!lastFlag.isPresent()) { commandContext.remove(FlagArgument.FLAG_META_KEY); } - } else if (GenericTypeReflector.erase(child.getValue().getValueType().getType()).isArray()) { - while (commandQueue.size() > 1) { - commandQueue.remove(); - } } else if (commandQueue.size() <= child.getValue().getParser().getRequestedArgumentCount()) { for (int i = 0; i < child.getValue().getParser().getRequestedArgumentCount() - 1 && commandQueue.size() > 1; i++) { @@ -636,7 +631,7 @@ public final class CommandTree { } else if (child.getValue() instanceof CompoundArgument) { return this.directSuggestions(commandContext, child, ((LinkedList) commandQueue).getLast()); } - } else if (commandQueue.size() == 1 && commandQueue.peek().isEmpty()) { + } else if (commandQueue.size() == 1) { return this.directSuggestions(commandContext, child, commandQueue.peek()); } diff --git a/cloud-core/src/test/java/cloud/commandframework/CommandSuggestionsTest.java b/cloud-core/src/test/java/cloud/commandframework/CommandSuggestionsTest.java index dd51bd30..8a988066 100644 --- a/cloud-core/src/test/java/cloud/commandframework/CommandSuggestionsTest.java +++ b/cloud-core/src/test/java/cloud/commandframework/CommandSuggestionsTest.java @@ -23,6 +23,7 @@ // package cloud.commandframework; +import cloud.commandframework.arguments.CommandArgument; import cloud.commandframework.arguments.compound.ArgumentTriplet; import cloud.commandframework.arguments.parser.ArgumentParseResult; import cloud.commandframework.arguments.standard.BooleanArgument; @@ -37,8 +38,10 @@ import cloud.commandframework.types.tuples.Triplet; import java.util.Arrays; import java.util.Collections; import java.util.List; +import org.junit.Ignore; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static cloud.commandframework.util.TestUtils.createManager; @@ -635,6 +638,41 @@ public class CommandSuggestionsTest { assertThat(suggestions6).isEmpty(); } + @Test + void testTextFlagCompletion() { + // Arrange + final CommandManager manager = createManager(); + manager.setSetting(CommandManager.ManagerSettings.LIBERAL_FLAG_PARSING, true); + manager.command( + manager.commandBuilder("command") + .flag(manager.flagBuilder("flag").withAliases("f") + .withArgument(EnumArgument.of(TestEnum.class, "test")).build()) + .flag(manager.flagBuilder("flog").build()) + ); + + // Act + final List suggestions1 = suggest(manager, "command "); + final List suggestions2 = suggest(manager, "command --"); + final List suggestions3 = suggest(manager, "command --f"); + final List suggestions4 = suggest(manager, "command --fla"); + final List suggestions5 = suggest(manager, "command -f"); + final List suggestions6 = suggest(manager, "command -"); + + final List suggestions7 = suggest(manager, "command -f "); + final List suggestions8 = suggest(manager, "command -f b"); + + // Assert + assertThat(suggestions1).containsExactly("--flag", "--flog", "-f"); + assertThat(suggestions2).containsExactly("--flag", "--flog"); + assertThat(suggestions3).containsExactly("--flag", "--flog"); + assertThat(suggestions4).containsExactly("--flag"); + assertThat(suggestions5).containsExactly("-f"); + assertThat(suggestions6).containsExactly("--flag", "--flog", "-f"); + assertThat(suggestions7).containsExactly("foo", "bar"); + assertThat(suggestions8).containsExactly("bar"); + } + + private List suggest(CommandManager manager, String command) { return manager.suggest(new TestCommandSender(), command); } From 19bbfb1e24735eef2998ae91e815956424245cf0 Mon Sep 17 00:00:00 2001 From: Konicai <71294714+Konicai@users.noreply.github.com> Date: Sat, 9 Sep 2023 02:48:42 -0400 Subject: [PATCH 02/10] Log cause of CommandExecutionException in fabric's default exception handler (#466) --- .../main/java/cloud/commandframework/fabric/FabricExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricExecutor.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricExecutor.java index bb3da343..5bf3df95 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricExecutor.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricExecutor.java @@ -158,7 +158,7 @@ final class FabricExecutor implements Com LOGGER.warn( "Error occurred while executing command for user {}:", this.getName.apply(source), - throwable + throwable.getCause() ); } ); From fda52448c20f5537c8f03aaf6a3b844119c20463 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Sat, 9 Sep 2023 00:05:27 -0700 Subject: [PATCH 03/10] release: Version 1.8.4 --- CHANGELOG.md | 12 ++++++++++++ README.md | 6 +++--- cloud-minecraft/README.md | 22 +++++++++++----------- gradle.properties | 2 +- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74ec775d..419fcc1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.8.4] + +### Fixed +- Core: Flags not tab-completing unless string is empty ([#460](https://github.com/Incendo/cloud/pull/460)) +- Core: Parser registry not properly resolving `TypeToken`s ([#454](https://github.com/Incendo/cloud/pull/454)) +- Fabric: Pottery pattern registry overriding default string parser for annotations +- Fabric: Log cause of CommandExecutionException in fabric's default exception handler ([#466](https://github.com/Incendo/cloud/pull/466)) + +### Changed +- Core: Improved string parser supplier argument checking +- Bukkit/Paper: Improve docs around Brigadier support + ## [1.8.3] ### Changed diff --git a/README.md b/README.md index 3e422f85..d140fe9e 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ Snapshot builds of Cloud are available through the [Sonatype OSS Snapshot reposi cloud.commandframework cloud-PLATFORM - 1.8.3 + 1.8.4