diff --git a/src/main/java/us/ajg0702/queue/Main.java b/src/main/java/us/ajg0702/queue/Main.java index e69abe5..16752c9 100644 --- a/src/main/java/us/ajg0702/queue/Main.java +++ b/src/main/java/us/ajg0702/queue/Main.java @@ -99,6 +99,9 @@ public class Main extends Plugin implements Listener { d.put("commands.leave.not-queued", "&cYou are not queued for that server! &7You are in these queues: {QUEUES}"); d.put("commands.leave.no-queues", "&cYou are not queued!"); + d.put("commands.pause.more-args", "&cUsage: /ajqueue pause "); + d.put("commands.pause.no-server", "&cThat server does not exist!"); + msgs = BungeeMessages.getInstance(this, d); //msgs = BungeeMessages.getInstance(this); @@ -125,12 +128,7 @@ public class Main extends Plugin implements Listener { metrics = new BungeeStats(this, 7404); - metrics.addCustomChart(new BungeeStats.SimplePie("premium", new Callable() { - @Override - public String call() throws Exception { - return isp+""; - } - })); + metrics.addCustomChart(new BungeeStats.SimplePie("premium", () -> isp+"")); } @@ -232,7 +230,7 @@ public class Main extends Plugin implements Listener { String data = in.readUTF(); String[] args = new String[1]; args[0] = data; - moveCommand.execute((CommandSender) player, args); + moveCommand.execute(player, args); //man.addToQueue(player, data); } diff --git a/src/main/java/us/ajg0702/queue/Manager.java b/src/main/java/us/ajg0702/queue/Manager.java index caf4266..d0df0df 100644 --- a/src/main/java/us/ajg0702/queue/Manager.java +++ b/src/main/java/us/ajg0702/queue/Manager.java @@ -51,6 +51,18 @@ public class Manager { return servers; } + /** + * Returns the name of all servers + * @return The names of all servers + */ + public List getServerNames() { + List names = new ArrayList<>(); + for(Server s : servers) { + names.add(s.getName()); + } + return names; + } + int sendId = -1; @@ -384,6 +396,7 @@ public class Manager { String name = s.getName(); if(server != null && !server.equals(name)) continue; if(!s.isOnline()) continue; + if(s.isPaused()) continue; if(s.getQueue().size() <= 0) continue; ProxiedPlayer nextplayer = s.getQueue().get(0); diff --git a/src/main/java/us/ajg0702/queue/Server.java b/src/main/java/us/ajg0702/queue/Server.java index 9b4f538..fbbad46 100644 --- a/src/main/java/us/ajg0702/queue/Server.java +++ b/src/main/java/us/ajg0702/queue/Server.java @@ -98,7 +98,11 @@ public class Server { return queue; } - + /** + * If the player can access the server. (Bungeecord's restricted servers) + * @param ply The player + * @return if the player can join based on bungeecord's restricted servers system + */ public boolean canAccess(ProxiedPlayer ply) { return info.canAccess(ply); } @@ -121,4 +125,27 @@ public class Server { public List getWhitelistedPlayers() { return whitelistedplayers; } + + /** + * If the server is joinable as a player + * @param p The player + * @return If the player can join the server + */ + public boolean isJoinable(ProxiedPlayer p) { + return (!whitelisted || whitelistedplayers.contains(p.getName())) && + this.isOnline() && + this.canAccess(p) && + this.isFull() && + !this.isPaused(); + + } + + + boolean paused = false; + public boolean isPaused() { + return paused; + } + public void setPaused(boolean to) { + paused = to; + } } diff --git a/src/main/java/us/ajg0702/queue/commands/ManageCommand.java b/src/main/java/us/ajg0702/queue/commands/ManageCommand.java index 01cf097..e148e6e 100644 --- a/src/main/java/us/ajg0702/queue/commands/ManageCommand.java +++ b/src/main/java/us/ajg0702/queue/commands/ManageCommand.java @@ -1,8 +1,5 @@ package us.ajg0702.queue.commands; -import java.util.ArrayList; -import java.util.List; - import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Command; @@ -11,6 +8,9 @@ import us.ajg0702.queue.Manager; import us.ajg0702.queue.Server; import us.ajg0702.utils.bungee.BungeeMessages; +import java.util.ArrayList; +import java.util.List; + public class ManageCommand extends Command { Main pl; @@ -78,8 +78,29 @@ public class ManageCommand extends Command { sender.sendMessage(Main.formatMessage(pl.getDescription().getVersion())); return; } + if(args[0].equalsIgnoreCase("pause")) { + if(!sender.hasPermission("ajqueue.pause")) { + sender.sendMessage(msgs.getBC("noperm")); + return; + } + sender.sendMessage(msgs.getBC("commands.pause.more-args")); + } } if(args.length == 2) { + if(args[0].equalsIgnoreCase("pause")) { + if(!sender.hasPermission("ajqueue.pause")) { + sender.sendMessage(msgs.getBC("noperm")); + return; + } + if(!Manager.getInstance().getServerNames().contains(args[1])) { + sender.sendMessage(msgs.getBC("")); + return; + } + + return; + } + + if(!sender.hasPermission("ajqueue.send")) { sender.sendMessage(msgs.getBC("noperm")); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index cef6474..95aa3e2 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -91,7 +91,7 @@ wait-after-online: 1 # This is for helping with finding issues with the server pinged -# This will spam the console when ehabled +# This will spam the console when enabled # When this enabled, if servers are offline then it will spam errors. You can ignore them. # Default: false pinger-debug: false