From ce85459041f8d9e8d25749d7f95deb02c943e691 Mon Sep 17 00:00:00 2001 From: ancap-kun Date: Fri, 17 Feb 2023 20:25:03 +0500 Subject: [PATCH] 1.6.6 --- Artifex/dependency-reduced-pom.xml | 2 +- Artifex/pom.xml | 2 +- .../communicate/PlayerCommandFallback.java | 6 +++--- .../api/commands/operator/arguments/Argument.java | 15 +++++++++++++++ .../commands/operator/arguments/Arguments.java | 12 +++++++++--- .../resource/config/BuiltTransferMap.java | 7 ++++--- .../config/FileConfigurationPreparator.java | 1 - 7 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Artifex/dependency-reduced-pom.xml b/Artifex/dependency-reduced-pom.xml index c2f4b30e..b38f8770 100644 --- a/Artifex/dependency-reduced-pom.xml +++ b/Artifex/dependency-reduced-pom.xml @@ -8,7 +8,7 @@ 4.0.0 Artifex Artifex - 1.6.5 + 1.6.6 AncapAPI runtime part artifex-v${version} diff --git a/Artifex/pom.xml b/Artifex/pom.xml index d6fb67f7..8eacb444 100644 --- a/Artifex/pom.xml +++ b/Artifex/pom.xml @@ -13,7 +13,7 @@ jar Artifex - 1.6.5 + 1.6.6 Artifex diff --git a/Artifex/src/main/java/ru/ancap/framework/artifex/implementation/command/communicate/PlayerCommandFallback.java b/Artifex/src/main/java/ru/ancap/framework/artifex/implementation/command/communicate/PlayerCommandFallback.java index c3545ff8..8adebe61 100644 --- a/Artifex/src/main/java/ru/ancap/framework/artifex/implementation/command/communicate/PlayerCommandFallback.java +++ b/Artifex/src/main/java/ru/ancap/framework/artifex/implementation/command/communicate/PlayerCommandFallback.java @@ -8,11 +8,11 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import ru.ancap.framework.communicate.Communicator; -import ru.ancap.framework.communicate.replacement.Placeholder; import ru.ancap.framework.artifex.Artifex; import ru.ancap.framework.command.api.event.OperableEvent; import ru.ancap.framework.command.api.event.classic.*; +import ru.ancap.framework.communicate.Communicator; +import ru.ancap.framework.communicate.replacement.Placeholder; import ru.ancap.framework.language.additional.LAPIMessage; @AllArgsConstructor @@ -59,7 +59,7 @@ public void on(CannotTransformArgumentEvent event) { new Form(event, event.sender()), "command.api.error.cannot-transform-argument", new Placeholder("ARGUMENT", String.join(" ", event.argument())), - new Placeholder("TYPE", event.type()) + new Placeholder("TYPE", new LAPIMessage("ru.ancap.types."+event.type().getName())) ); } diff --git a/CommandAPI/src/main/java/ru/ancap/framework/command/api/commands/operator/arguments/Argument.java b/CommandAPI/src/main/java/ru/ancap/framework/command/api/commands/operator/arguments/Argument.java index aeb2f17f..77eec268 100644 --- a/CommandAPI/src/main/java/ru/ancap/framework/command/api/commands/operator/arguments/Argument.java +++ b/CommandAPI/src/main/java/ru/ancap/framework/command/api/commands/operator/arguments/Argument.java @@ -3,7 +3,13 @@ import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; import lombok.ToString; +import org.bukkit.command.CommandSender; +import ru.ancap.framework.command.api.commands.object.tab.TabCompletion; import ru.ancap.framework.command.api.commands.operator.arguments.extractor.ArgumentExtractor; +import ru.ancap.framework.communicate.message.CallableMessage; + +import java.util.List; +import java.util.function.Function; @AllArgsConstructor @ToString @@ -13,10 +19,15 @@ public class Argument { private final String argumentName; private final ArgumentExtractor argumentExtractor; private final boolean optional; + private final Function> help; public Argument(String argumentName, ArgumentExtractor argumentExtractor) { this(argumentName, argumentExtractor, false); } + + public Argument(String argumentName, ArgumentExtractor argumentExtractor, boolean optional) { + this(argumentName, argumentExtractor, optional, null); + } public String argumentName() { return this.argumentName; @@ -30,4 +41,8 @@ public boolean optional() { return this.optional; } + public Function> help() { + return this.help; + } + } diff --git a/CommandAPI/src/main/java/ru/ancap/framework/command/api/commands/operator/arguments/Arguments.java b/CommandAPI/src/main/java/ru/ancap/framework/command/api/commands/operator/arguments/Arguments.java index c2616ec1..108ace81 100644 --- a/CommandAPI/src/main/java/ru/ancap/framework/command/api/commands/operator/arguments/Arguments.java +++ b/CommandAPI/src/main/java/ru/ancap/framework/command/api/commands/operator/arguments/Arguments.java @@ -6,7 +6,6 @@ import lombok.ToString; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; -import ru.ancap.commons.AncapDebug; import ru.ancap.framework.command.api.commands.object.dispatched.LeveledCommand; import ru.ancap.framework.command.api.commands.object.dispatched.exception.NoNextArgumentException; import ru.ancap.framework.command.api.commands.object.event.CommandDispatch; @@ -14,6 +13,7 @@ import ru.ancap.framework.command.api.commands.object.executor.CommandOperator; import ru.ancap.framework.command.api.commands.object.tab.OptionalTab; import ru.ancap.framework.command.api.commands.object.tab.TabBundle; +import ru.ancap.framework.command.api.commands.object.tab.TabCompletion; import ru.ancap.framework.command.api.commands.operator.arguments.bundle.ArgumentsBundle; import ru.ancap.framework.command.api.commands.operator.arguments.bundle.ArgumentsMap; import ru.ancap.framework.command.api.commands.operator.arguments.command.ArgumentCommandDispatch; @@ -26,6 +26,7 @@ import java.util.Map; import java.util.function.BiConsumer; import java.util.function.Consumer; +import java.util.function.Function; import java.util.stream.Collectors; @RequiredArgsConstructor @@ -83,7 +84,7 @@ public void on(CommandDispatch dispatch) { } while (!command.isRaw() && argumentIndex <= this.arguments.size() - 1) { - Argument argument = this.arguments.get(0); + Argument argument = this.arguments.get(argumentIndex); Object extracted; try { extracted = argument.extractor().extract(command); @@ -102,6 +103,7 @@ public void on(CommandDispatch dispatch) { else throw new IllegalStateException(); } map.put(argument.argumentName(), extracted); + argumentIndex ++; } ArgumentsBundle bundle = new ArgumentsMap(Map.copyOf(map)); @@ -130,9 +132,13 @@ public void on(CommandWrite write) { if (shard == null) return; ArgumentBounding bounding = this.optionalityBounding.get(shard.node().optional()); + + Function> tabFunction = shard.node().help() != null ? + shard.node().help() : + shard.node().extractor().help(); write.speaker().sendTab(TabBundle.builder() - .tooltiped(shard.node().extractor().help().apply(write.speaker().source().sender()).stream() + .tooltiped(tabFunction.apply(write.speaker().source().sender()).stream() .map(tabCompletion -> new OptionalTab(bounding.opening + tabCompletion.completion() + bounding.closing, tabCompletion.tooltipState())) .collect(Collectors.toList())) .replace((written - 1) - shard.firstLiteralIndex()) diff --git a/ResourceAPI/src/main/java/ru/ancap/framework/resource/config/BuiltTransferMap.java b/ResourceAPI/src/main/java/ru/ancap/framework/resource/config/BuiltTransferMap.java index 4c282153..e5a80468 100644 --- a/ResourceAPI/src/main/java/ru/ancap/framework/resource/config/BuiltTransferMap.java +++ b/ResourceAPI/src/main/java/ru/ancap/framework/resource/config/BuiltTransferMap.java @@ -3,10 +3,11 @@ import lombok.AllArgsConstructor; import org.bukkit.configuration.ConfigurationSection; import org.jetbrains.annotations.Nullable; -import ru.ancap.commons.AncapDebug; -import java.util.*; -import java.util.function.Function; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; @AllArgsConstructor public class BuiltTransferMap implements TransferMap { diff --git a/ResourceAPI/src/main/java/ru/ancap/framework/resource/config/FileConfigurationPreparator.java b/ResourceAPI/src/main/java/ru/ancap/framework/resource/config/FileConfigurationPreparator.java index 8f4f572f..a57710b3 100644 --- a/ResourceAPI/src/main/java/ru/ancap/framework/resource/config/FileConfigurationPreparator.java +++ b/ResourceAPI/src/main/java/ru/ancap/framework/resource/config/FileConfigurationPreparator.java @@ -9,7 +9,6 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.jetbrains.annotations.NotNull; -import ru.ancap.commons.AncapDebug; import ru.ancap.framework.resource.ResourcePreparator; import java.io.File;