antispam sending now message

This commit is contained in:
ajgeiss0702
2020-09-23 10:47:47 -07:00
parent 0b47fde43f
commit 9ce71b84c5
+45 -26
View File
@@ -484,6 +484,9 @@ public class Manager {
public void sendPlayers() { public void sendPlayers() {
sendPlayers(null); sendPlayers(null);
} }
HashMap<ProxiedPlayer, Long> sendingNowAntiSpam = new HashMap<>();
/** /**
* Attempts to send the first player in this queue * Attempts to send the first player in this queue
* @param server The server to send the first player in the queue. null for all servers. * @param server The server to send the first player in the queue. null for all servers.
@@ -506,18 +509,22 @@ public class Manager {
HashMap<ServerInfo, ServerPing> serverInfos = s.getLastPings(); HashMap<ServerInfo, ServerPing> serverInfos = s.getLastPings();
ServerInfo selected = null; ServerInfo selected = null;
int selectednum = 0; int selectednum = 0;
for(ServerInfo si : serverInfos.keySet()) { if(serverInfos.keySet().size() == 1) {
ServerPing sp = serverInfos.get(si); selected = serverInfos.keySet().iterator().next();
int online = sp.getPlayers().getOnline(); } else {
if(selected == null) { for(ServerInfo si : serverInfos.keySet()) {
selected = si; ServerPing sp = serverInfos.get(si);
selectednum = online; int online = sp.getPlayers().getOnline();
continue; if(selected == null) {
} selected = si;
if(selectednum > online && findServer(si.getName()).isJoinable(p)) { selectednum = online;
selected = si; continue;
selectednum = online; }
continue; if(selectednum > online && findServer(si.getName()).isJoinable(p)) {
selected = si;
selectednum = online;
continue;
}
} }
} }
if(selected == null) { if(selected == null) {
@@ -549,23 +556,35 @@ public class Manager {
if(s.getQueue().size() <= 0) continue; if(s.getQueue().size() <= 0) continue;
if(s.isFull() && !nextplayer.hasPermission("ajqueue.joinfull")) continue; if(s.isFull() && !nextplayer.hasPermission("ajqueue.joinfull")) continue;
nextplayer.sendMessage(Main.formatMessage(msgs.get("status.sending-now").replaceAll("\\{SERVER\\}", pl.aliases.getAlias(name))));
if(!sendingNowAntiSpam.containsKey(nextplayer)) {
sendingNowAntiSpam.put(nextplayer, (long) 0);
}
if(System.currentTimeMillis() - sendingNowAntiSpam.get(nextplayer) >= 5000) {
nextplayer.sendMessage(msgs.getBC("status.sending-now", "SERVER:"+pl.aliases.getAlias(s.getName())));
sendingNowAntiSpam.put(nextplayer, System.currentTimeMillis());
}
HashMap<ServerInfo, ServerPing> serverInfos = s.getLastPings(); HashMap<ServerInfo, ServerPing> serverInfos = s.getLastPings();
ServerInfo selected = null; ServerInfo selected = null;
int selectednum = 0; int selectednum = 0;
for(ServerInfo si : serverInfos.keySet()) { if(serverInfos.keySet().size() == 1) {
ServerPing sp = serverInfos.get(si); selected = serverInfos.keySet().iterator().next();
if(sp == null) continue; } else {
int online = sp.getPlayers().getOnline(); for(ServerInfo si : serverInfos.keySet()) {
if(selected == null) { ServerPing sp = serverInfos.get(si);
selected = si; int online = sp.getPlayers().getOnline();
selectednum = online; if(selected == null) {
continue; selected = si;
} selectednum = online;
if(selectednum > online && findServer(si.getName()).isJoinable(nextplayer)) { continue;
selected = si; }
selectednum = online; if(selectednum > online && findServer(si.getName()).isJoinable(nextplayer)) {
continue; selected = si;
selectednum = online;
continue;
}
} }
} }
if(selected == null) { if(selected == null) {