Fix not being able to join games through portals

This commit is contained in:
Shaun Bennett 2016-01-04 16:41:07 -05:00
parent ed81411373
commit 962efe4a61

View File

@ -86,7 +86,7 @@ public class ServerManager extends MiniPlugin
private NautHashMap<String, ServerNpcShop> _serverNpcShopMap = new NautHashMap<String, ServerNpcShop>(); private NautHashMap<String, ServerNpcShop> _serverNpcShopMap = new NautHashMap<String, ServerNpcShop>();
private NautHashMap<String, ServerInfo> _serverInfoMap = new NautHashMap<String, ServerInfo>(); private NautHashMap<String, ServerInfo> _serverInfoMap = new NautHashMap<String, ServerInfo>();
private NautHashMap<String, Long> _serverUpdate = new NautHashMap<String, Long>(); private NautHashMap<String, Long> _serverUpdate = new NautHashMap<String, Long>();
private NautHashMap<Vector, String> _serverPortalLocations = new NautHashMap<Vector, String>(); private NautHashMap<Vector, String> _portalToServerKey = new NautHashMap<Vector, String>();
private ClansServerShop _clansShop; private ClansServerShop _clansShop;
@ -185,14 +185,15 @@ public class ServerManager extends MiniPlugin
return; return;
} }
String serverName = _serverPortalLocations.get(player.getLocation().getBlock().getLocation().toVector()); String serverKey = _portalToServerKey.get(player.getLocation().getBlock().getLocation().toVector());
if (serverName != null) if (serverKey != null)
{ {
List<ServerInfo> serverList = new ArrayList<ServerInfo>(); List<ServerInfo> serverList = new ArrayList<ServerInfo>();
if (hasServerNpc(serverName)) Collection<ServerInfo> servers = getServerList(serverKey);
serverList.addAll(getServerList(serverName)); if (servers != null && servers.size() > 0)
serverList.addAll(servers);
int slots = 1; int slots = 1;
@ -347,9 +348,9 @@ public class ServerManager extends MiniPlugin
} }
} }
public Collection<ServerInfo> getServerList(String serverNpcName) public Collection<ServerInfo> getServerList(String serverKey)
{ {
return _serverKeyInfoMap.get(serverNpcName); return _serverKeyInfoMap.get(serverKey);
} }
public Set<String> getAllServers() public Set<String> getAllServers()
@ -362,11 +363,6 @@ public class ServerManager extends MiniPlugin
return _serverInfoMap.get(serverName); return _serverInfoMap.get(serverName);
} }
public boolean hasServerNpc(String serverNpcName)
{
return _serverKeyInfoMap.containsKey(serverNpcName);
}
@EventHandler @EventHandler
public void updatePages(UpdateEvent event) public void updatePages(UpdateEvent event)
{ {
@ -711,7 +707,7 @@ public class ServerManager extends MiniPlugin
while (blocks < 10 && (bottomVector.getBlockX() != topVector.getBlockX() || bottomVector.getBlockZ() != topVector.getBlockZ())) while (blocks < 10 && (bottomVector.getBlockX() != topVector.getBlockX() || bottomVector.getBlockZ() != topVector.getBlockZ()))
{ {
_serverPortalLocations.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getServerNpcName()); _portalToServerKey.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getPrefix());
if (bottomVector.getBlockX() != topVector.getBlockX()) if (bottomVector.getBlockX() != topVector.getBlockX())
{ {
@ -725,7 +721,7 @@ public class ServerManager extends MiniPlugin
blocks++; blocks++;
} }
_serverPortalLocations.put(bottomVector, serverGroup.getServerNpcName()); _portalToServerKey.put(bottomVector, serverGroup.getPrefix());
} }
} }
} }