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 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 String _serverNpcKey;
private boolean _onMainPage = true; private boolean _onMainPage = true;
private boolean _freeOnly; 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 + "Premium players get",
ChatColor.RESET + C.cRed + "in instantly", ChatColor.RESET + C.cRed + "in instantly",
ChatColor.RESET + "www.mineplex.com/shop" MESSAGE_SHOP_URL
}, 1, false); }, 1, false);
AddItem(22, item); AddItem(22, item);
@ -106,13 +117,8 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
boolean free = serverInfo.isFree(); boolean free = serverInfo.isFree();
List<String> lore = new ArrayList<String>(); List<String> lore = new ArrayList<String>();
String shop = ChatColor.RESET + "www.mineplex.com/shop"; String inProgress = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? MESSAGE_IN_PROGRESS : MESSAGE_SPECTATE;
String openFull = ChatColor.RESET + C.Line + "Get Ultra to join full servers!"; String wait = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? null : MESSAGE_WAIT;
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!");
if (isStarting(serverInfo) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slotsNeeded) if (isStarting(serverInfo) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slotsNeeded)
status = free ? Material.EMERALD_BLOCK : Material.DIAMOND_BLOCK; status = free ? Material.EMERALD_BLOCK : Material.DIAMOND_BLOCK;
@ -136,11 +142,18 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
if (serverInfo.Name.contains("BETA") && !ownsUltraPackage) if (serverInfo.Name.contains("BETA") && !ownsUltraPackage)
{ {
lore.add(beta); lore.add(MESSAGE_BETA_GET_ULTRA);
} }
else else
{ {
if (isInProgress(serverInfo) && serverInfo.CurrentPlayers >= serverInfo.MaxPlayers) if (isInProgress(serverInfo) && serverInfo.CurrentPlayers >= serverInfo.MaxPlayers)
{
if (serverInfo.MOTD.contains("Restarting"))
{
status = Material.IRON_BLOCK;
lore.add(MESSAGE_RESTARTING);
}
else
{ {
if (serverInfo.Game.equalsIgnoreCase("Survival Games")) if (serverInfo.Game.equalsIgnoreCase("Survival Games"))
{ {
@ -151,24 +164,31 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
{ {
if (!ownsUltraPackage) if (!ownsUltraPackage)
{ {
lore.add(free ? openFull : openPremium); if (free)
lore.add(MESSAGE_FULL_GET_ULTRA);
else
{
lore.add(MESSAGE_REQUIRES_PREMIUM);
lore.add(MESSAGE_SHOP_URL);
}
} }
else else
{ {
lore.add(inProgress); lore.add(inProgress);
if (inProgressLine2 != null) if (wait != null)
lore.add(inProgressLine2); lore.add(wait);
}
} }
} }
} }
else else
{ {
if (free || ownsUltraPackage) if (free || ownsUltraPackage)
lore.add(ChatColor.RESET + C.Line + "Click to Join"); lore.add(MESSAGE_JOIN);
else else
{ {
lore.add(openPremium); lore.add(MESSAGE_REQUIRES_PREMIUM);
lore.add(shop); 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(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)); // 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 @Override
public void Clicked(Player player) public void Clicked(Player player)
@ -221,7 +241,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
_freeOnly = true; _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 @Override
public void Clicked(Player player) public void Clicked(Player player)