forked from SteamWar/SteamWar
Fix registering of commands
This commit is contained in:
+8
-2
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.command;
|
package de.steamwar.command;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.command.CommandMeta;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.command.SimpleCommand;
|
import com.velocitypowered.api.command.SimpleCommand;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
@@ -41,6 +42,7 @@ public class VelocityCommand extends AbstractCommand<CommandSource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SimpleCommand command;
|
private SimpleCommand command;
|
||||||
|
private CommandMeta commandMeta;
|
||||||
|
|
||||||
private List<String> defaultHelpMessages = new ArrayList<>();
|
private List<String> defaultHelpMessages = new ArrayList<>();
|
||||||
|
|
||||||
@@ -72,16 +74,20 @@ public class VelocityCommand extends AbstractCommand<CommandSource> {
|
|||||||
return invocation.source().hasPermission(permission);
|
return invocation.source().hasPermission(permission);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
commandMeta = VelocityCommandFrameworkPlugin.getProxy().getCommandManager().metaBuilder(super.command)
|
||||||
|
.aliases(aliases)
|
||||||
|
.plugin(VelocityCommandFrameworkPlugin.getInstance())
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unregister() {
|
public void unregister() {
|
||||||
VelocityCommandRegistering.unregister(command);
|
VelocityCommandRegistering.unregister(commandMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
VelocityCommandRegistering.register(command);
|
VelocityCommandRegistering.register(commandMeta, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+4
@@ -33,6 +33,10 @@ public class VelocityCommandFrameworkPlugin {
|
|||||||
|
|
||||||
private static VelocityCommandFrameworkPlugin instance;
|
private static VelocityCommandFrameworkPlugin instance;
|
||||||
|
|
||||||
|
public static VelocityCommandFrameworkPlugin getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
public static ProxyServer getProxy() {
|
public static ProxyServer getProxy() {
|
||||||
return instance.proxyServer;
|
return instance.proxyServer;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-10
@@ -19,23 +19,18 @@
|
|||||||
|
|
||||||
package de.steamwar.command;
|
package de.steamwar.command;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.command.CommandMeta;
|
||||||
import com.velocitypowered.api.command.SimpleCommand;
|
import com.velocitypowered.api.command.SimpleCommand;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
|
||||||
import com.velocitypowered.proxy.Velocity;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
class VelocityCommandRegistering {
|
class VelocityCommandRegistering {
|
||||||
|
|
||||||
private static final Plugin plugin = ProxyServer.getInstance().getPluginManager().getPlugins().iterator().next();
|
static void unregister(CommandMeta command) {
|
||||||
|
VelocityCommandFrameworkPlugin.getProxy().getCommandManager().unregister(command);
|
||||||
static void unregister(SimpleCommand command) {
|
|
||||||
VelocityCommandFrameworkPlugin.getProxy().
|
|
||||||
ProxyServer.getInstance().getPluginManager().unregisterCommand(command);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void register(SimpleCommand command) {
|
static void register(CommandMeta command, SimpleCommand commandInstance) {
|
||||||
ProxyServer.getInstance().getPluginManager().registerCommand(plugin, command);
|
VelocityCommandFrameworkPlugin.getProxy().getCommandManager().register(command, commandInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user