Skip to content

Commit

Permalink
Fixed PositionChangeEvent being called when a player's position didn'…
Browse files Browse the repository at this point in the history
…t change
  • Loading branch information
ajgeiss0702 committed Jun 10, 2023
1 parent 49a3812 commit fa9f594
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Expand Up @@ -21,6 +21,8 @@ public class QueuePlayerImpl implements QueuePlayer {

private final int maxOfflineTime;

public int lastPosition;

public QueuePlayerImpl(UUID uuid, String name, QueueServer server, int highestPriority, int maxOfflineTime) {
this(null, name, uuid, server, highestPriority, maxOfflineTime);
}
Expand All @@ -39,6 +41,8 @@ private QueuePlayerImpl(@Nullable AdaptedPlayer player, String name, @NotNull UU
this.name = name;

this.maxOfflineTime = maxOfflineTime;

lastPosition = getPosition();
}

@Override
Expand Down
Expand Up @@ -321,7 +321,11 @@ public Balancer getBalancer() {

private void positionChange() {
main.getTaskManager().runNow(
() -> queue.forEach(queuePlayer -> main.call(new PositionChangeEvent(queuePlayer)))
() -> queue.forEach(queuePlayer -> {
if(((QueuePlayerImpl) queuePlayer).lastPosition != queuePlayer.getPosition()) {
main.call(new PositionChangeEvent(queuePlayer));
}
})
);
}

Expand Down

0 comments on commit fa9f594

Please sign in to comment.