improvements to sendingAttempts clearing

This commit is contained in:
ajgeiss0702
2022-01-24 13:02:05 -07:00
parent ffa132fee3
commit d10400cb74
3 changed files with 6 additions and 5 deletions
@@ -5,7 +5,7 @@ import us.ajg0702.queue.api.players.AdaptedPlayer;
import us.ajg0702.queue.api.players.QueuePlayer;
import us.ajg0702.queue.api.queues.QueueServer;
import java.util.HashMap;
import java.util.Map;
public interface QueueManager {
@@ -133,5 +133,5 @@ public interface QueueManager {
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 HashMap<QueuePlayer, Integer> sendingAttempts = new HashMap<>();
final Map<QueuePlayer, Integer> sendingAttempts = new WeakHashMap<>();
@Override
public void sendPlayers(QueueServer queueServer) {
@@ -600,7 +600,7 @@ public class QueueManagerImpl implements QueueManager {
if(server.isPaused() && !nextPlayer.hasPermission("ajqueue.bypasspaused")) 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");
if(tries >= maxTries && maxTries > 0) {
server.removePlayer(nextQueuePlayer);
@@ -678,7 +678,7 @@ public class QueueManagerImpl implements QueueManager {
}
@Override
public HashMap<QueuePlayer, Integer> getSendingAttempts() {
public Map<QueuePlayer, Integer> getSendingAttempts() {
return sendingAttempts;
}
}
@@ -329,6 +329,7 @@ public class QueueServerImpl implements QueueServer {
@Override
public synchronized void removePlayer(QueuePlayer player) {
main.getQueueManager().getSendingAttempts().remove(player);
queue.remove(player);
}