diff --git a/Maps/Bacon Brawl/Bacon_Lava.zip b/Maps/Bacon Brawl/Bacon_Lava.zip new file mode 100644 index 000000000..6e864b1d1 Binary files /dev/null and b/Maps/Bacon Brawl/Bacon_Lava.zip differ diff --git a/Maps/Death Tag/DeathTag_Village.zip b/Maps/Death Tag/DeathTag_Village.zip new file mode 100644 index 000000000..9013ffc8f Binary files /dev/null and b/Maps/Death Tag/DeathTag_Village.zip differ diff --git a/Maps/Dragon Escape/DragonEscape_Skylands.zip b/Maps/Dragon Escape/DragonEscape_Skylands.zip new file mode 100644 index 000000000..0fd704a1a Binary files /dev/null and b/Maps/Dragon Escape/DragonEscape_Skylands.zip differ diff --git a/Maps/Dragons/DR_Voyage.zip b/Maps/Dragons/DR_Voyage.zip new file mode 100644 index 000000000..79491f369 Binary files /dev/null and b/Maps/Dragons/DR_Voyage.zip differ diff --git a/Maps/Dragons/Dragons_Island.zip b/Maps/Dragons/Dragons_Island.zip new file mode 100644 index 000000000..78d72f921 Binary files /dev/null and b/Maps/Dragons/Dragons_Island.zip differ diff --git a/Maps/Dragons/Dragons_SkyShip.zip b/Maps/Dragons/Dragons_SkyShip.zip new file mode 100644 index 000000000..e4926344c Binary files /dev/null and b/Maps/Dragons/Dragons_SkyShip.zip differ diff --git a/Maps/Dragons/Dragons_SkyVillage.zip b/Maps/Dragons/Dragons_SkyVillage.zip new file mode 100644 index 000000000..751834790 Binary files /dev/null and b/Maps/Dragons/Dragons_SkyVillage.zip differ diff --git a/Maps/Halloween Horror/2013.zip b/Maps/Halloween Horror/2013.zip new file mode 100644 index 000000000..6b67c66f5 Binary files /dev/null and b/Maps/Halloween Horror/2013.zip differ diff --git a/Maps/Hunger Games/Hypixel.zip b/Maps/Hunger Games/Hypixel.zip new file mode 100644 index 000000000..ba128da7e Binary files /dev/null and b/Maps/Hunger Games/Hypixel.zip differ diff --git a/Maps/Milk the Cow/Milk_BobsFarm.zip b/Maps/Milk the Cow/Milk_BobsFarm.zip new file mode 100644 index 000000000..6c62ac4aa Binary files /dev/null and b/Maps/Milk the Cow/Milk_BobsFarm.zip differ diff --git a/Maps/One in the Quiver/OITQ_Island_Village.zip b/Maps/One in the Quiver/OITQ_Island_Village.zip new file mode 100644 index 000000000..a8d7c7528 Binary files /dev/null and b/Maps/One in the Quiver/OITQ_Island_Village.zip differ diff --git a/Maps/One in the Quiver/OITQ_Ruins.zip b/Maps/One in the Quiver/OITQ_Ruins.zip new file mode 100644 index 000000000..00ccb26d6 Binary files /dev/null and b/Maps/One in the Quiver/OITQ_Ruins.zip differ diff --git a/Maps/One in the Quiver/OITQ_TwinPeaks.zip b/Maps/One in the Quiver/OITQ_TwinPeaks.zip new file mode 100644 index 000000000..37746484d Binary files /dev/null and b/Maps/One in the Quiver/OITQ_TwinPeaks.zip differ diff --git a/Maps/One in the Quiver/OITQ_Village.zip b/Maps/One in the Quiver/OITQ_Village.zip new file mode 100644 index 000000000..9013ffc8f Binary files /dev/null and b/Maps/One in the Quiver/OITQ_Village.zip differ diff --git a/Maps/Runner/Runner_ClayPlaza.zip b/Maps/Runner/Runner_ClayPlaza.zip new file mode 100644 index 000000000..f779d42b1 Binary files /dev/null and b/Maps/Runner/Runner_ClayPlaza.zip differ diff --git a/Maps/Runner/Runner_Colloseum.zip b/Maps/Runner/Runner_Colloseum.zip new file mode 100644 index 000000000..551496e40 Binary files /dev/null and b/Maps/Runner/Runner_Colloseum.zip differ diff --git a/Maps/Runner/Runner_Euphoria.zip b/Maps/Runner/Runner_Euphoria.zip new file mode 100644 index 000000000..357ab8e45 Binary files /dev/null and b/Maps/Runner/Runner_Euphoria.zip differ diff --git a/Maps/Snake/Snake_Pit.zip b/Maps/Snake/Snake_Pit.zip new file mode 100644 index 000000000..8aeb2eab8 Binary files /dev/null and b/Maps/Snake/Snake_Pit.zip differ diff --git a/Maps/Snake/Snake_Volcanic.zip b/Maps/Snake/Snake_Volcanic.zip new file mode 100644 index 000000000..7614e7b4f Binary files /dev/null and b/Maps/Snake/Snake_Volcanic.zip differ diff --git a/Maps/Squid Shooter/Squid_JunglePools.zip b/Maps/Squid Shooter/Squid_JunglePools.zip new file mode 100644 index 000000000..1d99339ef Binary files /dev/null and b/Maps/Squid Shooter/Squid_JunglePools.zip differ diff --git a/Maps/Super Paintball/1984.zip b/Maps/Super Paintball/1984.zip new file mode 100644 index 000000000..c841d5a3d Binary files /dev/null and b/Maps/Super Paintball/1984.zip differ diff --git a/Maps/Super Paintball/Besmap.zip b/Maps/Super Paintball/Besmap.zip new file mode 100644 index 000000000..13a7b6dd4 Binary files /dev/null and b/Maps/Super Paintball/Besmap.zip differ diff --git a/Maps/Super Paintball/Paintball_CookieTown.zip b/Maps/Super Paintball/Paintball_CookieTown.zip new file mode 100644 index 000000000..bee728dbf Binary files /dev/null and b/Maps/Super Paintball/Paintball_CookieTown.zip differ diff --git a/Maps/Super Paintball/Paintball_FriendlyForest.zip b/Maps/Super Paintball/Paintball_FriendlyForest.zip new file mode 100644 index 000000000..4a1d3c6f1 Binary files /dev/null and b/Maps/Super Paintball/Paintball_FriendlyForest.zip differ diff --git a/Maps/Super Paintball/Paintball_PaintedGardens.zip b/Maps/Super Paintball/Paintball_PaintedGardens.zip new file mode 100644 index 000000000..dcade7a68 Binary files /dev/null and b/Maps/Super Paintball/Paintball_PaintedGardens.zip differ diff --git a/Maps/Super Paintball/Paintball_TripleTowers.zip b/Maps/Super Paintball/Paintball_TripleTowers.zip new file mode 100644 index 000000000..5a6b3b2ef Binary files /dev/null and b/Maps/Super Paintball/Paintball_TripleTowers.zip differ diff --git a/Maps/Super Smash Mobs/Smash_Adrift.zip b/Maps/Super Smash Mobs/Smash_Adrift.zip new file mode 100644 index 000000000..aae4d5997 Binary files /dev/null and b/Maps/Super Smash Mobs/Smash_Adrift.zip differ diff --git a/Maps/Super Smash Mobs/Smash_Desert.zip b/Maps/Super Smash Mobs/Smash_Desert.zip new file mode 100644 index 000000000..75d1c4aac Binary files /dev/null and b/Maps/Super Smash Mobs/Smash_Desert.zip differ diff --git a/Maps/Super Smash Mobs/Smash_HyruleCastle.zip b/Maps/Super Smash Mobs/Smash_HyruleCastle.zip new file mode 100644 index 000000000..07029cafa Binary files /dev/null and b/Maps/Super Smash Mobs/Smash_HyruleCastle.zip differ diff --git a/Maps/Super Smash Mobs/Smash_Mushroom.zip b/Maps/Super Smash Mobs/Smash_Mushroom.zip new file mode 100644 index 000000000..1485b4c4f Binary files /dev/null and b/Maps/Super Smash Mobs/Smash_Mushroom.zip differ diff --git a/Maps/Super Smash Mobs/Smash_Skylands.zip b/Maps/Super Smash Mobs/Smash_Skylands.zip new file mode 100644 index 000000000..811b11e94 Binary files /dev/null and b/Maps/Super Smash Mobs/Smash_Skylands.zip differ diff --git a/Maps/Super Spleef/SP_Euphoria.zip b/Maps/Super Spleef/SP_Euphoria.zip new file mode 100644 index 000000000..cf3c8c70a Binary files /dev/null and b/Maps/Super Spleef/SP_Euphoria.zip differ diff --git a/Maps/Super Spleef/SP_Temple.zip b/Maps/Super Spleef/SP_Temple.zip new file mode 100644 index 000000000..7b9fcd997 Binary files /dev/null and b/Maps/Super Spleef/SP_Temple.zip differ diff --git a/Maps/Super Spleef/SP_Tibbles.zip b/Maps/Super Spleef/SP_Tibbles.zip new file mode 100644 index 000000000..e5d662bba Binary files /dev/null and b/Maps/Super Spleef/SP_Tibbles.zip differ diff --git a/Maps/Super Spleef/Spleef_Volcanic.zip b/Maps/Super Spleef/Spleef_Volcanic.zip new file mode 100644 index 000000000..7644c72a8 Binary files /dev/null and b/Maps/Super Spleef/Spleef_Volcanic.zip differ diff --git a/Maps/Super Spleef/Spleef_Wood.zip b/Maps/Super Spleef/Spleef_Wood.zip new file mode 100644 index 000000000..ed8c6dacc Binary files /dev/null and b/Maps/Super Spleef/Spleef_Wood.zip differ diff --git a/Maps/The Bridges/BR_Icelands.zip b/Maps/The Bridges/BR_Icelands.zip new file mode 100644 index 000000000..90a2e7047 Binary files /dev/null and b/Maps/The Bridges/BR_Icelands.zip differ diff --git a/Maps/The Bridges/BR_Skylands.zip b/Maps/The Bridges/BR_Skylands.zip new file mode 100644 index 000000000..7e24e785e Binary files /dev/null and b/Maps/The Bridges/BR_Skylands.zip differ diff --git a/Maps/The Bridges/BR_Volcano.zip b/Maps/The Bridges/BR_Volcano.zip new file mode 100644 index 000000000..d394d5737 Binary files /dev/null and b/Maps/The Bridges/BR_Volcano.zip differ diff --git a/Maps/Turf Wars/TF_DoubleForts.zip b/Maps/Turf Wars/TF_DoubleForts.zip new file mode 100644 index 000000000..636147a29 Binary files /dev/null and b/Maps/Turf Wars/TF_DoubleForts.zip differ diff --git a/Maps/Turf Wars/TF_FireWater.zip b/Maps/Turf Wars/TF_FireWater.zip new file mode 100644 index 000000000..223910294 Binary files /dev/null and b/Maps/Turf Wars/TF_FireWater.zip differ diff --git a/Maps/Turf Wars/TF_FrostForts.zip b/Maps/Turf Wars/TF_FrostForts.zip new file mode 100644 index 000000000..b6eb1fe0e Binary files /dev/null and b/Maps/Turf Wars/TF_FrostForts.zip differ diff --git a/Maps/bob.rtf b/Maps/bob.rtf deleted file mode 100644 index 08778d7a8..000000000 --- a/Maps/bob.rtf +++ /dev/null @@ -1 +0,0 @@ -{\rtf1} \ No newline at end of file diff --git a/Maps/world_ruins.rar b/Maps/world_ruins.rar deleted file mode 100644 index 892f80d93..000000000 Binary files a/Maps/world_ruins.rar and /dev/null differ diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java index f019ad137..568a0fc65 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java @@ -27,7 +27,7 @@ public class LobbyBalancer implements Listener, Runnable { _plugin = plugin; _repository = new LobbyBalancerRepository(); - _repository.initialize(true); + _repository.initialize(false); loadLobbyServers(); diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCountRepository.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCountRepository.java index fdfac5111..dccb1be82 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCountRepository.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerCount/PlayerCountRepository.java @@ -74,6 +74,7 @@ public class PlayerCountRepository throw new SQLException("Creating bungee server failed, no rows affected."); } + resultSet.close(); resultSet = preparedStatementInsert.getGeneratedKeys(); if (resultSet.next()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java index 76355f0c4..239a98c90 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java @@ -390,7 +390,6 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable _movePacketMap.put(movePacket.a, velocityPacket); - //XXX packetList.forceAdd(velocityPacket); if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20) @@ -399,7 +398,6 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable { public void run() { - //XXX packetList.forceAdd(velocityPacket); } }); @@ -439,7 +437,6 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable _movePacketMap.put(movePacket.a, velocityPacket); - //XXX packetList.forceAdd(velocityPacket); if (_goingUp.contains(movePacket.a) && movePacket.c != 0 && movePacket.c > 20) @@ -448,7 +445,6 @@ public class DisguiseManager extends MiniPlugin implements IPacketRunnable { public void run() { - //XXX packetList.forceAdd(velocityPacket); } }); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java index 5d3797363..03a267f43 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java @@ -92,6 +92,7 @@ public class ServerStatusManager extends MiniPlugin plugin.getConfig().getString("serverstatus.connectionurl"), plugin.getConfig().getString("serverstatus.username"), plugin.getConfig().getString("serverstatus.password"), + plugin.getConfig().getBoolean("serverstatus.us"), _name, plugin.getConfig().getString("serverstatus.group"), address + ":" + _plugin.getServer().getPort(), event.getMaxPlayers() @@ -119,6 +120,9 @@ public class ServerStatusManager extends MiniPlugin GetPlugin().getConfig().addDefault("serverstatus.password", "tAbechAk3wR7tuTh"); GetPlugin().getConfig().set("serverstatus.password", GetPlugin().getConfig().getString("serverstatus.password")); + GetPlugin().getConfig().addDefault("serverstatus.us", true); + GetPlugin().getConfig().set("serverstatus.us", GetPlugin().getConfig().getBoolean("serverstatus.us")); + GetPlugin().getConfig().addDefault("serverstatus.name", "TEST-1"); GetPlugin().getConfig().set("serverstatus.name", GetPlugin().getConfig().getString("serverstatus.name")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusRepository.java index fb671030d..922ae3241 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusRepository.java @@ -20,19 +20,21 @@ public class ServerStatusRepository private static String UPDATE_PLAYER_COUNT_WITH_PLAYERS = "UPDATE ServerStatus SET updated = now(), serverName = ?, serverGroup = ?, motd = ?, players = ?, maxPlayers = ?, tps = ?, ram = ?, maxRam = ?, lastTimeWithPlayers = now() WHERE id = ?;"; private static String UPDATE_PLAYER_COUNT_WITHOUT_PLAYERS = "UPDATE ServerStatus SET updated = now(), serverName = ?, serverGroup = ?, motd = ?, players = ?, maxPlayers = ?, tps = ?, ram = ?, maxRam = ? WHERE id = ?;"; private static String RETRIEVE_ID = "SELECT id FROM ServerStatus WHERE address = ?;"; - private static String RETRIEVE_SERVER_STATUSES = "SELECT serverName, motd, players, maxPlayers FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = 'true' AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) < 10;"; + private static String RETRIEVE_SERVER_STATUSES = "SELECT ServerStatus.serverName, motd, players, maxPlayers FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = ? AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) < 10;"; private int _id = -1; + private boolean _us; private String _serverName; private String _serverGroup; private String _address; private int _maxPlayers = 0; - public ServerStatusRepository(String connectionUrl, String username, String password, String serverName, String serverGroup, String address, int maxPlayers) + public ServerStatusRepository(String connectionUrl, String username, String password, boolean us, String serverName, String serverGroup, String address, int maxPlayers) { _connectionString = connectionUrl; _userName = username; _password = password; + _us = us; _serverName = serverName; _serverGroup = serverGroup; _address = address; @@ -86,6 +88,8 @@ public class ServerStatusRepository throw new SQLException("Creating server status failed, no rows affected."); } + resultSet.close(); + resultSet = preparedStatementInsert.getGeneratedKeys(); if (resultSet.next()) @@ -240,6 +244,8 @@ public class ServerStatusRepository connection = DriverManager.getConnection(_connectionString, _userName, _password); preparedStatement = connection.prepareStatement(RETRIEVE_SERVER_STATUSES); + preparedStatement.setBoolean(1, _us); + resultSet = preparedStatement.executeQuery(); while (resultSet.next()) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 26debd92f..b97db96ac 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -216,7 +216,7 @@ public class HubManager extends MiniClientPlugin for (Rank rank : Rank.values()) { if (rank != Rank.ALL) - board.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, false) + ChatColor.RESET + " "); + board.registerNewTeam(rank.Name).setPrefix(rank.GetTag(true, true) + ChatColor.RESET + " "); else board.registerNewTeam(rank.Name).setPrefix(""); } diff --git a/Plugins/Mineplex.ServerMonitor/.project b/Plugins/Mineplex.ServerMonitor/.project new file mode 100644 index 000000000..77e4dc132 --- /dev/null +++ b/Plugins/Mineplex.ServerMonitor/.project @@ -0,0 +1,27 @@ + + + Mineplex.ServerMonitor + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.ui.externaltools.ExternalToolBuilder + auto,full,incremental, + + + LaunchConfigHandle + <project>/.externalToolBuilders/ServerMonitor.launch + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicServerData.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicServerData.java index 56b25f9cd..483cbfc36 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicServerData.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/DynamicServerData.java @@ -7,9 +7,10 @@ public class DynamicServerData public String Name; public String Address; public int AvailableCPU = 32; - public int AvailableRAM = 26624; + public int AvailableRAM = 14000; public HashMap ServerGroupCount = new HashMap(); + public boolean US; public void setServerGroupCount(ServerGroupData groupData, int count) { diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java index 471666d49..02c65cb6b 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/GroupStatusData.java @@ -1,25 +1,28 @@ package mineplex.servermonitor; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; public class GroupStatusData { + private int _serverNum = 0; private int _totalCount = 0; private int _joinableCount = 0; public int Players; public int MaxPlayers; + public int MaxServerNumber; public List EmptyServers = new ArrayList(); - public List Servers = new ArrayList(); + public HashMap Servers = new HashMap(); public void addServer(ServerStatusData serverStatusData) { Players += serverStatusData.Players; MaxPlayers += serverStatusData.MaxPlayers; - if (serverStatusData.Motd.contains("Starting") || serverStatusData.Motd.contains("Recruiting") || serverStatusData.Motd.contains("Waiting") || serverStatusData.Motd.contains("Cup") || serverStatusData.Motd.isEmpty() || serverStatusData.Motd.equals("")) + if (serverStatusData.Motd != null && (serverStatusData.Motd.contains("Starting") || serverStatusData.Motd.contains("Recruiting") || serverStatusData.Motd.contains("Waiting") || serverStatusData.Motd.contains("Cup") || serverStatusData.Motd.isEmpty() || serverStatusData.Motd.equals(""))) { if (serverStatusData.Players < serverStatusData.MaxPlayers) { @@ -43,7 +46,7 @@ public class GroupStatusData EmptyServers.add(serverStatusData); } - Servers.add(serverStatusData); + Servers.put(Integer.parseInt(serverStatusData.Name.split("-")[1]), serverStatusData); } public int getTotalServers() @@ -55,4 +58,19 @@ public class GroupStatusData { return _joinableCount; } + + public int getNextServerNumber() + { + _serverNum++; + + while (true) + { + if (!Servers.containsKey(_serverNum)) + { + return _serverNum; + } + + _serverNum++; + } + } } diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java index 2ca8fb5c4..0266f9382 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/Repository.java @@ -5,7 +5,6 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -18,13 +17,13 @@ public class Repository private String _password = "y2D4atu3Pene2asw"; private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS ServerStatus (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256), serverGroup VARCHAR(256), address VARCHAR(256), updated LONG, lastTimeWithPlayers LONG, motd VARCHAR(256), players INT, maxPlayers INT, tps INT, ram INT, maxRam INT, PRIMARY KEY (id));"; - private static String RETRIEVE_OLD_SERVER_STATUSES = "SELECT serverName, address, motd, players, maxPlayers FROM ServerStatus WHERE TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) > 10;"; + private static String RETRIEVE_OLD_SERVER_STATUSES = "SELECT ServerStatus.serverName, ServerStatus.address, motd, players, maxPlayers FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = false AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) > 10;"; private static String CREATE_DYNAMIC_TABLE = "CREATE TABLE IF NOT EXISTS DynamicServers (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256), address VARCHAR(256), US BOOLEAN NOT NULL DEFAULT 'true', PRIMARY KEY (id));"; - private static String RETRIEVE_AVAILABLE_SERVERS = "SELECT DynamicServers.serverName, DynamicServers.address, ServerStatus.serverGroup, COUNT(*) As serverCount FROM DynamicServers LEFT JOIN ServerStatus ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = 'false' GROUP BY DynamicServers.address, ServerStatus.serverGroup;"; - private static String RETRIEVE_SERVERGROUP_STATUSES = "SELECT ServerStatus.serverName, serverGroup, ServerStatus.address, players, maxPlayers, case when TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.lastTimeWithPlayers)) > 300 then 1 else 0 end as empty FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = 'false' AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) <= 10"; + private static String RETRIEVE_AVAILABLE_SERVERS = "SELECT DynamicServers.serverName, DynamicServers.address, DynamicServers.US, DynamicServers.availableCpu, DynamicServers.availableRam, ServerStatus.serverGroup, COUNT(*) As serverCount FROM DynamicServers LEFT JOIN ServerStatus ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = false GROUP BY DynamicServers.address, ServerStatus.serverGroup;"; + private static String RETRIEVE_SERVERGROUP_STATUSES = "SELECT ServerStatus.serverName, serverGroup, motd, ServerStatus.address, players, maxPlayers, case when TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.lastTimeWithPlayers)) > 300 then 1 else 0 end as empty FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.address, '%') WHERE DynamicServers.US = false AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) <= 10"; private static String RETRIEVE_SERVER_GROUP_DATA = "SELECT groupName, prefix, scriptName, requiredRam, cpuRequired, requiredTotal, requiredJoinable FROM ServerGroups;"; - + private static String DELETE_SERVER_STATUS = "DELETE FROM ServerStatus WHERE address = ? AND serverName = ?;"; public void initialize() { @@ -213,11 +212,12 @@ public class Repository serverStatusData.Name = resultSet.getString(1); String serverGroup = resultSet.getString(2); - String addressPortString = resultSet.getString(3); + serverStatusData.Motd = resultSet.getString(3); + String addressPortString = resultSet.getString(4); serverStatusData.Address = addressPortString.split(":")[0]; serverStatusData.Port = Integer.parseInt(addressPortString.split(":")[1]); - serverStatusData.Players = resultSet.getInt(4); - serverStatusData.MaxPlayers = resultSet.getInt(5); + serverStatusData.Players = resultSet.getInt(5); + serverStatusData.MaxPlayers = resultSet.getInt(6); serverStatusData.Empty = resultSet.getBoolean(7); if (!groupData.containsKey(serverGroup)) @@ -305,6 +305,9 @@ public class Repository serverGroupMap.put(serverGroupData.Name, serverGroupData); } + preparedStatement.close(); + resultSet.close(); + preparedStatement = connection.prepareStatement(RETRIEVE_AVAILABLE_SERVERS); resultSet = preparedStatement.executeQuery(); @@ -314,13 +317,16 @@ public class Repository dynamicServer.Name = resultSet.getString(1); dynamicServer.Address = resultSet.getString(2); + dynamicServer.US = resultSet.getBoolean(3); + dynamicServer.AvailableCPU = resultSet.getInt(4); + dynamicServer.AvailableRAM = resultSet.getInt(5); if (!serverMap.containsKey(dynamicServer.Name)) serverMap.put(dynamicServer.Name, dynamicServer); - String serverGroupName = resultSet.getString(3); + String serverGroupName = resultSet.getString(6); if (serverGroupMap.containsKey(serverGroupName)) - serverMap.get(dynamicServer.Name).setServerGroupCount(serverGroupMap.get(serverGroupName), resultSet.getInt(4)); + serverMap.get(dynamicServer.Name).setServerGroupCount(serverGroupMap.get(serverGroupName), resultSet.getInt(7)); } } catch (Exception exception) @@ -444,4 +450,50 @@ public class Repository return serverGroupMap.values(); } + + public void removeServerRecord(ServerStatusData serverToKill) + { + Connection connection = null; + PreparedStatement preparedStatement = null; + + try + { + connection = DriverManager.getConnection(_connectionString, _userName, _password); + + preparedStatement = connection.prepareStatement(DELETE_SERVER_STATUS); + preparedStatement.setString(1, serverToKill.Address + ":" + serverToKill.Port); + preparedStatement.setString(2, serverToKill.Name); + preparedStatement.execute(); + } + catch (Exception exception) + { + exception.printStackTrace(); + } + finally + { + if (preparedStatement != null) + { + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + + if (connection != null) + { + try + { + connection.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + } + } } diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index d95146856..2f5bda607 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -7,8 +7,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Map.Entry; - public class ServerMonitor { @@ -21,55 +19,20 @@ public class ServerMonitor while (true) { - /* - if (_count % 20 == 0) + if (_count % 10 == 0) { for (ServerStatusData statusData : _repository.retrieveOldServerStatuses()) { - String key = statusData.Address + " " + statusData.Name; - - String cmd = "/home/mineplex/restartServer.sh"; - Process process = null; - - try - { - process = new ProcessBuilder(new String[] {"/bin/sh", "-x", cmd, statusData.Address, statusData.Name}).start(); - process.waitFor(); - BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream())); - String line = reader.readLine(); - - while(line != null) - { - System.out.println(line); - line=reader.readLine(); - } - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - if (process != null) - { - process.destroy(); - } - } - - System.out.println("Sent restart command to " + key + ""); + System.out.println("----Old Server Status----"); + killServer(statusData); } - } - */ - if (_count % 10 == 0) - { + List dynamicServers = new ArrayList(_repository.retrieveDynamicServers()); Collection serverGroups = _repository.retrieveServerGroups(); HashMap groupStatusList = _repository.retrieveGroupStatusData(); for (ServerGroupData serverGroup : serverGroups) { - System.out.println("Checking Server Group " + serverGroup.Name); - if (!groupStatusList.containsKey(serverGroup.Name)) { groupStatusList.put(serverGroup.Name, new GroupStatusData()); @@ -77,94 +40,34 @@ public class ServerMonitor GroupStatusData groupStatus = groupStatusList.get(serverGroup.Name); - int serversToAdd = Math.max(serverGroup.RequiredTotalServers - groupStatus.getTotalServers(), serverGroup.RequiredJoinableServers - groupStatus.getJoinableCount()); - int serversToKill = groupStatus.EmptyServers.size() - serverGroup.RequiredJoinableServers; - int serverNum = groupStatus.getTotalServers() + 1; - if (serversToAdd > 0) + + int serversToAdd = Math.max(serverGroup.RequiredTotalServers - groupStatus.getTotalServers(), serverGroup.RequiredJoinableServers - groupStatus.getJoinableCount()); + int serversToKill = (groupStatus.getTotalServers() > serverGroup.RequiredTotalServers && groupStatus.getJoinableCount() > serverGroup.RequiredJoinableServers) ? Math.min(groupStatus.getJoinableCount() - serverGroup.RequiredJoinableServers, groupStatus.EmptyServers.size()) : 0; + + while (serversToAdd > 0) { - while (serversToAdd > 0) + int serverNum = groupStatus.getNextServerNumber(); + Collections.sort(dynamicServers, new DynamicServerSorter()); + DynamicServerData bestServer = getBestDynamicServer(dynamicServers, serverGroup); + + if (bestServer == null) { - Collections.sort(dynamicServers, new DynamicServerSorter()); - DynamicServerData bestServer = getBestDynamicServer(dynamicServers, serverGroup); - - if (bestServer == null) - { - System.out.println("No best dynamic server available for group " + serverGroup.Name); - break; - } - - String cmd = "/home/mineplex/easyRemoteStartServer.sh"; - Process process = null; - - try - { - process = new ProcessBuilder(new String[] {"/bin/sh", "-x", cmd, bestServer.Address, serverGroup.ScriptName, serverGroup.Prefix + "-" + serverNum, "1"}).start(); - process.waitFor(); - BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream())); - String line = reader.readLine(); - - while(line != null) - { - System.out.println(line); - line=reader.readLine(); - } - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - if (process != null) - { - process.destroy(); - } - } - - bestServer.setServerGroupCount(serverGroup, bestServer.ServerGroupCount.containsKey(serverGroup.Name) ? (bestServer.ServerGroupCount.get(serverGroup.Name) + 1) : 1); - System.out.println("Sent start command to " + bestServer.Address + " for " + serverGroup.Prefix + "-" + (groupStatus.getTotalServers() + 1)); - serversToAdd--; - serverNum++; + System.out.println("No best dynamic server available for group " + serverGroup.Name); + break; } + + System.out.println("Adding server for Server Group " + serverGroup.Name + " Req Total: " + serverGroup.RequiredTotalServers + " Req Joinable: " + serverGroup.RequiredJoinableServers + " | Actual Total: " + groupStatus.getTotalServers() + " Actual Joinable: " + groupStatus.getJoinableCount()); + startServer(bestServer, serverGroup, serverNum); + + serversToAdd--; } - else if (serversToKill > 0) + + while (serversToKill > 0) { - while (serversToKill > 0) - { - String cmd = "/home/mineplex/easyRemoteKillServer.sh"; - Process process = null; - - ServerStatusData serverToKill = groupStatus.EmptyServers.get(0); - - try - { - process = new ProcessBuilder(new String[] {"/bin/sh", "-x", cmd, serverToKill.Address, serverToKill.Name}).start(); - process.waitFor(); - BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream())); - String line = reader.readLine(); - - while(line != null) - { - System.out.println(line); - line=reader.readLine(); - } - } - catch (Exception e) - { - e.printStackTrace(); - } - finally - { - if (process != null) - { - process.destroy(); - } - } - - System.out.println("Sent start command to " + serverToKill.Address + " for " + serverToKill.Name); - serversToKill--; - } + System.out.println("Killing excess server for Server Group " + serverGroup.Name + " Req Total: " + serverGroup.RequiredTotalServers + " Req Joinable: " + serverGroup.RequiredJoinableServers + " | Actual Total: " + groupStatus.getTotalServers() + " Actual Joinable: " + groupStatus.getJoinableCount()); + killServer(groupStatus.EmptyServers.get(0)); + serversToKill--; } } } @@ -179,7 +82,7 @@ public class ServerMonitor } _count++; - _count %= 20; + _count %= 10000; } } @@ -189,7 +92,7 @@ public class ServerMonitor for (DynamicServerData serverData : dynamicServers) { - System.out.println("Checking Dynamic Server " + serverData.Name); + System.out.println("Checking " + serverData.Name + " Cpu:" + serverData.AvailableCPU + " Ram:" + serverData.AvailableRAM); if (serverData.AvailableRAM > serverGroup.RequiredRAM && serverData.AvailableCPU > serverGroup.RequiredCPU) { @@ -210,4 +113,72 @@ public class ServerMonitor return bestServer; } + + private static void killServer(ServerStatusData serverToKill) + { + String cmd = "/home/mineplex/easyRemoteKillServer.sh"; + Process process = null; + + try + { + process = new ProcessBuilder(new String[] {"/bin/sh", cmd, serverToKill.Address, serverToKill.Name}).start(); + process.waitFor(); + BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream())); + String line = reader.readLine(); + + while(line != null) + { + System.out.println(line); + line=reader.readLine(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + if (process != null) + { + process.destroy(); + } + } + + _repository.removeServerRecord(serverToKill); + System.out.println("Sent kill command to " + serverToKill.Address + " for " + serverToKill.Name); + } + + private static void startServer(DynamicServerData serverSpace, ServerGroupData serverGroup, int serverNum) + { + String cmd = "/home/mineplex/easyRemoteStartServer.sh"; + Process process = null; + + try + { + process = new ProcessBuilder(new String[] {"/bin/sh", cmd, serverSpace.Address, serverGroup.ScriptName, serverGroup.Prefix + "-" + serverNum, "1", serverSpace.US ? "us" : "eu"}).start(); + process.waitFor(); + BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream())); + String line = reader.readLine(); + + while(line != null) + { + System.out.println(line); + line=reader.readLine(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + finally + { + if (process != null) + { + process.destroy(); + } + } + + serverSpace.setServerGroupCount(serverGroup, serverSpace.ServerGroupCount.containsKey(serverGroup.Name) ? (serverSpace.ServerGroupCount.get(serverGroup.Name) + 1) : 1); + System.out.println("Sent start command (" + serverSpace.Address + "," + serverGroup.ScriptName + "," + serverGroup.Prefix + "-" + serverNum + ", 1," + (serverSpace.US ? "us" : "eu") + ")"); + } } diff --git a/Plugins/Nautilus.Game.Core/src/nautilus/game/core/GamePlugin.java b/Plugins/Nautilus.Game.Core/src/nautilus/game/core/GamePlugin.java index 6f0b38ffc..8c2c06e93 100644 --- a/Plugins/Nautilus.Game.Core/src/nautilus/game/core/GamePlugin.java +++ b/Plugins/Nautilus.Game.Core/src/nautilus/game/core/GamePlugin.java @@ -112,7 +112,7 @@ public abstract class GamePlugin extends JavaPlugin implements IRelation PacketHandler = new PacketHandler(this); _damage = new DamageManager(this, CombatManager, NpcManager, new DisguiseManager(this, PacketHandler)); _fire = new Fire(this, ConditionManager, _damage); - new Punish(this, GetWebServerAddress()); + new Punish(this, GetWebServerAddress(), ClientManager); new ServerStatusManager(this, new LagMeter(this, ClientManager)); diff --git a/Plugins/Nautilus.Game.MineKart/src/nautilus/game/minekart/MineKart.java b/Plugins/Nautilus.Game.MineKart/src/nautilus/game/minekart/MineKart.java index b786be06b..f99b91f62 100644 --- a/Plugins/Nautilus.Game.MineKart/src/nautilus/game/minekart/MineKart.java +++ b/Plugins/Nautilus.Game.MineKart/src/nautilus/game/minekart/MineKart.java @@ -108,7 +108,7 @@ public class MineKart extends JavaPlugin implements INautilusPlugin, Listener _creature = new Creature(this); - new Punish(this, GetWebServerAddress()); + new Punish(this, GetWebServerAddress(), _clientManager); new Explosion(this, _blockRestore); _teleport = new Teleport(this, _clientManager, _spawn);