leave command + premium stuff
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
mv ajQueue-$1.jar ajQueuePlus-$1.jar
|
||||||
|
mv original-ajQueue-$1.jar ajQueue-$1.jar
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package us.ajg0702.queue;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.plugin.Command;
|
||||||
|
import us.ajg0702.queue.utils.BungeeMessages;
|
||||||
|
|
||||||
|
public class LeaveCommand extends Command {
|
||||||
|
Main plugin;
|
||||||
|
BungeeMessages msgs;
|
||||||
|
public LeaveCommand(Main pl) {
|
||||||
|
super("leavequeue");
|
||||||
|
this.plugin = pl;
|
||||||
|
msgs = BungeeMessages.getInstance();
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
if(!(sender instanceof ProxiedPlayer)) {
|
||||||
|
sender.sendMessage(msgs.getBC("errors.player-only"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
|
String queue = plugin.getPlayerInQueue((ProxiedPlayer) sender);
|
||||||
|
if(queue != null) {
|
||||||
|
plugin.queues.get(queue).remove(p);
|
||||||
|
p.sendMessage(msgs.getBC("commands.leave-queue"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.bstats.bungeecord.Metrics;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.Callback;
|
import net.md_5.bungee.api.Callback;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.ServerPing;
|
import net.md_5.bungee.api.ServerPing;
|
||||||
@@ -21,18 +19,21 @@ import net.md_5.bungee.api.plugin.Plugin;
|
|||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
import us.ajg0702.queue.utils.BungeeConfig;
|
import us.ajg0702.queue.utils.BungeeConfig;
|
||||||
import us.ajg0702.queue.utils.BungeeMessages;
|
import us.ajg0702.queue.utils.BungeeMessages;
|
||||||
|
import us.ajg0702.queue.utils.BungeeStats;
|
||||||
|
|
||||||
public class Main extends Plugin implements Listener {
|
public class Main extends Plugin implements Listener {
|
||||||
|
|
||||||
int timeBetweenPlayers = 5;
|
int timeBetweenPlayers = 5;
|
||||||
int offlineSecs = 120;
|
int offlineSecs = 120;
|
||||||
|
|
||||||
Metrics metrics;
|
BungeeStats metrics;
|
||||||
|
|
||||||
BungeeMessages msgs;
|
BungeeMessages msgs;
|
||||||
|
|
||||||
BungeeConfig config;
|
BungeeConfig config;
|
||||||
|
|
||||||
|
boolean isp;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ public class Main extends Plugin implements Listener {
|
|||||||
|
|
||||||
this.getProxy().getPluginManager().registerCommand(this, new MoveCommand(this));
|
this.getProxy().getPluginManager().registerCommand(this, new MoveCommand(this));
|
||||||
this.getProxy().getPluginManager().registerCommand(this, new ManageCommand(this));
|
this.getProxy().getPluginManager().registerCommand(this, new ManageCommand(this));
|
||||||
|
this.getProxy().getPluginManager().registerCommand(this, new LeaveCommand(this));
|
||||||
|
|
||||||
this.getProxy().getPluginManager().registerListener(this, this);
|
this.getProxy().getPluginManager().registerListener(this, this);
|
||||||
|
|
||||||
@@ -49,6 +51,13 @@ public class Main extends Plugin implements Listener {
|
|||||||
|
|
||||||
updateOnlineServers();
|
updateOnlineServers();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Class.forName("us.ajg0702.queue.Logic");
|
||||||
|
isp = true;
|
||||||
|
} catch(ClassNotFoundException e) {
|
||||||
|
isp = false;
|
||||||
|
}
|
||||||
|
|
||||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
updateOnlineServers();
|
updateOnlineServers();
|
||||||
@@ -57,7 +66,7 @@ public class Main extends Plugin implements Listener {
|
|||||||
}, 5, timeBetweenPlayers, TimeUnit.SECONDS);
|
}, 5, timeBetweenPlayers, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
|
||||||
metrics = new Metrics(this, 7404);
|
metrics = new BungeeStats(this, 7404);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -212,6 +221,7 @@ public class Main extends Plugin implements Listener {
|
|||||||
|
|
||||||
HashMap<String, List<ProxiedPlayer>> queues = new HashMap<>();
|
HashMap<String, List<ProxiedPlayer>> queues = new HashMap<>();
|
||||||
public void addToQueue(ProxiedPlayer p, String server) {
|
public void addToQueue(ProxiedPlayer p, String server) {
|
||||||
|
//getLogger().info("adding "+p.getDisplayName()+" to queue "+server);
|
||||||
if(!servers.containsKey(server)) {
|
if(!servers.containsKey(server)) {
|
||||||
p.sendMessage(msgs.getBC("errors.server-not-exist"));
|
p.sendMessage(msgs.getBC("errors.server-not-exist"));
|
||||||
return;
|
return;
|
||||||
@@ -239,6 +249,9 @@ public class Main extends Plugin implements Listener {
|
|||||||
queues.get(currentQueued).remove(p);
|
queues.get(currentQueued).remove(p);
|
||||||
p.sendMessage(msgs.getBC("status.left-last-queue"));
|
p.sendMessage(msgs.getBC("status.left-last-queue"));
|
||||||
}
|
}
|
||||||
|
if(isp) {
|
||||||
|
us.ajg0702.queue.Logic.priorityLogic(list, p);
|
||||||
|
} else {
|
||||||
if(p.hasPermission("ajqueue.priority") && list.size() > 0) {
|
if(p.hasPermission("ajqueue.priority") && list.size() > 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(ProxiedPlayer ply : list) {
|
for(ProxiedPlayer ply : list) {
|
||||||
@@ -254,6 +267,7 @@ public class Main extends Plugin implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
list.add(p);
|
list.add(p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
int pos = list.indexOf(p)+1;
|
int pos = list.indexOf(p)+1;
|
||||||
int len = list.size();
|
int len = list.size();
|
||||||
p.sendMessage(formatMessage(
|
p.sendMessage(formatMessage(
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ public class ManageCommand extends Command {
|
|||||||
sender.sendMessage(Main.formatMessage(msgs.get("list.total").replaceAll("\\{TOTAL\\}", total+"")));
|
sender.sendMessage(Main.formatMessage(msgs.get("list.total").replaceAll("\\{TOTAL\\}", total+"")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(args[0].equalsIgnoreCase("p")) {
|
||||||
|
sender.sendMessage(Main.formatMessage(pl.isp+""));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(Main.formatMessage("/ajqueue <reload|list>"));
|
sender.sendMessage(Main.formatMessage("/ajqueue <reload|list>"));
|
||||||
|
|||||||
Reference in New Issue
Block a user