Finalized revert to old server menus.
Tied in solo/team buttons to use old server menu as well.
This commit is contained in:
parent
fc412b0782
commit
813dfb26b3
@ -86,7 +86,6 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
private NautHashMap<String, Long> _queueCooldowns = new NautHashMap<String, Long>();
|
||||
private NautHashMap<String, HashSet<ServerInfo>> _serverKeyInfoMap = new NautHashMap<String, HashSet<ServerInfo>>();
|
||||
private NautHashMap<String, String> _serverKeyTagMap = new NautHashMap<String, String>();
|
||||
private NautHashMap<String, Integer> _serverPlayerCounts = new NautHashMap<String, Integer>();
|
||||
private NautHashMap<String, ServerNpcShop> _serverNpcShopMap = new NautHashMap<String, ServerNpcShop>();
|
||||
private NautHashMap<String, ServerInfo> _serverInfoMap = new NautHashMap<String, ServerInfo>();
|
||||
@ -189,13 +188,13 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
if (serverName != null)
|
||||
{
|
||||
List<ServerInfo> serverList = new ArrayList<ServerInfo>(GetServerList(serverName));
|
||||
List<ServerInfo> serverList = new ArrayList<ServerInfo>(getServerList(serverName));
|
||||
|
||||
int slots = 1;
|
||||
|
||||
if (serverList.size() > 0)
|
||||
{
|
||||
slots = GetRequiredSlots(player, serverList.get(0).ServerType);
|
||||
slots = getRequiredSlots(player, serverList.get(0).ServerType);
|
||||
}
|
||||
|
||||
try
|
||||
@ -206,7 +205,7 @@ public class ServerManager extends MiniPlugin
|
||||
{
|
||||
if ((serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Cup")) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slots)
|
||||
{
|
||||
SelectServer(player, serverInfo);
|
||||
selectServer(player, serverInfo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -292,7 +291,7 @@ public class ServerManager extends MiniPlugin
|
||||
return timeLeft;
|
||||
}
|
||||
|
||||
public void RemoveServer(String serverName)
|
||||
public void removeServer(String serverName)
|
||||
{
|
||||
for (String key : _serverKeyInfoMap.keySet())
|
||||
{
|
||||
@ -304,19 +303,15 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
public void addServerGroup(ServerGroup serverGroup)
|
||||
{
|
||||
_serverKeyInfoMap.put(serverGroup.getName(), new HashSet<ServerInfo>());
|
||||
_serverKeyTagMap.put(serverGroup.getPrefix(), serverGroup.getName());
|
||||
|
||||
if (!serverGroup.getServerNpcName().isEmpty())
|
||||
_serverKeyTagMap.put(serverGroup.getServerNpcName(), serverGroup.getName());
|
||||
_serverKeyInfoMap.put(serverGroup.getPrefix(), new HashSet<ServerInfo>());
|
||||
}
|
||||
|
||||
public void AddServerNpc(ServerGroup serverGroup)
|
||||
public void addServerNpc(ServerGroup serverGroup)
|
||||
{
|
||||
_serverNpcShopMap.put(serverGroup.getServerNpcName(), new ServerNpcShop(this, _clientManager, _donationManager, serverGroup));
|
||||
}
|
||||
|
||||
public void RemoveServerNpc(String serverNpcName)
|
||||
public void removeServerNpc(String serverNpcName)
|
||||
{
|
||||
Set<ServerInfo> mappedServers = _serverKeyInfoMap.remove(serverNpcName);
|
||||
_serverNpcShopMap.remove(serverNpcName);
|
||||
@ -348,22 +343,23 @@ public class ServerManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<ServerInfo> GetServerList(String serverNpcName)
|
||||
public Collection<ServerInfo> getServerList(String serverNpcName)
|
||||
{
|
||||
System.out.println("contains?" + _serverKeyInfoMap.containsKey(serverNpcName));
|
||||
return _serverKeyInfoMap.get(serverNpcName);
|
||||
}
|
||||
|
||||
public Set<String> GetAllServers()
|
||||
public Set<String> getAllServers()
|
||||
{
|
||||
return _serverInfoMap.keySet();
|
||||
}
|
||||
|
||||
public ServerInfo GetServerInfo(String serverName)
|
||||
public ServerInfo getServerInfo(String serverName)
|
||||
{
|
||||
return _serverInfoMap.get(serverName);
|
||||
}
|
||||
|
||||
public boolean HasServerNpc(String serverNpcName)
|
||||
public boolean hasServerNpc(String serverNpcName)
|
||||
{
|
||||
return _serverKeyInfoMap.containsKey(serverNpcName);
|
||||
}
|
||||
@ -449,9 +445,9 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
_serverUpdate.put(serverStatus.getName(), System.currentTimeMillis());
|
||||
|
||||
if (_serverKeyTagMap.containsKey(tag))
|
||||
if (_serverKeyInfoMap.containsKey(tag))
|
||||
{
|
||||
_serverKeyInfoMap.get(_serverKeyTagMap.get(tag)).add(serverInfo);
|
||||
_serverKeyInfoMap.get(tag).add(serverInfo);
|
||||
|
||||
if (!_serverPlayerCounts.containsKey(tag))
|
||||
_serverPlayerCounts.put(tag, 0);
|
||||
@ -484,7 +480,7 @@ public class ServerManager extends MiniPlugin
|
||||
updateCooldowns();
|
||||
}
|
||||
|
||||
public void Help(Player caller, String message)
|
||||
public void help(Player caller, String message)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Commands List:"));
|
||||
UtilPlayer.message(caller, F.help("/servernpc create <name>", "<name> is name of npc.", Rank.OWNER));
|
||||
@ -499,9 +495,9 @@ public class ServerManager extends MiniPlugin
|
||||
UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message));
|
||||
}
|
||||
|
||||
public void Help(Player caller)
|
||||
public void help(Player caller)
|
||||
{
|
||||
Help(caller, null);
|
||||
help(caller, null);
|
||||
}
|
||||
|
||||
public PartyManager getPartyManager()
|
||||
@ -509,7 +505,7 @@ public class ServerManager extends MiniPlugin
|
||||
return _partyManager;
|
||||
}
|
||||
|
||||
public void SelectServer(org.bukkit.entity.Player player, ServerInfo serverInfo)
|
||||
public void selectServer(org.bukkit.entity.Player player, ServerInfo serverInfo)
|
||||
{
|
||||
Party party = _partyManager.GetParty(player);
|
||||
|
||||
@ -539,7 +535,7 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
if (bestServer != null)
|
||||
{
|
||||
SelectServer(player, bestServer);
|
||||
selectServer(player, bestServer);
|
||||
addCooldown(player);
|
||||
}
|
||||
}
|
||||
@ -580,12 +576,7 @@ public class ServerManager extends MiniPlugin
|
||||
*/
|
||||
public ServerInfo getBestServer(Player player, String serverKey)
|
||||
{
|
||||
if (_serverKeyTagMap.containsKey(serverKey)) // Update key to full-name if a tag pair exists
|
||||
{
|
||||
serverKey = _serverKeyTagMap.get(serverKey);
|
||||
}
|
||||
|
||||
Collection<ServerInfo> serverList = GetServerList(serverKey);
|
||||
Collection<ServerInfo> serverList = getServerList(serverKey);
|
||||
if (serverList == null) return null;
|
||||
|
||||
List<ServerInfo> servers = new ArrayList<ServerInfo>(serverList);
|
||||
@ -616,7 +607,7 @@ public class ServerManager extends MiniPlugin
|
||||
public List<ServerInfo> fetchOpenServers(Player player, List<ServerInfo> servers, int count)
|
||||
{
|
||||
List<ServerInfo> results = new ArrayList<ServerInfo>();
|
||||
int requiredSlots = (servers.size() > 0) ? GetRequiredSlots(player, servers.get(0).ServerType) : 0;
|
||||
int requiredSlots = (servers.size() > 0) ? getRequiredSlots(player, servers.get(0).ServerType) : 0;
|
||||
|
||||
for (ServerInfo server : servers)
|
||||
{
|
||||
@ -639,7 +630,7 @@ public class ServerManager extends MiniPlugin
|
||||
return serverInfo.MOTD.contains("Progress") || serverInfo.MOTD.contains("Restarting");
|
||||
}
|
||||
|
||||
public void ListServerNpcs(Player caller)
|
||||
public void listServerNpcs(Player caller)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(getName(), "Listing Server Npcs:"));
|
||||
|
||||
@ -649,7 +640,7 @@ public class ServerManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void ListServers(Player caller, String serverNpcName)
|
||||
public void listServers(Player caller, String serverNpcName)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(getName(), "Listing Servers for '" + serverNpcName + "':"));
|
||||
|
||||
@ -659,7 +650,7 @@ public class ServerManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void ListOfflineServers(Player caller)
|
||||
public void listOfflineServers(Player caller)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(getName(), "Listing Offline Servers:"));
|
||||
|
||||
@ -681,8 +672,6 @@ public class ServerManager extends MiniPlugin
|
||||
{
|
||||
_serverKeyInfoMap.get(npcName).clear();
|
||||
}
|
||||
|
||||
_serverKeyTagMap.clear();
|
||||
|
||||
Region region = getPlugin().getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
||||
|
||||
@ -693,7 +682,7 @@ public class ServerManager extends MiniPlugin
|
||||
addServerGroup(serverGroup);
|
||||
|
||||
if (!serverGroup.getServerNpcName().isEmpty())
|
||||
AddServerNpc(serverGroup);
|
||||
addServerNpc(serverGroup);
|
||||
|
||||
if (!serverGroup.getPortalBottomCornerLocation().isEmpty() && !serverGroup.getPortalTopCornerLocation().isEmpty())
|
||||
{
|
||||
@ -729,13 +718,13 @@ public class ServerManager extends MiniPlugin
|
||||
ServerGroup eventGroup = new ServerGroup("Event", "Event Servers", "EVENT");
|
||||
ServerGroup mpsGroup = new ServerGroup("MPS", "Mineplex Player Servers", "MPS");
|
||||
|
||||
AddServerNpc(eventGroup);
|
||||
addServerNpc(eventGroup);
|
||||
addServerGroup(eventGroup);
|
||||
AddServerNpc(mpsGroup);
|
||||
addServerNpc(mpsGroup);
|
||||
addServerGroup(mpsGroup);
|
||||
}
|
||||
|
||||
public int GetRequiredSlots(Player player, String serverType)
|
||||
public int getRequiredSlots(Player player, String serverType)
|
||||
{
|
||||
int slots = 0;
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop> implements
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
List<ServerInfo> serverList = new ArrayList<ServerInfo>(getPlugin().GetServerList(_serverGroup));
|
||||
List<ServerInfo> serverList = new ArrayList<ServerInfo>(getPlugin().getServerList(_serverGroup));
|
||||
|
||||
try
|
||||
{
|
||||
@ -99,7 +99,7 @@ public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop> implements
|
||||
@Override
|
||||
public void SelectServer(org.bukkit.entity.Player player, ServerInfo serverInfo)
|
||||
{
|
||||
int slots = getPlugin().GetRequiredSlots(player, serverInfo.ServerType);
|
||||
int slots = getPlugin().getRequiredSlots(player, serverInfo.ServerType);
|
||||
|
||||
if (serverInfo.MaxPlayers - serverInfo.CurrentPlayers < slots)
|
||||
{
|
||||
@ -107,6 +107,6 @@ public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop> implements
|
||||
return;
|
||||
}
|
||||
|
||||
getPlugin().SelectServer(player, serverInfo);
|
||||
getPlugin().selectServer(player, serverInfo);
|
||||
}
|
||||
}
|
||||
|
@ -37,14 +37,14 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
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 _serverGroupName;
|
||||
private boolean _onMainPage = true;
|
||||
|
||||
public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverNpcKey)
|
||||
public ServerNpcPage(ServerManager plugin, ServerNpcShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, String serverGroupName)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, name, player, 54);
|
||||
|
||||
_serverNpcKey = serverNpcKey;
|
||||
_serverGroupName = serverGroupName;
|
||||
|
||||
buildPage();
|
||||
}
|
||||
@ -52,14 +52,16 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
@Override
|
||||
protected void buildPage()
|
||||
{
|
||||
List<ServerInfo> serverList = new ArrayList<ServerInfo>(getPlugin().GetServerList(_serverNpcKey));
|
||||
System.out.println(_serverGroupName);
|
||||
System.out.println("getPlugin() null?" + (getPlugin() == null));
|
||||
List<ServerInfo> serverList = new ArrayList<ServerInfo>(getPlugin().getServerList(_serverGroupName));
|
||||
|
||||
int slotsNeeded = 1;
|
||||
|
||||
|
||||
if (serverList.size() > 0)
|
||||
{
|
||||
slotsNeeded = getPlugin().GetRequiredSlots(getPlayer(), serverList.get(0).ServerType);
|
||||
slotsNeeded = getPlugin().getRequiredSlots(getPlayer(), serverList.get(0).ServerType);
|
||||
}
|
||||
|
||||
try
|
||||
@ -78,7 +80,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType) {
|
||||
getPlugin().selectServer(player, _serverNpcKey);
|
||||
getPlugin().selectServer(player, _serverGroupName);
|
||||
}
|
||||
});
|
||||
buildAvailableServerPage(serverList, slotsNeeded);
|
||||
@ -409,7 +411,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
|
||||
public void SelectServer(Player player, ServerInfo serverInfo)
|
||||
{
|
||||
int slots = getPlugin().GetRequiredSlots(player, serverInfo.ServerType);
|
||||
int slots = getPlugin().getRequiredSlots(player, serverInfo.ServerType);
|
||||
|
||||
if (serverInfo.getAvailableSlots() < slots && !(getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || getClient().GetRank().Has(Rank.ULTRA)))
|
||||
{
|
||||
@ -417,6 +419,6 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
return;
|
||||
}
|
||||
|
||||
getPlugin().SelectServer(player, serverInfo);
|
||||
getPlugin().selectServer(player, serverInfo);
|
||||
}
|
||||
}
|
||||
|
@ -81,12 +81,13 @@ public class ServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop>
|
||||
if (team)
|
||||
{
|
||||
//getPlugin().selectServer(player, _serverGroup.getTeamServerKey()); // TODO: Grab the team-key instead of regular game key
|
||||
getPlugin().getServerNPCShopByName(_serverGroup.getServerNpcName() + " 2").attemptShopOpen(player);
|
||||
//getPlugin().getServerNPCShopByName(_serverGroup.getServerNpcName() + " 2").attemptShopOpen(player);
|
||||
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getTeamServerKey()));
|
||||
}
|
||||
else
|
||||
{
|
||||
//getPlugin().selectServer(player, _serverGroup.getPrefix());
|
||||
getPlugin().getServerNPCShopByName(_serverGroup.getServerNpcName()).attemptShopOpen(player);
|
||||
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getPrefix()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user