add /listqueues
This commit is contained in:
@@ -19,6 +19,7 @@ import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import us.ajg0702.queue.commands.LeaveCommand;
|
||||
import us.ajg0702.queue.commands.ListCommand;
|
||||
import us.ajg0702.queue.commands.ManageCommand;
|
||||
import us.ajg0702.queue.commands.MoveCommand;
|
||||
import us.ajg0702.utils.bungee.BungeeConfig;
|
||||
@@ -111,6 +112,9 @@ public class Main extends Plugin implements Listener {
|
||||
d.put("commands.pause.paused.true", "&epaused");
|
||||
d.put("commands.pause.paused.false", "&aun-paused");
|
||||
|
||||
d.put("commands.listqueues.header", "&9Queues:");
|
||||
d.put("commands.listqueues.format", "{COLOR}{NAME}&7: {COUNT} queued");
|
||||
|
||||
d.put("max-tries-reached", "&cUnable to connect to {SERVER}. Max retries reached.");
|
||||
|
||||
msgs = BungeeMessages.getInstance(this, d);
|
||||
@@ -121,6 +125,7 @@ public class Main extends Plugin implements Listener {
|
||||
this.getProxy().getPluginManager().registerCommand(this, moveCommand);
|
||||
this.getProxy().getPluginManager().registerCommand(this, new ManageCommand(this));
|
||||
this.getProxy().getPluginManager().registerCommand(this, new LeaveCommand(this));
|
||||
this.getProxy().getPluginManager().registerCommand(this, new ListCommand(this));
|
||||
|
||||
this.getProxy().getPluginManager().registerListener(this, this);
|
||||
|
||||
|
||||
@@ -154,6 +154,7 @@ public class QueueServer {
|
||||
* @return if the player can join based on bungeecord's restricted servers system
|
||||
*/
|
||||
public boolean canAccess(ProxiedPlayer ply) {
|
||||
if(ply == null) return true;
|
||||
boolean ca = false;
|
||||
for(ServerInfo si : servers) {
|
||||
if(si.canAccess(ply)) {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package us.ajg0702.queue.commands;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import us.ajg0702.queue.Main;
|
||||
import us.ajg0702.queue.Manager;
|
||||
import us.ajg0702.queue.QueueServer;
|
||||
import us.ajg0702.utils.bungee.BungeeMessages;
|
||||
|
||||
public class ListCommand extends Command {
|
||||
Main pl;
|
||||
BungeeMessages msgs;
|
||||
|
||||
public ListCommand(Main pl) {
|
||||
super("listqueues", null, "listq");
|
||||
this.pl = pl;
|
||||
msgs = BungeeMessages.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("ajqueue.listqueues")) {
|
||||
sender.sendMessage(msgs.getBC("noperm"));
|
||||
return;
|
||||
}
|
||||
|
||||
ProxiedPlayer spp = null;
|
||||
if(sender instanceof ProxiedPlayer) {
|
||||
spp = (ProxiedPlayer) sender;
|
||||
}
|
||||
|
||||
String m = msgs.get("commands.listqueues.header");
|
||||
for(QueueServer s : Manager.getInstance().getServers()) {
|
||||
String color = "&a";
|
||||
if(!s.isOnline()) {
|
||||
color = "&c";
|
||||
} else if(!s.isJoinable(spp)) {
|
||||
color = "&e";
|
||||
}
|
||||
m += "\n"+msgs.get("commands.listqueues.format")
|
||||
.replaceAll("\\{COLOR\\}", msgs.color(color))
|
||||
.replaceAll("\\{NAME\\}", s.getName())
|
||||
.replaceAll("\\{COUNT\\}", s.getQueue().size()+"");
|
||||
}
|
||||
|
||||
sender.sendMessage(TextComponent.fromLegacyText(m));
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user