check if a player is in a queue server and isnt queued
This commit is contained in:
@@ -3,6 +3,7 @@ package us.ajg0702.queue.api;
|
||||
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 java.util.List;
|
||||
|
||||
@@ -42,4 +43,6 @@ public interface PlatformMethods {
|
||||
* @return if the plugin is on the server
|
||||
*/
|
||||
boolean hasPlugin(String pluginName);
|
||||
|
||||
AdaptedServer getServer(String name);
|
||||
}
|
||||
|
||||
@@ -194,8 +194,8 @@ public class QueueManagerImpl implements QueueManager {
|
||||
|
||||
servers.addAll(main.getServerBuilder().buildServers());
|
||||
|
||||
List<String> groupsraw = main.getConfig().getStringList("server-groups");
|
||||
for(String groupraw : groupsraw) {
|
||||
List<String> groupsRaw = main.getConfig().getStringList("server-groups");
|
||||
for(String groupraw : groupsRaw) {
|
||||
if(groupraw.isEmpty()) {
|
||||
main.getLogger().warning("Empty group string! If you dont want server groups, set server-groups like this: server-groups: []");
|
||||
continue;
|
||||
@@ -272,6 +272,21 @@ public class QueueManagerImpl implements QueueManager {
|
||||
|
||||
@Override
|
||||
public void sendQueueEvents() {
|
||||
List<String> svs = main.getConfig().getStringList("queue-servers");
|
||||
for(String s : svs) {
|
||||
if(!s.contains(":")) continue;
|
||||
String[] parts = s.split(":");
|
||||
String fromName = parts[0];
|
||||
String toName = parts[1];
|
||||
AdaptedServer from = main.getPlatformMethods().getServer(fromName);
|
||||
QueueServer to = findServer(toName);
|
||||
if(from == null || to == null) continue;
|
||||
from.getPlayers().forEach(player -> {
|
||||
if(!getPlayerQueues(player).contains(to)) {
|
||||
addToQueue(player, to);
|
||||
}
|
||||
});
|
||||
}
|
||||
for (QueueServer s : servers) {
|
||||
for (QueuePlayer queuePlayer : s.getQueue()) {
|
||||
AdaptedPlayer player = queuePlayer.getPlayer();
|
||||
|
||||
+10
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user