Visual clock update

This commit is contained in:
Shaun Bennett 2014-07-31 23:49:52 -05:00
parent cf724272dd
commit 7d1da7114f

View File

@ -51,13 +51,6 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
@Override
protected void BuildPage()
{
long portalTime = Plugin.getMillisecondsUntilPortal(Player);
if (portalTime > 0)
{
showClock(portalTime);
return;
}
List<ServerInfo> serverList = new ArrayList<ServerInfo>(Plugin.GetServerList(_serverNpcKey));
int slotsNeeded = 1;
@ -89,17 +82,21 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
private void showClock(long milliseconds)
{
int seconds = (int) (milliseconds / 1000);
String timeLeft = UtilTime.convertString(milliseconds, 0, UtilTime.TimeUnit.SECONDS);
ShopItem item = new ShopItem(Material.WATCH, ChatColor.RESET + C.Bold + "Free Server Timer", new String[] {
"",
ChatColor.RESET + C.cGreen + "Please wait " + timeLeft,
"",
ChatColor.RESET + C.cRed + "Premium players get",
ChatColor.RESET + C.cRed + "in instantly",
MESSAGE_SHOP_URL
}, 1, false);
ChatColor.RESET + C.cGreen + timeLeft + " Remaining...",
ChatColor.RESET + "",
ChatColor.RESET + C.cYellow + "Free players must wait a short time",
ChatColor.RESET + C.cYellow + "to help lighten the load on free servers.",
ChatColor.RESET + "",
ChatColor.RESET + C.cAqua + "Ultra and Hero players have instant",
ChatColor.RESET + C.cAqua + "access to free and premium servers!",
ChatColor.RESET + "",
ChatColor.RESET + "Visit " + C.cGreen + "www.mineplex.com/shop" + C.cWhite + " to become Premium!"
}, seconds, false);
AddItem(22, item);
AddItem(20, item);
}
private void clearPage()
@ -213,6 +210,14 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
int yellowUltraCount = 0;
int greenStartSlot = 19;
int blueStartSlot = 23;
boolean showGreen = true;
long portalTime = Plugin.getMillisecondsUntilPortal(Player);
if (portalTime > 0)
{
showClock(portalTime);
showGreen = false;
}
for (ServerInfo serverInfo : serverList)
{
@ -221,14 +226,17 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
if (isStarting(serverInfo) && hasEnoughSlots(serverInfo, slotsNeeded) && (free ? greenCount : blueCount) < 3)
{
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded);
if ((free && showGreen) || !free)
{
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded);
if (free)
greenCount++;
else
blueCount++;
if (free)
greenCount++;
else
blueCount++;
AddButton(slot, shopItem, new JoinServerButton(this, serverInfo));
AddButton(slot, shopItem, new JoinServerButton(this, serverInfo));
}
}
else
{
@ -241,16 +249,24 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
// AddItem(11, new ShopItem(Material.IRON_BLOCK, C.cGreen + "Free Servers", new String[] {C.cGray + "Anyone can play!" }, 1, false));
// AddItem(15, new ShopItem(Material.IRON_BLOCK, C.cBlue + "Premium Servers", new String[] {C.cGray + "Available to " + Rank.ULTRA.GetTag(true, true) + ChatColor.RESET + C.cGray + " and " + Rank.HERO.GetTag(true, true) + ChatColor.RESET + C.cGray + "!" }, 1, false));
AddButton(38, new ShopItem(Material.GOLD_BLOCK, C.cGreen + yellowFreeCount + " Games In Progress", new String[]{ MESSAGE_SPECTATE }, yellowFreeCount > 64 ? 1 : yellowFreeCount, false), new SingleButton()
AddButton(38, new ShopItem(Material.GOLD_BLOCK, C.cGreen + yellowFreeCount + " Games In Progress", new String[]{MESSAGE_SPECTATE}, yellowFreeCount > 64 ? 1 : yellowFreeCount, false), new SingleButton()
{
@Override
public void Clicked(Player player)
{
_onMainPage = false;
_freeOnly = true;
long portalTime = Plugin.getMillisecondsUntilPortal(Player);
if (portalTime <= 0)
{
_onMainPage = false;
_freeOnly = true;
}
else
{
PlayDenySound(Player);
}
}
});
AddButton(42, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowUltraCount + " Games In Progress", new String[]{ MESSAGE_SPECTATE }, yellowUltraCount > 64 ? 1 : yellowUltraCount, false), new SingleButton()
AddButton(42, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowUltraCount + " Games In Progress", new String[]{MESSAGE_SPECTATE}, yellowUltraCount > 64 ? 1 : yellowUltraCount, false), new SingleButton()
{
@Override
public void Clicked(Player player)
@ -261,17 +277,17 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
});
// Clear empty slots
for (int i = greenCount + greenStartSlot; i < greenStartSlot + 3; i++)
if (showGreen)
{
setItem(i, null);
for (int i = greenCount + greenStartSlot; i < greenStartSlot + 3; i++)
{
setItem(i, null);
}
}
for (int i = blueCount + blueStartSlot; i < blueStartSlot + 3; i++)
{
setItem(i, null);
}
// For Clock
setItem(22, null);
}
private boolean isStarting(ServerInfo serverInfo)