the basics are working on velocity now
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
package us.ajg0702.queue.commands.commands.listqueues;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.commands.ISubCommand;
|
||||
import us.ajg0702.queue.api.players.AdaptedPlayer;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.commands.BaseCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ListCommand extends BaseCommand {
|
||||
|
||||
private final QueueMain main;
|
||||
|
||||
public ListCommand(QueueMain main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "listqueues";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of("listq");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<ISubCommand> getSubCommands() {
|
||||
return ImmutableList.<ISubCommand>builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "ajqueue.listqueues";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubCommand(ISubCommand subCommand) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!checkPermission(sender)) return;
|
||||
|
||||
AdaptedPlayer spp = null;
|
||||
if(sender.isPlayer()) {
|
||||
spp = main.getPlatformMethods().senderToPlayer(sender);
|
||||
}
|
||||
|
||||
|
||||
Component m = main.getMessages().getComponent("commands.listqueues.header");
|
||||
boolean none = true;
|
||||
for(QueueServer s : main.getQueueManager().getServers()) {
|
||||
none = false;
|
||||
String color = "&a";
|
||||
if(!s.isOnline()) {
|
||||
color = "&c";
|
||||
} else if(!s.isJoinable(spp)) {
|
||||
color = "&e";
|
||||
}
|
||||
|
||||
m = m.append(Component.text("\n"));
|
||||
m = m.append(main.getMessages().getComponent("commands.listqueues.format",
|
||||
"COLOR:" + main.getMessages().color(color),
|
||||
"NAME:" + s.getName(),
|
||||
"COUNT:" + s.getQueue().size(),
|
||||
"STATUS:" + s.getStatusString(spp)
|
||||
));
|
||||
}
|
||||
sender.sendMessage(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package us.ajg0702.queue.commands.commands.manage;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.commands.ISubCommand;
|
||||
import us.ajg0702.queue.commands.BaseCommand;
|
||||
@@ -9,7 +10,9 @@ import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ManageCommand extends BaseCommand {
|
||||
|
||||
@@ -18,7 +21,8 @@ public class ManageCommand extends BaseCommand {
|
||||
public ManageCommand(QueueMain main) {
|
||||
this.main = main;
|
||||
|
||||
|
||||
addSubCommand(new Reload(main));
|
||||
addSubCommand(new Tasks(main));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,11 +60,31 @@ public class ManageCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
|
||||
if(args.length > 0) {
|
||||
for(ISubCommand subCommand : subCommands) {
|
||||
if(args[0].equalsIgnoreCase(subCommand.getName()) || subCommand.getAliases().contains(args[0].toLowerCase(Locale.ROOT))) {
|
||||
subCommand.execute(sender, Arrays.copyOfRange(args, 1, args.length));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.sendMessage(Component.text("/ajQueue <reload|list|send|pause>"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
return null;
|
||||
if(args.length > 0) {
|
||||
for(ISubCommand subCommand : subCommands) {
|
||||
if(args[0].equalsIgnoreCase(subCommand.getName()) || subCommand.getAliases().contains(args[0].toLowerCase(Locale.ROOT))) {
|
||||
return subCommand.autoComplete(sender, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> commands = new ArrayList<>();
|
||||
for(ISubCommand subCommand : subCommands) {
|
||||
commands.add(subCommand.getName());
|
||||
commands.addAll(subCommand.getAliases());
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package us.ajg0702.queue.commands.commands.manage;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.commands.ISubCommand;
|
||||
import us.ajg0702.queue.commands.SubCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Reload extends SubCommand {
|
||||
|
||||
QueueMain main;
|
||||
public Reload(QueueMain main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "ajqueue.reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubCommand(ISubCommand subCommand) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!checkPermission(sender)) return;
|
||||
main.getMessages().reload();
|
||||
try {
|
||||
main.getConfig().reload();
|
||||
} catch (ConfigurateException e) {
|
||||
sender.sendMessage(Component.text("An error occurred while reloading. Check the console").color(NamedTextColor.RED));
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
main.setTimeBetweenPlayers();
|
||||
main.getTaskManager().rescheduleTasks();
|
||||
main.getQueueManager().reloadServers();
|
||||
|
||||
sender.sendMessage(getMessages().getComponent("commands.reload"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package us.ajg0702.queue.commands.commands.manage;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
import us.ajg0702.queue.api.commands.ISubCommand;
|
||||
import us.ajg0702.queue.commands.SubCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Tasks extends SubCommand {
|
||||
|
||||
QueueMain main;
|
||||
public Tasks(QueueMain main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "tasks";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "ajqueue.tasks";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubCommand(ISubCommand subCommand) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!checkPermission(sender)) return;
|
||||
sender.sendMessage(Component.text(main.getTaskManager().taskStatus()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class QueueCommand extends BaseCommand {
|
||||
@@ -26,7 +27,11 @@ public class QueueCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of("move", "server", "joinqueue", "joinq");
|
||||
List<String> aliases = new ArrayList<>(Arrays.asList("move", "joinqueue", "joinq"));
|
||||
if(main.getConfig().getBoolean("enable-server-command")) {
|
||||
aliases.add("server");
|
||||
}
|
||||
return ImmutableList.copyOf(aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user