Use constants for lore messages on server page

This commit is contained in:
Shaun Bennett 2014-07-31 17:17:05 -05:00
parent 4c74ce60eb
commit 41128cbc9d

View File

@ -24,6 +24,17 @@ import mineplex.hub.server.ui.button.JoinServerButton;
public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> implements IServerPage
{
// Shop Item Messages
private static final String MESSAGE_SHOP_URL = ChatColor.RESET + "www.mineplex.com/shop";
private static final String MESSAGE_REQUIRES_PREMIUM = ChatColor.RESET + C.cRed + "Premium requires " + Rank.ULTRA.GetTag(false, false) + C.cRed + " or " + Rank.HERO.GetTag(false, false);
private static final String MESSAGE_BETA_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join Beta servers!";
private static final String MESSAGE_JOIN = ChatColor.RESET + C.Line + "Click to Join";
private static final String MESSAGE_IN_PROGRESS = ChatColor.RESET + C.Line + "Game in Progress.";
private static final String MESSAGE_SPECTATE = ChatColor.RESET + C.Line + "Click to Spectate";
private static final String MESSAGE_WAIT = ChatColor.RESET + C.Line + "and wait for next game!";
private static final String MESSAGE_FULL_GET_ULTRA = ChatColor.RESET + C.Line + "Get Ultra to join full servers!";
private static final String MESSAGE_RESTARTING = ChatColor.RESET + C.Line + "This server will be open shortly!";
private String _serverNpcKey;
private boolean _onMainPage = true;
private boolean _freeOnly;
@ -85,7 +96,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
"",
ChatColor.RESET + C.cRed + "Premium players get",
ChatColor.RESET + C.cRed + "in instantly",
ChatColor.RESET + "www.mineplex.com/shop"
MESSAGE_SHOP_URL
}, 1, false);
AddItem(22, item);
@ -106,13 +117,8 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
boolean free = serverInfo.isFree();
List<String> lore = new ArrayList<String>();
String shop = ChatColor.RESET + "www.mineplex.com/shop";
String openFull = ChatColor.RESET + C.Line + "Get Ultra to join full servers!";
String openPremium = ChatColor.RESET + C.cRed + "Premium requires " + Rank.ULTRA.GetTag(false, false) + C.cRed + " or " + Rank.HERO.GetTag(false, false);
String beta = ChatColor.RESET + C.Line + "Get Ultra to join Beta servers!";
String clickJoin = ChatColor.RESET + C.Line + "Click to Join";
String inProgress = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? (ChatColor.RESET + C.Line + "Game in Progress.") : ChatColor.RESET + C.Line + "Click to Spectate";
String inProgressLine2 = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? null : (ChatColor.RESET + C.Line + "and wait for next game!");
String inProgress = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? MESSAGE_IN_PROGRESS : MESSAGE_SPECTATE;
String wait = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? null : MESSAGE_WAIT;
if (isStarting(serverInfo) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slotsNeeded)
status = free ? Material.EMERALD_BLOCK : Material.DIAMOND_BLOCK;
@ -136,39 +142,53 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
if (serverInfo.Name.contains("BETA") && !ownsUltraPackage)
{
lore.add(beta);
lore.add(MESSAGE_BETA_GET_ULTRA);
}
else
{
if (isInProgress(serverInfo) && serverInfo.CurrentPlayers >= serverInfo.MaxPlayers)
{
if (serverInfo.Game.equalsIgnoreCase("Survival Games"))
if (serverInfo.MOTD.contains("Restarting"))
{
lore.add(ChatColor.RESET + C.Line + "Full Survival Games servers");
lore.add(ChatColor.RESET + C.Line + "cannot be joined.");
status = Material.IRON_BLOCK;
lore.add(MESSAGE_RESTARTING);
}
else
{
if (!ownsUltraPackage)
if (serverInfo.Game.equalsIgnoreCase("Survival Games"))
{
lore.add(free ? openFull : openPremium);
lore.add(ChatColor.RESET + C.Line + "Full Survival Games servers");
lore.add(ChatColor.RESET + C.Line + "cannot be joined.");
}
else
{
lore.add(inProgress);
if (inProgressLine2 != null)
lore.add(inProgressLine2);
if (!ownsUltraPackage)
{
if (free)
lore.add(MESSAGE_FULL_GET_ULTRA);
else
{
lore.add(MESSAGE_REQUIRES_PREMIUM);
lore.add(MESSAGE_SHOP_URL);
}
}
else
{
lore.add(inProgress);
if (wait != null)
lore.add(wait);
}
}
}
}
else
{
if (free || ownsUltraPackage)
lore.add(ChatColor.RESET + C.Line + "Click to Join");
lore.add(MESSAGE_JOIN);
else
{
lore.add(openPremium);
lore.add(shop);
lore.add(MESSAGE_REQUIRES_PREMIUM);
lore.add(MESSAGE_SHOP_URL);
}
}
}
@ -212,7 +232,7 @@ 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[]{ChatColor.RESET + C.Line + "Click to 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)
@ -221,7 +241,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
_freeOnly = true;
}
});
AddButton(42, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowUltraCount + " Games In Progress", new String[]{ChatColor.RESET + C.Line + "Click to 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)