+ * Credits to @SkytAsul
+ */
+public final class LocationParameterType implements ParameterType
* If a method has {@link Subcommand @Subcommand} on it, this annotation is unnecessary.
* It simply exists in cases where the orphan command is the function itself, and
diff --git a/common/src/main/java/revxrsal/commands/annotation/Cooldown.java b/common/src/main/java/revxrsal/commands/annotation/Cooldown.java
new file mode 100644
index 00000000..cf2fb19a
--- /dev/null
+++ b/common/src/main/java/revxrsal/commands/annotation/Cooldown.java
@@ -0,0 +1,54 @@
+/*
+ * This file is part of sweeper, licensed under the MIT License.
+ *
+ * Copyright (c) Revxrsal
+ * This hook is only fired for commands that have been successfully executed.
+ * Any command that errors in the process will not be invoked here.
+ */
+@FunctionalInterface
+public interface PostCommandExecutedHook extends Hook {
+
+ /**
+ * Invokes the hook for a command whose action has been successfully executed
+ *
+ * @param command The command that will be executed
+ * @param context The execution context
+ */
+ void onPostExecuted(@NotNull ExecutableCommand command, @NotNull ExecutionContext context);
+
+}
diff --git a/common/src/main/java/revxrsal/commands/node/ParameterNode.java b/common/src/main/java/revxrsal/commands/node/ParameterNode.java
index 31514089..3e56679e 100644
--- a/common/src/main/java/revxrsal/commands/node/ParameterNode.java
+++ b/common/src/main/java/revxrsal/commands/node/ParameterNode.java
@@ -140,13 +140,11 @@ default boolean isRequired() {
/**
* Provides suggestions for the given user input.
*
- * @param actor The actor to generate for
- * @param input The command input
* @param context The execution context.
* @return The
*/
@Contract(pure = true)
- @NotNull Collection
* This will not move the cursor forward.
+ *
+ * Note that, if the next string is an unclosed-quoted string, it will return
+ * the content inside the unclosed quote.
*
* @return The next string.
*/
diff --git a/minestom/src/main/java/revxrsal/commands/minestom/hooks/MinestomCommandHooks.java b/minestom/src/main/java/revxrsal/commands/minestom/hooks/MinestomCommandHooks.java
index 7085da66..873bd4b9 100644
--- a/minestom/src/main/java/revxrsal/commands/minestom/hooks/MinestomCommandHooks.java
+++ b/minestom/src/main/java/revxrsal/commands/minestom/hooks/MinestomCommandHooks.java
@@ -110,8 +110,7 @@ private void addCommand(@NotNull ExecutableCommand command, @NotNull Command
if (node.isLiteral())
arguments.add(toArgument(node));
- else if (node instanceof ParameterNode) {
- ParameterNode parameter = (ParameterNode) node;
+ else if (node instanceof ParameterNode parameter) {
if (parameter.isSwitch()) {
// add the required
minestomCommand.addSyntax(generateAction(command), arguments.toArray(Argument[]::new));
@@ -224,11 +223,9 @@ private ArgumentColl ofFlag(ParameterNode parameter) {
A actor = actorFactory.create(sender, node.lamp());
StringStream input = StringStream.create(exception.getInput());
ExecutionContext context = ExecutionContext.create(node.command(), actor, input);
- if (node instanceof LiteralNode) {
- LiteralNode literal = (LiteralNode) node;
+ if (node instanceof LiteralNode literal) {
node.lamp().handleException(exception, ErrorContext.parsingLiteral(context, literal));
- } else if (node instanceof ParameterNode) {
- ParameterNode parameter = (ParameterNode) node;
+ } else if (node instanceof ParameterNode parameter) {
node.lamp().handleException(exception, ErrorContext.parsingParameter(context, parameter, input));
}
};
diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts
deleted file mode 100644
index 5a8362fd..00000000
--- a/paper/build.gradle.kts
+++ /dev/null
@@ -1,20 +0,0 @@
-plugins {
- id("java")
-}
-
-repositories {
- maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
- maven(url = "https://hub.spigotmc.org/nexus/content/groups/public/")
- maven(url = "https://libraries.minecraft.net")
- maven(url = "https://repo.papermc.io/repository/maven-public/")
-}
-
-dependencies {
- implementation(project(":common"))
- implementation(project(":bukkit"))
- implementation(project(":brigadier"))
- compileOnly("com.mojang:brigadier:1.0.18")
- compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
-}
-
-java.toolchain.languageVersion.set(JavaLanguageVersion.of(21))
\ No newline at end of file
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 94aec48a..ce789f49 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -13,7 +13,6 @@ rootProject.name = "lamp"
include("common")
include("bukkit")
-include("paper")
include("bungee")
include("brigadier")
include("velocity")
diff --git a/velocity/src/main/java/revxrsal/commands/velocity/VelocityVisitors.java b/velocity/src/main/java/revxrsal/commands/velocity/VelocityVisitors.java
index a95e8145..dfecbbac 100644
--- a/velocity/src/main/java/revxrsal/commands/velocity/VelocityVisitors.java
+++ b/velocity/src/main/java/revxrsal/commands/velocity/VelocityVisitors.java
@@ -31,9 +31,11 @@
import revxrsal.commands.Lamp;
import revxrsal.commands.LampBuilderVisitor;
import revxrsal.commands.LampVisitor;
+import revxrsal.commands.brigadier.types.ArgumentTypes;
import revxrsal.commands.command.CommandActor;
import revxrsal.commands.exception.CommandExceptionHandler;
import revxrsal.commands.parameter.ContextParameter;
+import revxrsal.commands.velocity.actor.ActorFactory;
import revxrsal.commands.velocity.actor.VelocityCommandActor;
import revxrsal.commands.velocity.annotation.CommandPermission;
import revxrsal.commands.velocity.exception.VelocityExceptionHandler;
@@ -137,4 +139,48 @@ public final class VelocityVisitors {
public static @NotNull LampVisitor brigadier(@NotNull VelocityLampConfig config) {
return new VelocityBrigadier<>(config);
}
+
+ /**
+ * Registers the commands into Velocity as {@link BrigadierCommand brigadier commands}.
+ *
+ * @param server The server instance
+ * @param actorFactory The actor factory
+ * @param argumentTypes The argument type registry
+ * @param The actor type
+ * @return The visitor
+ */
+ public static @NotNull LampVisitor brigadier(
+ @NotNull ProxyServer server,
+ @NotNull ActorFactory actorFactory,
+ @NotNull ArgumentTypes argumentTypes
+ ) {
+ return new VelocityBrigadier<>(server, actorFactory, argumentTypes);
+ }
+
+ /**
+ * Registers the commands into Velocity as {@link BrigadierCommand brigadier commands}.
+ *
+ * @param server The server instance
+ * @param actorFactory The actor factory
+ * @param The actor type
+ * @return The visitor
+ */
+ public static @NotNull LampVisitor brigadier(
+ @NotNull ProxyServer server,
+ @NotNull ActorFactory actorFactory
+ ) {
+ return new VelocityBrigadier<>(server, actorFactory, ArgumentTypes.builder().build());
+ }
+
+ /**
+ * Registers the commands into Velocity as {@link BrigadierCommand brigadier commands}.
+ *
+ * @param server The server instance
+ * @return The visitor
+ */
+ public static @NotNull LampVisitor
+ *
+ */
+ HALT,
+
+ /**
+ * Continue moving through the command nodes. This is sent when
+ * all previous nodes have been successfully parsed, and the input
+ * has been valid until now.
+ */
+ CONTINUE
+ }
+
+ private static String getRemainingContent(String suggestion, String consumed) {
+ // Find the index where they match until
+ int matchIndex = consumed.length();
+
+ // Find the first space after the matching part
+ int spaceIndex = suggestion.lastIndexOf(' ', matchIndex - 1);
+
+ // Return the content after the first space
+ return suggestion.substring(spaceIndex + 1);
+ }
+
+}
diff --git a/common/src/main/java/revxrsal/commands/autocomplete/StandardAutoCompleter.java b/common/src/main/java/revxrsal/commands/autocomplete/StandardAutoCompleter.java
index 1cd5c076..b28725fd 100644
--- a/common/src/main/java/revxrsal/commands/autocomplete/StandardAutoCompleter.java
+++ b/common/src/main/java/revxrsal/commands/autocomplete/StandardAutoCompleter.java
@@ -24,20 +24,13 @@
package revxrsal.commands.autocomplete;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import revxrsal.commands.Lamp;
import revxrsal.commands.command.CommandActor;
import revxrsal.commands.command.ExecutableCommand;
-import revxrsal.commands.node.*;
import revxrsal.commands.stream.MutableStringStream;
import revxrsal.commands.stream.StringStream;
import java.util.*;
-import java.util.stream.Collectors;
-
-import static revxrsal.commands.node.DispatcherSettings.LONG_FORMAT_PREFIX;
-import static revxrsal.commands.node.DispatcherSettings.SHORT_FORMAT_PREFIX;
-import static revxrsal.commands.util.Collections.*;
/**
* A basic implementation of {@link AutoCompleter} that respects secret
@@ -55,29 +48,6 @@ public StandardAutoCompleter(Lamp lamp) {
this.lamp = lamp;
}
- private static @NotNull List