Updated ServerManager to read server npc stuff from redis.
Updated ServerGroup to have NPC name in it.
This commit is contained in:
parent
a2250ea343
commit
d9a641fd92
@ -59,6 +59,7 @@ import mineplex.hub.server.ui.LobbyShop;
|
||||
import mineplex.hub.server.ui.QuickShop;
|
||||
import mineplex.hub.server.ui.ServerCountSorter;
|
||||
import mineplex.hub.server.ui.ServerNpcShop;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.MinecraftServer;
|
||||
import mineplex.serverdata.data.ServerGroup;
|
||||
|
||||
@ -114,7 +115,7 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||
|
||||
LoadServers();
|
||||
loadServers();
|
||||
|
||||
_quickShop = new QuickShop(this, clientManager, donationManager, "Quick Menu");
|
||||
_lobbyShop = new LobbyShop(this, clientManager, donationManager, "Lobby Menu");
|
||||
@ -628,7 +629,7 @@ public class ServerManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadServers()
|
||||
public void loadServers()
|
||||
{
|
||||
_serverInfoMap.clear();
|
||||
_serverUpdate.clear();
|
||||
@ -640,82 +641,49 @@ public class ServerManager extends MiniPlugin
|
||||
|
||||
_serverKeyTagMap.clear();
|
||||
|
||||
FileInputStream fstream = null;
|
||||
BufferedReader br = null;
|
||||
|
||||
HashSet<String> npcNames = new HashSet<String>();
|
||||
Region region = getPlugin().getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
||||
|
||||
try
|
||||
{
|
||||
File npcFile = new File("ServerManager.dat");
|
||||
|
||||
if (npcFile.exists())
|
||||
for (ServerGroup serverGroup : mineplex.serverdata.servers.ServerManager.getServerRepository(region).getServerGroups(null))
|
||||
{
|
||||
fstream = new FileInputStream(npcFile);
|
||||
br = new BufferedReader(new InputStreamReader(fstream));
|
||||
|
||||
String line = br.readLine();
|
||||
|
||||
while (line != null)
|
||||
if (!serverGroup.getServerNpcName().isEmpty())
|
||||
{
|
||||
String serverNpcName = line.substring(0, line.indexOf('|')).trim();
|
||||
String[] serverTags = line.substring(line.indexOf('|') + 1, line.indexOf('|', line.indexOf('|') + 1)).trim().split(",");
|
||||
String[] locations = line.substring(line.indexOf('|', line.indexOf('|') + 1) + 1).trim().split(",");
|
||||
if (!HasServerNpc(serverGroup.getServerNpcName()))
|
||||
{
|
||||
AddServerNpc(serverGroup.getServerNpcName(), serverGroup.getPrefix());
|
||||
}
|
||||
}
|
||||
|
||||
for (String location : locations)
|
||||
if (!serverGroup.getPortalBottomCornerLocation().isEmpty() && !serverGroup.getPortalTopCornerLocation().isEmpty())
|
||||
{
|
||||
Vector bottomVector = ParseVector(serverGroup.getPortalBottomCornerLocation());
|
||||
Vector topVector = ParseVector(serverGroup.getPortalTopCornerLocation());
|
||||
int blocks = 0;
|
||||
|
||||
while (blocks < 10 && (bottomVector.getBlockX() != topVector.getBlockX() || bottomVector.getBlockZ() != topVector.getBlockZ()))
|
||||
{
|
||||
_serverPortalLocations.put(ParseVector(location), serverNpcName);
|
||||
_serverPortalLocations.put(new Vector(bottomVector.getBlockX(), bottomVector.getBlockY(), bottomVector.getBlockZ()), serverGroup.getServerNpcName());
|
||||
|
||||
if (bottomVector.getBlockX() != topVector.getBlockX())
|
||||
{
|
||||
bottomVector.add(new Vector(-(bottomVector.getBlockX() - topVector.getBlockX()) / Math.abs(bottomVector.getBlockX() - topVector.getBlockX()), 0, 0));
|
||||
}
|
||||
else if (bottomVector.getBlockZ() != topVector.getBlockZ())
|
||||
{
|
||||
bottomVector.add(new Vector(0, 0, -(bottomVector.getBlockZ() - topVector.getBlockZ()) / Math.abs(bottomVector.getBlockZ() - topVector.getBlockZ())));
|
||||
}
|
||||
|
||||
blocks++;
|
||||
}
|
||||
|
||||
if (!HasServerNpc(serverNpcName))
|
||||
{
|
||||
AddServerNpc(serverNpcName, serverTags);
|
||||
}
|
||||
|
||||
npcNames.add(serverNpcName);
|
||||
|
||||
line = br.readLine();
|
||||
_serverPortalLocations.put(bottomVector, serverGroup.getServerNpcName());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("ServerManager - Error parsing servers file : " + e.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (br != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
br.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (fstream != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fstream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String npcName : npcNames)
|
||||
{
|
||||
if (!_serverNpcShopMap.containsKey(npcName))
|
||||
_serverNpcShopMap.remove(npcName);
|
||||
|
||||
if (!_serverKeyInfoMap.containsKey(npcName))
|
||||
_serverKeyInfoMap.remove(npcName);
|
||||
System.out.println("ServerManager - Error parsing servergroups : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,7 @@ public class ServerGroup
|
||||
private boolean _staffOnly;
|
||||
private String _resourcePack = "";
|
||||
|
||||
private String _npcName = "";
|
||||
private String _portalBottomCornerLocation = "";
|
||||
private String _portalTopCornerLocation = "";
|
||||
|
||||
@ -109,6 +110,7 @@ public class ServerGroup
|
||||
_teamServerKey = data.containsKey("teamServerKey") ? data.get("teamServerKey") : "";
|
||||
_portalBottomCornerLocation = data.containsKey("portalBottomCornerLocation") ? data.get("portalBottomCornerLocation") : "";
|
||||
_portalTopCornerLocation = data.containsKey("portalTopCornerLocation") ? data.get("portalTopCornerLocation") : "";
|
||||
_npcName = data.containsKey("npcName") ? data.get("npcName") : "";
|
||||
|
||||
if (serverStatuses != null)
|
||||
parseServers(serverStatuses);
|
||||
@ -118,7 +120,7 @@ public class ServerGroup
|
||||
, int minPlayers, int maxPlayers, boolean pvp, boolean tournament, boolean tournamentPoints, String games, String serverType, boolean noCheat, boolean worldEdit, boolean teamRejoin
|
||||
, boolean teamAutoJoin, boolean teamForceBalance, boolean gameAutoStart, boolean gameTimeout, boolean rewardGems, boolean rewardItems, boolean rewardStats
|
||||
, boolean rewardAchievements, boolean hotbarInventory, boolean hotbarHubClock, boolean playerKickIdle, boolean staffOnly, boolean whitelist, String resourcePack, Region region
|
||||
, String teamServerKey, String portalBottomCornerLocation, String portalTopCornerLocation)
|
||||
, String teamServerKey, String portalBottomCornerLocation, String portalTopCornerLocation, String npcName)
|
||||
{
|
||||
_name = name;
|
||||
_prefix = prefix;
|
||||
@ -160,6 +162,7 @@ public class ServerGroup
|
||||
_teamServerKey = teamServerKey;
|
||||
_portalBottomCornerLocation = portalBottomCornerLocation;
|
||||
_portalTopCornerLocation = portalTopCornerLocation;
|
||||
_npcName = npcName;
|
||||
}
|
||||
|
||||
public String getName() { return _name; }
|
||||
@ -210,6 +213,7 @@ public class ServerGroup
|
||||
|
||||
public String getTeamServerKey() { return _teamServerKey; }
|
||||
|
||||
public String getServerNpcName() { return _npcName; }
|
||||
public String getPortalBottomCornerLocation() { return _portalBottomCornerLocation; }
|
||||
public String getPortalTopCornerLocation() { return _portalTopCornerLocation; }
|
||||
|
||||
@ -370,6 +374,7 @@ public class ServerGroup
|
||||
_dataMap.put("teamServerKey", _teamServerKey);
|
||||
_dataMap.put("portalBottomCornerLocation", _portalBottomCornerLocation);
|
||||
_dataMap.put("portalTopCornerLocation", _portalTopCornerLocation);
|
||||
_dataMap.put("npcName", _npcName);
|
||||
}
|
||||
|
||||
return _dataMap;
|
||||
|
Loading…
Reference in New Issue
Block a user