improvements to sendingAttempts clearing
This commit is contained in:
@@ -5,7 +5,7 @@ import us.ajg0702.queue.api.players.AdaptedPlayer;
|
|||||||
import us.ajg0702.queue.api.players.QueuePlayer;
|
import us.ajg0702.queue.api.players.QueuePlayer;
|
||||||
import us.ajg0702.queue.api.queues.QueueServer;
|
import us.ajg0702.queue.api.queues.QueueServer;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface QueueManager {
|
public interface QueueManager {
|
||||||
|
|
||||||
@@ -133,5 +133,5 @@ public interface QueueManager {
|
|||||||
|
|
||||||
void clear(AdaptedPlayer player);
|
void clear(AdaptedPlayer player);
|
||||||
|
|
||||||
HashMap<QueuePlayer, Integer> getSendingAttempts();
|
Map<QueuePlayer, Integer> getSendingAttempts();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -522,7 +522,7 @@ public class QueueManagerImpl implements QueueManager {
|
|||||||
|
|
||||||
|
|
||||||
final ConcurrentHashMap<AdaptedPlayer, Long> sendingNowAntiSpam = new ConcurrentHashMap<>();
|
final ConcurrentHashMap<AdaptedPlayer, Long> sendingNowAntiSpam = new ConcurrentHashMap<>();
|
||||||
final HashMap<QueuePlayer, Integer> sendingAttempts = new HashMap<>();
|
final Map<QueuePlayer, Integer> sendingAttempts = new WeakHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPlayers(QueueServer queueServer) {
|
public void sendPlayers(QueueServer queueServer) {
|
||||||
@@ -600,7 +600,7 @@ public class QueueManagerImpl implements QueueManager {
|
|||||||
if(server.isPaused() && !nextPlayer.hasPermission("ajqueue.bypasspaused")) continue;
|
if(server.isPaused() && !nextPlayer.hasPermission("ajqueue.bypasspaused")) continue;
|
||||||
} else if(server.isPaused()) { continue; }
|
} else if(server.isPaused()) { continue; }
|
||||||
|
|
||||||
int tries = sendingAttempts.get(nextQueuePlayer) == null ? 0 : sendingAttempts.get(nextQueuePlayer);
|
int tries = sendingAttempts.getOrDefault(nextQueuePlayer, 0);
|
||||||
int maxTries = main.getConfig().getInt("max-tries");
|
int maxTries = main.getConfig().getInt("max-tries");
|
||||||
if(tries >= maxTries && maxTries > 0) {
|
if(tries >= maxTries && maxTries > 0) {
|
||||||
server.removePlayer(nextQueuePlayer);
|
server.removePlayer(nextQueuePlayer);
|
||||||
@@ -678,7 +678,7 @@ public class QueueManagerImpl implements QueueManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<QueuePlayer, Integer> getSendingAttempts() {
|
public Map<QueuePlayer, Integer> getSendingAttempts() {
|
||||||
return sendingAttempts;
|
return sendingAttempts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -329,6 +329,7 @@ public class QueueServerImpl implements QueueServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void removePlayer(QueuePlayer player) {
|
public synchronized void removePlayer(QueuePlayer player) {
|
||||||
|
main.getQueueManager().getSendingAttempts().remove(player);
|
||||||
queue.remove(player);
|
queue.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user