Fixed PositionChangeEvent being called when a player's position didn't change
This commit is contained in:
@@ -21,6 +21,8 @@ public class QueuePlayerImpl implements QueuePlayer {
|
|||||||
|
|
||||||
private final int maxOfflineTime;
|
private final int maxOfflineTime;
|
||||||
|
|
||||||
|
public int lastPosition;
|
||||||
|
|
||||||
public QueuePlayerImpl(UUID uuid, String name, QueueServer server, int highestPriority, int maxOfflineTime) {
|
public QueuePlayerImpl(UUID uuid, String name, QueueServer server, int highestPriority, int maxOfflineTime) {
|
||||||
this(null, name, uuid, server, highestPriority, maxOfflineTime);
|
this(null, name, uuid, server, highestPriority, maxOfflineTime);
|
||||||
}
|
}
|
||||||
@@ -39,6 +41,8 @@ public class QueuePlayerImpl implements QueuePlayer {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
||||||
this.maxOfflineTime = maxOfflineTime;
|
this.maxOfflineTime = maxOfflineTime;
|
||||||
|
|
||||||
|
lastPosition = getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -321,7 +321,11 @@ public class QueueServerImpl implements QueueServer {
|
|||||||
|
|
||||||
private void positionChange() {
|
private void positionChange() {
|
||||||
main.getTaskManager().runNow(
|
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));
|
||||||
|
}
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user