mirror of
https://github.com/funkemunky/AntiVPN.git
synced 2026-06-03 10:22:21 +00:00
Finished commands system on Bukkit - tested and working
This commit is contained in:
@@ -4,6 +4,8 @@ import dev.brighten.antivpn.api.PlayerExecutor;
|
||||
import dev.brighten.antivpn.api.VPNConfig;
|
||||
import dev.brighten.antivpn.api.VPNExecutor;
|
||||
import dev.brighten.antivpn.command.Command;
|
||||
import dev.brighten.antivpn.command.impl.AntiVPNCommand;
|
||||
import dev.brighten.antivpn.command.impl.LookupCommand;
|
||||
import dev.brighten.antivpn.utils.VPNResponse;
|
||||
import dev.brighten.antivpn.utils.json.JSONException;
|
||||
import dev.brighten.antivpn.utils.json.JSONObject;
|
||||
@@ -39,7 +41,7 @@ public class AntiVPN {
|
||||
INSTANCE.config.update();
|
||||
|
||||
//Registering commands
|
||||
registerCommands();
|
||||
INSTANCE.registerCommands();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
@@ -61,7 +63,8 @@ public class AntiVPN {
|
||||
return VPNResponse.fromJson(result);
|
||||
}
|
||||
|
||||
private static void registerCommands() {
|
||||
|
||||
private void registerCommands() {
|
||||
commands.add(new AntiVPNCommand());
|
||||
commands.add(new LookupCommand());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,6 @@ import dev.brighten.antivpn.AntiVPN;
|
||||
|
||||
public abstract class Command {
|
||||
|
||||
public Command() {
|
||||
for (Command child : children()) {
|
||||
AntiVPN.getInstance().getCommands().add(child);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String permission();
|
||||
|
||||
public abstract String name();
|
||||
@@ -21,8 +15,6 @@ public abstract class Command {
|
||||
public abstract String usage();
|
||||
|
||||
public abstract String parent();
|
||||
|
||||
public abstract Command[] children();
|
||||
|
||||
public abstract String execute(CommandExecutor executor, String[] args);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.brighten.antivpn.command.impl;
|
||||
|
||||
import dev.brighten.antivpn.AntiVPN;
|
||||
import dev.brighten.antivpn.command.Command;
|
||||
import dev.brighten.antivpn.command.CommandExecutor;
|
||||
import dev.brighten.antivpn.utils.StringUtil;
|
||||
@@ -38,11 +39,6 @@ public class AntiVPNCommand extends Command {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Command[] children() {
|
||||
return new Command[] {new LookupCommand()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(CommandExecutor uuid, String[] args) {
|
||||
List<String> messages = new ArrayList<>();
|
||||
@@ -50,8 +46,7 @@ public class AntiVPNCommand extends Command {
|
||||
messages.add(StringUtil.line("&8"));
|
||||
messages.add("&6&lAntiVPN Help Page");
|
||||
messages.add("");
|
||||
messages.add(String.format("&8/&f%s &8- &7&o%s", "antivpn", description()));
|
||||
for (Command child : children()) {
|
||||
for (Command child : AntiVPN.getInstance().getCommands()) {
|
||||
messages.add(String.format("&8/&f%s &8- &7&o%s", "&7antivpn &f" + child.name() + " &7" + child.usage(),
|
||||
description()));
|
||||
}
|
||||
|
||||
@@ -39,11 +39,6 @@ public class LookupCommand extends Command {
|
||||
return "antivpn";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Command[] children() {
|
||||
return new Command[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(CommandExecutor executor, String[] args) {
|
||||
if(args.length == 0) {
|
||||
|
||||
Reference in New Issue
Block a user