Skip to content

Commit

Permalink
Tiny changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Nov 13, 2022
1 parent d6c9e3e commit ffa466b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,14 @@ default void initializeReservationSlots() {
for (PlayerWrapper player : targetServer.get().getConnectedPlayers()) {
QueueType playerType = QueueType.getQueueType(player::hasPermission);

if (map.containsKey(playerType)) {
map.get(playerType).incrementAndGet();
} else {
map.put(playerType, new AtomicInteger(1));
}
map.compute(playerType, (queueType, integer) -> {
if (integer == null) {
return new AtomicInteger(1);
} else {
integer.incrementAndGet();
return integer;
}
});
}

map.forEach((type, count) -> type.getPlayersWithTypeInTarget().set(count.get()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ private boolean isServerFull(QueueType type) {
return isTargetFull(type) || isAnyoneQueuedOfType(type);
}

private int getFreeSlots(QueueType type) {
return type.getReservedSlots() - type.getPlayersWithTypeInTarget().get();
}

private boolean isTargetFull(QueueType type) {
return getFreeSlots(type) <= 0;
}

private int getFreeSlots(QueueType type) {
return type.getReservedSlots() - type.getPlayersWithTypeInTarget().get();
}

private boolean isAnyoneQueuedOfType(QueueType type) {
return !type.getQueueMap().isEmpty();
}
Expand Down

0 comments on commit ffa466b

Please sign in to comment.