From fd22c1cccc631ccb3a3d9397a5281823543472bf Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sun, 23 Nov 2025 08:32:44 +0100 Subject: [PATCH] Fix registering of commands --- .../src/de/steamwar/command/VelocityCommand.java | 10 ++++++++-- .../command/VelocityCommandFrameworkPlugin.java | 4 ++++ .../command/VelocityCommandRegistering.java | 15 +++++---------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommand.java b/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommand.java index 361c8d27..936283cf 100644 --- a/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommand.java +++ b/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommand.java @@ -19,6 +19,7 @@ package de.steamwar.command; +import com.velocitypowered.api.command.CommandMeta; import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.command.SimpleCommand; import com.velocitypowered.api.proxy.Player; @@ -41,6 +42,7 @@ public class VelocityCommand extends AbstractCommand { } private SimpleCommand command; + private CommandMeta commandMeta; private List defaultHelpMessages = new ArrayList<>(); @@ -72,16 +74,20 @@ public class VelocityCommand extends AbstractCommand { return invocation.source().hasPermission(permission); } }; + commandMeta = VelocityCommandFrameworkPlugin.getProxy().getCommandManager().metaBuilder(super.command) + .aliases(aliases) + .plugin(VelocityCommandFrameworkPlugin.getInstance()) + .build(); } @Override public void unregister() { - VelocityCommandRegistering.unregister(command); + VelocityCommandRegistering.unregister(commandMeta); } @Override public void register() { - VelocityCommandRegistering.register(command); + VelocityCommandRegistering.register(commandMeta, command); } @Override diff --git a/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommandFrameworkPlugin.java b/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommandFrameworkPlugin.java index f676e0ec..f7fb06f3 100644 --- a/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommandFrameworkPlugin.java +++ b/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommandFrameworkPlugin.java @@ -33,6 +33,10 @@ public class VelocityCommandFrameworkPlugin { private static VelocityCommandFrameworkPlugin instance; + public static VelocityCommandFrameworkPlugin getInstance() { + return instance; + } + public static ProxyServer getProxy() { return instance.proxyServer; } diff --git a/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommandRegistering.java b/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommandRegistering.java index baf46394..d0b99994 100644 --- a/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommandRegistering.java +++ b/CommandFramework/CommandFrameworkVelocity/src/de/steamwar/command/VelocityCommandRegistering.java @@ -19,23 +19,18 @@ package de.steamwar.command; +import com.velocitypowered.api.command.CommandMeta; import com.velocitypowered.api.command.SimpleCommand; -import com.velocitypowered.api.proxy.ProxyServer; -import com.velocitypowered.proxy.Velocity; import lombok.experimental.UtilityClass; -import net.md_5.bungee.api.plugin.Plugin; @UtilityClass class VelocityCommandRegistering { - private static final Plugin plugin = ProxyServer.getInstance().getPluginManager().getPlugins().iterator().next(); - - static void unregister(SimpleCommand command) { - VelocityCommandFrameworkPlugin.getProxy(). - ProxyServer.getInstance().getPluginManager().unregisterCommand(command); + static void unregister(CommandMeta command) { + VelocityCommandFrameworkPlugin.getProxy().getCommandManager().unregister(command); } - static void register(SimpleCommand command) { - ProxyServer.getInstance().getPluginManager().registerCommand(plugin, command); + static void register(CommandMeta command, SimpleCommand commandInstance) { + VelocityCommandFrameworkPlugin.getProxy().getCommandManager().register(command, commandInstance); } } \ No newline at end of file