From d3c5d0cbe66b9899ec037caccd6be2894c4d3b45 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 1 Aug 2015 01:12:01 -0500 Subject: [PATCH 1/4] Only store account cache stuff for 6 hours. Update MOtd. --- .../src/mineplex/bungee/motd/MotdManager.java | 2 +- .../src/mineplex/core/account/CoreClientManager.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java index 49e6f6ae1..05284beeb 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/motd/MotdManager.java @@ -39,7 +39,7 @@ public class MotdManager implements Listener, Runnable if (new File("updateMOTD.dat").exists()) { List lines = new ArrayList(); - lines.add(" §b§l◄§f§lNEW§b§l► §f§l◄§b§lSKYWARS§f§l► §b§l◄§f§lNEW§b§l►"); + lines.add(" §f§l◄ §6§lNEW ARCADE GAME §f§l▬ §c§lBOMB LOBBERS §f§l►"); //lines.add(" §d§lRank Sale §a§l40% Off"); //lines.add(" §f§l◄§c§lMAINTENANCE§f§l►"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index a76be2fcd..3e5b7196e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -227,7 +227,7 @@ public class CoreClientManager extends MiniPlugin Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); if (client.getAccountId() > 0) - _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId())); + _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6); } catch (Exception exception) { @@ -301,7 +301,7 @@ public class CoreClientManager extends MiniPlugin System.out.println(client.GetPlayerName() + "'s account id = " + client.getAccountId()); if (client.getAccountId() > 0) - _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId())); + _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6); return !_clientLoginLock.containsKey(client.GetPlayerName()); } From f520908f8d4c73c04684286071ef83cb2a8002cb Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sun, 2 Aug 2015 17:52:51 -0500 Subject: [PATCH 2/4] Added team and portal location info to server group. --- .../mineplex/serverdata/data/ServerGroup.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java index 40d36f875..b018383b7 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java @@ -57,6 +57,11 @@ public class ServerGroup private boolean _staffOnly; private String _resourcePack = ""; + private String _portalBottomCornerLocation = ""; + private String _portalTopCornerLocation = ""; + + private String _teamServerKey = ""; + private Region _region; private Set _servers; @@ -101,6 +106,9 @@ public class ServerGroup _resourcePack = data.containsKey("resourcePack") ? data.get("resourcePack") : ""; _host = data.get("host"); _region = data.containsKey("region") ? Region.valueOf(data.get("region")) : Region.ALL; + _teamServerKey = data.containsKey("teamServerKey") ? data.get("teamServerKey") : ""; + _portalBottomCornerLocation = data.containsKey("portalBottomCornerLocation") ? data.get("portalBottomCornerLocation") : ""; + _portalTopCornerLocation = data.containsKey("portalTopCornerLocation") ? data.get("portalTopCornerLocation") : ""; if (serverStatuses != null) parseServers(serverStatuses); @@ -109,7 +117,8 @@ public class ServerGroup public ServerGroup(String name, String prefix, String host, int ram, int cpu, int totalServers, int joinable, int portSection, boolean arcade, String worldZip, String plugin, String configPath , 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) + , boolean rewardAchievements, boolean hotbarInventory, boolean hotbarHubClock, boolean playerKickIdle, boolean staffOnly, boolean whitelist, String resourcePack, Region region + , String teamServerKey, String portalBottomCornerLocation, String portalTopCornerLocation) { _name = name; _prefix = prefix; @@ -148,6 +157,9 @@ public class ServerGroup _whitelist = whitelist; _resourcePack = resourcePack; _region = region; + _teamServerKey = teamServerKey; + _portalBottomCornerLocation = portalBottomCornerLocation; + _portalTopCornerLocation = portalTopCornerLocation; } public String getName() { return _name; } @@ -196,6 +208,11 @@ public class ServerGroup public String getResourcePack() { return _resourcePack; } public Region getRegion() { return _region; } + public String getTeamServerKey() { return _teamServerKey; } + + public String getPortalBottomCornerLocation() { return _portalBottomCornerLocation; } + public String getPortalTopCornerLocation() { return _portalTopCornerLocation; } + public Set getServers() { return _servers; } public int getServerCount() @@ -350,6 +367,9 @@ public class ServerGroup _dataMap.put("resourcePack", _resourcePack); _dataMap.put("host", _host); _dataMap.put("region", _region.name()); + _dataMap.put("teamServerKey", _teamServerKey); + _dataMap.put("portalBottomCornerLocation", _portalBottomCornerLocation); + _dataMap.put("portalTopCornerLocation", _portalTopCornerLocation); } return _dataMap; From a2250ea3434350fa8ee543c22366f8d0d86982c0 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sun, 2 Aug 2015 18:59:13 -0500 Subject: [PATCH 3/4] Fix for blocking logins if redis can't add account cache. --- .../src/mineplex/core/account/CoreClientManager.java | 11 ++++++++++- .../core/personalServer/PersonalServerManager.java | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 3e5b7196e..9d11610a5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -301,7 +301,16 @@ public class CoreClientManager extends MiniPlugin System.out.println(client.GetPlayerName() + "'s account id = " + client.getAccountId()); if (client.getAccountId() > 0) - _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6); + { + try + { + _accountCacheRepository.addElement(new AccountCache(uuid, client.getAccountId()), 60 * 60 * 6); + } + catch (Exception e) + { + e.printStackTrace(); + } + } return !_clientLoginLock.containsKey(client.GetPlayerName()); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java index db709fd28..466a26d50 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/personalServer/PersonalServerManager.java @@ -157,7 +157,7 @@ public class PersonalServerManager extends MiniPlugin } final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), ram, cpu, 1, 0, UtilMath.random.nextInt(250) + 19999, true, "arcade.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers, - true, false, false, games, "Player", true, event, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU); + true, false, false, games, "Player", true, event, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU, "", "", "", ""); getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() { From d9a641fd92fd03af509b3c897e478af0957eae8f Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sun, 2 Aug 2015 18:59:43 -0500 Subject: [PATCH 4/4] Updated ServerManager to read server npc stuff from redis. Updated ServerGroup to have NPC name in it. --- .../mineplex/hub/server/ServerManager.java | 96 +++++++------------ .../mineplex/serverdata/data/ServerGroup.java | 7 +- 2 files changed, 38 insertions(+), 65 deletions(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index beda010d6..72a5343a2 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -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 npcNames = new HashSet(); + 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()); } } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java index b018383b7..02628419d 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/data/ServerGroup.java @@ -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;