mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-06-30 15:28:29 +00:00
Implemented bungee commands and tab complete 1.1.1
This commit is contained in:
@@ -6,6 +6,7 @@ import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
@@ -2,9 +2,19 @@ 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 lombok.val;
|
||||
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.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class BungeePlugin extends Plugin {
|
||||
|
||||
public static BungeePlugin pluginInstance;
|
||||
@@ -12,6 +22,9 @@ public class BungeePlugin extends Plugin {
|
||||
@Getter
|
||||
private Config config;
|
||||
|
||||
private static BaseComponent[] noPermission = new ComponentBuilder("No permission").color(ChatColor.RED)
|
||||
.create();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
pluginInstance = this;
|
||||
@@ -23,22 +36,48 @@ public class BungeePlugin extends Plugin {
|
||||
AntiVPN.start(new BungeeConfig(), new BungeeListener(), new BungeePlayerExecutor());
|
||||
|
||||
//TODO Add command functionality for BungeeCord
|
||||
/*for (Command command : AntiVPN.getInstance().getCommands()) {
|
||||
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()) {
|
||||
.Command(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());
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("antivpn.command.*")
|
||||
&& !sender.hasPermission(command.permission())) {
|
||||
sender.sendMessage(noPermission);
|
||||
return;
|
||||
}
|
||||
|
||||
command.execute(new BungeeCommandExecutor(commandSender), strings);
|
||||
val children = command.children();
|
||||
|
||||
if(children.length > 0 && args.length > 0) {
|
||||
for (Command child : children) {
|
||||
if(child.name().equalsIgnoreCase(args[0])) {
|
||||
if(!sender.hasPermission("antivpn.command.*")
|
||||
&& !sender.hasPermission(child.permission())) {
|
||||
sender.sendMessage(noPermission);
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(TextComponent
|
||||
.fromLegacyText(ChatColor
|
||||
.translateAlternateColorCodes('&',
|
||||
child.execute(new BungeeCommandExecutor(sender), IntStream
|
||||
.range(0, args.length - 1)
|
||||
.mapToObj(i -> args[i + 1]).toArray(String[]::new)))));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sender.sendMessage(TextComponent
|
||||
.fromLegacyText(ChatColor
|
||||
.translateAlternateColorCodes('&',
|
||||
command.execute(new BungeeCommandExecutor(sender), args))));
|
||||
}
|
||||
});
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user