diff --git a/api/src/main/java/us/ajg0702/queue/api/players/QueuePlayer.java b/api/src/main/java/us/ajg0702/queue/api/players/QueuePlayer.java index a816255b..b267a6dc 100644 --- a/api/src/main/java/us/ajg0702/queue/api/players/QueuePlayer.java +++ b/api/src/main/java/us/ajg0702/queue/api/players/QueuePlayer.java @@ -25,7 +25,9 @@ public interface QueuePlayer { * Gets the player's position in the queue * @return The player's position. 1 being 1st, 2 being 2nd, etc */ - int getPosition(); + default int getPosition() { + return getQueueServer().getPosition(this); + } /** * Get the player this represents. @@ -81,4 +83,10 @@ public interface QueuePlayer { * Attempts a connection to the provided AdaptedServer, calling PreConnectEvent before AdaptedPlayer.connect(...) */ void connect(@NotNull AdaptedServer server); + + /** + * Returns the estimated time until a player is connected + * @return The number of seconds (estimated) until the player is connected to the server. -1 means that no estimate is available currently + */ + int getEstimatedTime(); } diff --git a/api/src/main/java/us/ajg0702/queue/api/queueholders/QueueHolder.java b/api/src/main/java/us/ajg0702/queue/api/queueholders/QueueHolder.java index d9cf7c65..aecb25de 100644 --- a/api/src/main/java/us/ajg0702/queue/api/queueholders/QueueHolder.java +++ b/api/src/main/java/us/ajg0702/queue/api/queueholders/QueueHolder.java @@ -76,6 +76,8 @@ public QueuePlayer findPlayer(AdaptedPlayer player) { */ public abstract int getQueueSize(); + public abstract int getPosition(QueuePlayer player); + /** * Get all players that are in the queue * @return a list of players in the queue diff --git a/api/src/main/java/us/ajg0702/queue/api/queues/QueueServer.java b/api/src/main/java/us/ajg0702/queue/api/queues/QueueServer.java index 68c404d2..c6b2b087 100644 --- a/api/src/main/java/us/ajg0702/queue/api/queues/QueueServer.java +++ b/api/src/main/java/us/ajg0702/queue/api/queues/QueueServer.java @@ -228,6 +228,10 @@ default boolean isOnline() { */ QueueHolder getQueueHolder(); + default int getPosition(QueuePlayer player) { + return getQueueHolder().getPosition(player); + } + /** * elliot is bad diff --git a/common/src/main/java/us/ajg0702/queue/common/DefaultQueueHolder.java b/common/src/main/java/us/ajg0702/queue/common/DefaultQueueHolder.java index 4fef9f59..2ca389b5 100644 --- a/common/src/main/java/us/ajg0702/queue/common/DefaultQueueHolder.java +++ b/common/src/main/java/us/ajg0702/queue/common/DefaultQueueHolder.java @@ -62,6 +62,11 @@ public int getQueueSize() { return queue.size(); } + @Override + public int getPosition(QueuePlayer player) { + return queue.indexOf(player) + 1; + } + @Override public List getAllPlayers() { return ImmutableList.copyOf(queue); diff --git a/common/src/main/java/us/ajg0702/queue/common/players/QueuePlayerImpl.java b/common/src/main/java/us/ajg0702/queue/common/players/QueuePlayerImpl.java index 1eb96d48..e752e798 100644 --- a/common/src/main/java/us/ajg0702/queue/common/players/QueuePlayerImpl.java +++ b/common/src/main/java/us/ajg0702/queue/common/players/QueuePlayerImpl.java @@ -64,11 +64,6 @@ public QueueServer getQueueServer() { return server; } - @Override - public int getPosition() { - return getQueueServer().getQueue().indexOf(this)+1; - } - @Nullable @Override public AdaptedPlayer getPlayer() {