more progress

This commit is contained in:
ajgeiss0702
2021-07-12 20:37:09 -07:00
parent 0999c2dee4
commit 5165185ff1
7 changed files with 154 additions and 5 deletions
@@ -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();
}
}
@@ -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));
@@ -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