Prevent empty stack exception in PlayerListener

An additional condition is added to prevent an exception from being thrown when attempting to peek an empty stack in the PlayerListener.java file. This should resolve issues where checking if the playerDeathsStack is before the cut off time caused an empty stack exception error.
This commit is contained in:
Teriuihi 2024-04-28 21:38:12 +02:00
parent de24ca4437
commit 99f66c3b4b

View File

@ -103,7 +103,7 @@ public class PlayerListener implements Listener {
Stack<Instant> playerDeathsStack = sendPlayerDeaths.computeIfAbsent(uuid, key -> new Stack<>());
Instant cutOff = Instant.now().minus(Config.DEATH_MESSAGES_LIMIT_PERIOD_MINUTES, ChronoUnit.MINUTES);
while (playerDeathsStack.peek().isBefore(cutOff)) {
while (!playerDeathsStack.isEmpty() && playerDeathsStack.peek().isBefore(cutOff)) {
playerDeathsStack.pop();
}