stuff
This commit is contained in:
@@ -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 <server>");
|
||||
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<String>() {
|
||||
@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);
|
||||
|
||||
}
|
||||
|
||||
@@ -51,6 +51,18 @@ public class Manager {
|
||||
return servers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of all servers
|
||||
* @return The names of all servers
|
||||
*/
|
||||
public List<String> getServerNames() {
|
||||
List<String> 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);
|
||||
|
||||
@@ -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<String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user