more progress
This commit is contained in:
@@ -31,4 +31,6 @@ public interface PlatformMethods {
|
||||
*/
|
||||
AdaptedPlayer senderToPlayer(ICommandSender sender);
|
||||
|
||||
String getPluginVersion();
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ public class ManageCommand extends BaseCommand {
|
||||
|
||||
addSubCommand(new Reload(main));
|
||||
addSubCommand(new Tasks(main));
|
||||
addSubCommand(new Version(main));
|
||||
addSubCommand(new Pause(main));
|
||||
}
|
||||
|
||||
|
||||
@@ -72,12 +74,13 @@ public class ManageCommand extends BaseCommand {
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
if(args.length > 0) {
|
||||
if(args.length > 1) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> commands = new ArrayList<>();
|
||||
for(ISubCommand subCommand : subCommands) {
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
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.queues.QueueServer;
|
||||
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.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Pause extends SubCommand {
|
||||
|
||||
final QueueMain main;
|
||||
public Pause(QueueMain main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "pause";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "ajqueue.pause";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!checkPermission(sender)) return;
|
||||
|
||||
if(args.length < 1) {
|
||||
sender.sendMessage(getMessages().getComponent("commands.pause.more-args"));
|
||||
return;
|
||||
}
|
||||
|
||||
QueueServer server = main.getQueueManager().findServer(args[0]);
|
||||
if(server == null) {
|
||||
sender.sendMessage(getMessages().getComponent("commands.pause.no-server", "SERVER:"+args[1]));
|
||||
return;
|
||||
}
|
||||
if(args.length == 1) {
|
||||
server.setPaused(!server.isPaused());
|
||||
} else {
|
||||
server.setPaused(args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true"));
|
||||
}
|
||||
sender.sendMessage(getMessages().getComponent("commands.pause.success",
|
||||
"SERVER:"+server.getName(),
|
||||
"PAUSED:"+getMessages().getString("commands.pause.paused."+server.isPaused())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
if(args.length == 1) {
|
||||
return main.getQueueManager().getServerNames();
|
||||
}
|
||||
if(args.length == 2) {
|
||||
return Arrays.asList("on", "off", "true", "false");
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
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.commands.SubCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
import us.ajg0702.utils.common.Messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Version extends SubCommand {
|
||||
|
||||
final QueueMain main;
|
||||
public Version(QueueMain main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "version";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<String> getAliases() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "ajqueue.version";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Messages getMessages() {
|
||||
return main.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(ICommandSender sender, String[] args) {
|
||||
if(!checkPermission(sender)) return;
|
||||
sender.sendMessage(Component.text(main.getPlatformMethods().getPluginVersion()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
+13
-2
@@ -1,5 +1,6 @@
|
||||
package us.ajg0702.queue.platforms.velocity;
|
||||
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -10,14 +11,15 @@ import us.ajg0702.queue.api.players.QueuePlayer;
|
||||
import us.ajg0702.queue.api.queues.QueueServer;
|
||||
import us.ajg0702.queue.platforms.velocity.players.VelocityPlayer;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PlatformMethodImpl implements PlatformMethods {
|
||||
public class PlatformMethodsImpl implements PlatformMethods {
|
||||
|
||||
final ProxyServer proxyServer;
|
||||
final Logger logger;
|
||||
|
||||
public PlatformMethodImpl(ProxyServer proxyServer, Logger logger) {
|
||||
public PlatformMethodsImpl(ProxyServer proxyServer, Logger logger) {
|
||||
this.proxyServer = proxyServer;
|
||||
this.logger = logger;
|
||||
}
|
||||
@@ -38,4 +40,13 @@ public class PlatformMethodImpl implements PlatformMethods {
|
||||
public AdaptedPlayer senderToPlayer(ICommandSender sender) {
|
||||
return new VelocityPlayer((Player) sender.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginVersion() {
|
||||
Optional<PluginContainer> plugin = proxyServer.getPluginManager().getPlugin("ajqueue");
|
||||
if(plugin.isEmpty()) return "?E";
|
||||
Optional<String> version = plugin.get().getDescription().getVersion();
|
||||
if(version.isEmpty()) return "?V";
|
||||
return version.get();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class VelocityQueue {
|
||||
public void onProxyInit(ProxyInitializeEvent e) {
|
||||
main = new QueueMain(
|
||||
logger,
|
||||
new PlatformMethodImpl(proxyServer, logger),
|
||||
new PlatformMethodsImpl(proxyServer, logger),
|
||||
dataFolder
|
||||
);
|
||||
main.setServerBuilder(new ServerBuilderImpl(main, proxyServer));
|
||||
|
||||
+7
-1
@@ -4,6 +4,8 @@ import com.velocitypowered.api.command.RawCommand;
|
||||
import us.ajg0702.queue.commands.BaseCommand;
|
||||
import us.ajg0702.queue.common.QueueMain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class VelocityCommand implements RawCommand {
|
||||
@@ -23,7 +25,11 @@ public class VelocityCommand implements RawCommand {
|
||||
|
||||
@Override
|
||||
public List<String> suggest(final Invocation invocation) {
|
||||
return command.autoComplete(new VelocitySender(invocation.source()), invocation.arguments().split(" "));
|
||||
List<String> args = new ArrayList<>(Arrays.asList(invocation.arguments().split(" ")));
|
||||
if(invocation.arguments().length() > 0 &&invocation.arguments().charAt(invocation.arguments().length()-1) == ' ') {
|
||||
args.add(" ");
|
||||
}
|
||||
return command.autoComplete(new VelocitySender(invocation.source()), args.toArray(new String[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user