add slash server aliases
This commit is contained in:
+55
@@ -0,0 +1,55 @@
|
||||
package us.ajg0702.queue.commands.commands.SlashServer;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import us.ajg0702.queue.api.commands.ICommandSender;
|
||||
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.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class SlashServerCommand extends BaseCommand {
|
||||
|
||||
final QueueMain main;
|
||||
final String server;
|
||||
public SlashServerCommand(QueueMain main, String server) {
|
||||
this.main = main;
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!sender.isPlayer()) {
|
||||
sender.sendMessage(getMessages().getComponent("errors.player-only"));
|
||||
return;
|
||||
}
|
||||
main.getQueueManager().addToQueue(main.getPlatformMethods().senderToPlayer(sender), server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ public class Reload extends SubCommand {
|
||||
main.getTaskManager().rescheduleTasks();
|
||||
main.getQueueManager().reloadServers();
|
||||
main.getMessages().reload();
|
||||
main.getSlashServerManager().reload();
|
||||
|
||||
main.getUpdater().setEnabled(main.getConfig().getBoolean("enable-updater"));
|
||||
|
||||
|
||||
@@ -107,6 +107,16 @@ public class QueueMain extends AjQueueAPI {
|
||||
return updater;
|
||||
}
|
||||
|
||||
private final Implementation implementation;
|
||||
public Implementation getImplementation() {
|
||||
return implementation;
|
||||
}
|
||||
|
||||
private SlashServerManager slashServerManager;
|
||||
public SlashServerManager getSlashServerManager() {
|
||||
return slashServerManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
taskManager.shutdown();
|
||||
@@ -117,7 +127,8 @@ public class QueueMain extends AjQueueAPI {
|
||||
private final File dataFolder;
|
||||
|
||||
|
||||
public QueueMain(QueueLogger logger, PlatformMethods platformMethods, File dataFolder) {
|
||||
public QueueMain(Implementation implementation, QueueLogger logger, PlatformMethods platformMethods, File dataFolder) {
|
||||
this.implementation = implementation;
|
||||
|
||||
logicGetter = new LogicGetterImpl();
|
||||
|
||||
@@ -147,6 +158,8 @@ public class QueueMain extends AjQueueAPI {
|
||||
return;
|
||||
}
|
||||
|
||||
slashServerManager = new SlashServerManager(this);
|
||||
|
||||
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
messages.getComponent("one").replaceText(b -> b.match(Pattern.compile("\\e")).replacement("a"));
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package us.ajg0702.queue.common;
|
||||
|
||||
import us.ajg0702.queue.api.Implementation;
|
||||
import us.ajg0702.queue.commands.commands.SlashServer.SlashServerCommand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SlashServerManager {
|
||||
|
||||
private final List<SlashServerCommand> serverCommands = new ArrayList<>();
|
||||
|
||||
private final QueueMain main;
|
||||
private final Implementation implementation;
|
||||
public SlashServerManager(QueueMain main) {
|
||||
this.main = main;
|
||||
this.implementation = this.main.getImplementation();
|
||||
reload();
|
||||
}
|
||||
public void reload() {
|
||||
serverCommands.forEach(implementation::unregisterCommand);
|
||||
serverCommands.clear();
|
||||
|
||||
List<String> slashServerServers = main.getConfig().getStringList("slash-servers");
|
||||
for(String server : slashServerServers) {
|
||||
SlashServerCommand command = new SlashServerCommand(main, server);
|
||||
serverCommands.add(command);
|
||||
implementation.registerCommand(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
# Dont touch this number please
|
||||
config-version: 28
|
||||
config-version: 29
|
||||
|
||||
|
||||
# This is the main config for ajQueue.
|
||||
@@ -261,4 +261,10 @@ protocol-names:
|
||||
velocity-kick-message: false
|
||||
|
||||
# Should the updater be enabled?
|
||||
enable-updater: true
|
||||
enable-updater: true
|
||||
|
||||
# What servers should we make slash server commands for?
|
||||
# For example, if survival is in this list, then if a player executes /survival
|
||||
# then they will be put in the queue for survival
|
||||
# This works for both servers and groups
|
||||
slash-servers: []
|
||||
Reference in New Issue
Block a user