check if a player is in a queue server and isnt queued

This commit is contained in:
ajgeiss0702
2021-07-31 14:11:30 -07:00
parent f644745c24
commit f569353213
4 changed files with 40 additions and 2 deletions
@@ -3,14 +3,17 @@ package us.ajg0702.queue.platforms.bungeecord;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import us.ajg0702.queue.api.PlatformMethods;
import us.ajg0702.queue.api.commands.IBaseCommand;
import us.ajg0702.queue.api.commands.ICommandSender;
import us.ajg0702.queue.api.players.AdaptedPlayer;
import us.ajg0702.queue.api.server.AdaptedServer;
import us.ajg0702.queue.api.util.QueueLogger;
import us.ajg0702.queue.commands.commands.PlayerSender;
import us.ajg0702.queue.platforms.bungeecord.players.BungeePlayer;
import us.ajg0702.queue.platforms.bungeecord.server.BungeeServer;
import java.util.ArrayList;
import java.util.Collection;
@@ -100,4 +103,11 @@ public class BungeeMethods implements PlatformMethods {
public boolean hasPlugin(String pluginName) {
return proxyServer.getPluginManager().getPlugin(pluginName) != null;
}
@Override
public AdaptedServer getServer(String name) {
ServerInfo server = proxyServer.getServerInfo(name);
if(server == null) return null;
return new BungeeServer(server);
}
}
@@ -13,15 +13,18 @@ import us.ajg0702.queue.api.PlatformMethods;
import us.ajg0702.queue.api.commands.IBaseCommand;
import us.ajg0702.queue.api.commands.ICommandSender;
import us.ajg0702.queue.api.players.AdaptedPlayer;
import us.ajg0702.queue.api.server.AdaptedServer;
import us.ajg0702.queue.api.util.QueueLogger;
import us.ajg0702.queue.commands.commands.PlayerSender;
import us.ajg0702.queue.platforms.velocity.players.VelocityPlayer;
import us.ajg0702.queue.platforms.velocity.server.VelocityServer;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
@SuppressWarnings("OptionalIsPresent")
public class VelocityMethods implements PlatformMethods {
final ProxyServer proxyServer;
@@ -122,4 +125,11 @@ public class VelocityMethods implements PlatformMethods {
public boolean hasPlugin(String pluginName) {
return proxyServer.getPluginManager().getPlugin(pluginName.toLowerCase(Locale.ROOT)).isPresent();
}
@Override
public AdaptedServer getServer(String name) {
Optional<RegisteredServer> server = proxyServer.getServer(name);
if(!server.isPresent()) return null;
return new VelocityServer(server.get());
}
}