@@ -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<CommandSource> {
|
||||
}
|
||||
|
||||
private SimpleCommand command;
|
||||
private CommandMeta commandMeta;
|
||||
|
||||
private List<String> defaultHelpMessages = new ArrayList<>();
|
||||
|
||||
@@ -72,16 +74,20 @@ public class VelocityCommand extends AbstractCommand<CommandSource> {
|
||||
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
|
||||
|
||||
@@ -33,6 +33,10 @@ public class VelocityCommandFrameworkPlugin {
|
||||
|
||||
private static VelocityCommandFrameworkPlugin instance;
|
||||
|
||||
public static VelocityCommandFrameworkPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static ProxyServer getProxy() {
|
||||
return instance.proxyServer;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user