From 1583d41d1a17f2d8f593f2338da80c1a8d1f7ace Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 27 Jul 2018 20:43:00 +0100 Subject: [PATCH] Close the server selector after 45 seconds --- .../hub/server/newui/ServerSelectionPage.java | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/newui/ServerSelectionPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/newui/ServerSelectionPage.java index d749d9e86..32bf57020 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/newui/ServerSelectionPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/newui/ServerSelectionPage.java @@ -1,7 +1,9 @@ package mineplex.hub.server.newui; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; +import java.util.concurrent.TimeUnit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -11,6 +13,7 @@ import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTime; import mineplex.core.donation.DonationManager; import mineplex.core.game.status.GameInfo; import mineplex.core.game.status.GameInfo.GameDisplayStatus; @@ -26,9 +29,14 @@ public class ServerSelectionPage extends ShopPageBase GAME_SERVER_SORTER = (o1, o2) -> + { + return 0; + }; private final ServerGroup _serverGroup; + private final long _openedAt; private boolean _showInProgress; @@ -37,24 +45,41 @@ public class ServerSelectionPage extends ShopPageBase servers = new ArrayList<>(getPlugin().getServers(_serverGroup.getPrefix())); + servers.sort(GAME_SERVER_SORTER); + if (_showInProgress) { // TODO MAKE } else { - buildMainPage(); + buildMainPage(servers); } } - private void buildMainPage() + private void buildMainPage(List servers) { + // Filter servers + servers.removeIf(server -> + { + GameDisplayStatus status = server.getInfo().getStatus(); + return status == null || status == GameDisplayStatus.IN_PROGRESS || status == GameDisplayStatus.CLOSING; + }); + // Instant join addRow(0, (byte) 3, new ItemBuilder(Material.DIAMOND_BLOCK) .setTitle(C.cGreenB + "Click To Join Instantly!") @@ -65,7 +90,6 @@ public class ServerSelectionPage extends ShopPageBase servers = new ArrayList<>(getPlugin().getServers(_serverGroup.getPrefix())); int slot = STARTING_SLOT; for (GameServer server : servers) @@ -96,7 +120,8 @@ public class ServerSelectionPage extends ShopPageBase { - // TODO show in progress servers + _showInProgress = !_showInProgress; + refresh(); }); } @@ -136,7 +161,7 @@ public class ServerSelectionPage extends ShopPageBase