Implementing commands system into antivpn [v1.1]

This commit is contained in:
funkemunky
2021-06-17 12:00:06 -04:00
parent 20e6cbde9f
commit 3fcb3fe157
16 changed files with 488 additions and 7 deletions
@@ -2,7 +2,13 @@ package dev.brighten.antivpn.bungee;
import dev.brighten.antivpn.AntiVPN;
import dev.brighten.antivpn.bungee.util.Config;
import dev.brighten.antivpn.command.Command;
import lombok.Getter;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Plugin;
public class BungeePlugin extends Plugin {
@@ -20,7 +26,24 @@ public class BungeePlugin extends Plugin {
config = new Config();
//Loading plugin
AntiVPN.start(new BungeeConfig(), new BungeeListener());
AntiVPN.start(new BungeeConfig(), new BungeeListener(), new BungeePlayerExecutor());
for (Command command : AntiVPN.getInstance().getCommands()) {
BungeeCord.getInstance().getPluginManager().registerCommand(pluginInstance, new net.md_5.bungee.api.plugin
.Command(command.parent() + " " + command.name(), command.permission(), command.aliases()) {
@Override
public void execute(CommandSender commandSender, String[] strings) {
if(!commandSender.hasPermission("antivpn.command.*")
&& !commandSender.hasPermission(command.permission())) {
commandSender.sendMessage(new ComponentBuilder("No permission").color(ChatColor.RED)
.create());
return;
}
command.execute(new BungeeCommandExecutor(commandSender), strings);
}
});
}
}
@Override