Merge branch 'master' of ssh://dev.mineplex.com:7999/min/mineplex
Conflicts: Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java
This commit is contained in:
commit
255307088c
BIN
Maps/Bacon Brawl/Bacon_Lava.zip
Normal file
BIN
Maps/Bacon Brawl/Bacon_Lava.zip
Normal file
Binary file not shown.
BIN
Maps/Death Tag/DeathTag_Village.zip
Normal file
BIN
Maps/Death Tag/DeathTag_Village.zip
Normal file
Binary file not shown.
BIN
Maps/Dragon Escape/DragonEscape_Skylands.zip
Normal file
BIN
Maps/Dragon Escape/DragonEscape_Skylands.zip
Normal file
Binary file not shown.
BIN
Maps/Dragons/DR_Voyage.zip
Normal file
BIN
Maps/Dragons/DR_Voyage.zip
Normal file
Binary file not shown.
BIN
Maps/Dragons/Dragons_Island.zip
Normal file
BIN
Maps/Dragons/Dragons_Island.zip
Normal file
Binary file not shown.
BIN
Maps/Dragons/Dragons_SkyShip.zip
Normal file
BIN
Maps/Dragons/Dragons_SkyShip.zip
Normal file
Binary file not shown.
BIN
Maps/Dragons/Dragons_SkyVillage.zip
Normal file
BIN
Maps/Dragons/Dragons_SkyVillage.zip
Normal file
Binary file not shown.
BIN
Maps/Halloween Horror/2013.zip
Normal file
BIN
Maps/Halloween Horror/2013.zip
Normal file
Binary file not shown.
BIN
Maps/Hunger Games/Hypixel.zip
Normal file
BIN
Maps/Hunger Games/Hypixel.zip
Normal file
Binary file not shown.
BIN
Maps/Milk the Cow/Milk_BobsFarm.zip
Normal file
BIN
Maps/Milk the Cow/Milk_BobsFarm.zip
Normal file
Binary file not shown.
BIN
Maps/One in the Quiver/OITQ_Island_Village.zip
Normal file
BIN
Maps/One in the Quiver/OITQ_Island_Village.zip
Normal file
Binary file not shown.
BIN
Maps/One in the Quiver/OITQ_Ruins.zip
Normal file
BIN
Maps/One in the Quiver/OITQ_Ruins.zip
Normal file
Binary file not shown.
BIN
Maps/One in the Quiver/OITQ_TwinPeaks.zip
Normal file
BIN
Maps/One in the Quiver/OITQ_TwinPeaks.zip
Normal file
Binary file not shown.
BIN
Maps/One in the Quiver/OITQ_Village.zip
Normal file
BIN
Maps/One in the Quiver/OITQ_Village.zip
Normal file
Binary file not shown.
BIN
Maps/Runner/Runner_ClayPlaza.zip
Normal file
BIN
Maps/Runner/Runner_ClayPlaza.zip
Normal file
Binary file not shown.
BIN
Maps/Runner/Runner_Colloseum.zip
Normal file
BIN
Maps/Runner/Runner_Colloseum.zip
Normal file
Binary file not shown.
BIN
Maps/Runner/Runner_Euphoria.zip
Normal file
BIN
Maps/Runner/Runner_Euphoria.zip
Normal file
Binary file not shown.
BIN
Maps/Snake/Snake_Pit.zip
Normal file
BIN
Maps/Snake/Snake_Pit.zip
Normal file
Binary file not shown.
BIN
Maps/Snake/Snake_Volcanic.zip
Normal file
BIN
Maps/Snake/Snake_Volcanic.zip
Normal file
Binary file not shown.
BIN
Maps/Squid Shooter/Squid_JunglePools.zip
Normal file
BIN
Maps/Squid Shooter/Squid_JunglePools.zip
Normal file
Binary file not shown.
BIN
Maps/Super Paintball/1984.zip
Normal file
BIN
Maps/Super Paintball/1984.zip
Normal file
Binary file not shown.
BIN
Maps/Super Paintball/Besmap.zip
Normal file
BIN
Maps/Super Paintball/Besmap.zip
Normal file
Binary file not shown.
BIN
Maps/Super Paintball/Paintball_CookieTown.zip
Normal file
BIN
Maps/Super Paintball/Paintball_CookieTown.zip
Normal file
Binary file not shown.
BIN
Maps/Super Paintball/Paintball_FriendlyForest.zip
Normal file
BIN
Maps/Super Paintball/Paintball_FriendlyForest.zip
Normal file
Binary file not shown.
BIN
Maps/Super Paintball/Paintball_PaintedGardens.zip
Normal file
BIN
Maps/Super Paintball/Paintball_PaintedGardens.zip
Normal file
Binary file not shown.
BIN
Maps/Super Paintball/Paintball_TripleTowers.zip
Normal file
BIN
Maps/Super Paintball/Paintball_TripleTowers.zip
Normal file
Binary file not shown.
BIN
Maps/Super Smash Mobs/Smash_Adrift.zip
Normal file
BIN
Maps/Super Smash Mobs/Smash_Adrift.zip
Normal file
Binary file not shown.
BIN
Maps/Super Smash Mobs/Smash_Desert.zip
Normal file
BIN
Maps/Super Smash Mobs/Smash_Desert.zip
Normal file
Binary file not shown.
BIN
Maps/Super Smash Mobs/Smash_HyruleCastle.zip
Normal file
BIN
Maps/Super Smash Mobs/Smash_HyruleCastle.zip
Normal file
Binary file not shown.
BIN
Maps/Super Smash Mobs/Smash_Mushroom.zip
Normal file
BIN
Maps/Super Smash Mobs/Smash_Mushroom.zip
Normal file
Binary file not shown.
BIN
Maps/Super Smash Mobs/Smash_Skylands.zip
Normal file
BIN
Maps/Super Smash Mobs/Smash_Skylands.zip
Normal file
Binary file not shown.
BIN
Maps/Super Spleef/SP_Euphoria.zip
Normal file
BIN
Maps/Super Spleef/SP_Euphoria.zip
Normal file
Binary file not shown.
BIN
Maps/Super Spleef/SP_Temple.zip
Normal file
BIN
Maps/Super Spleef/SP_Temple.zip
Normal file
Binary file not shown.
BIN
Maps/Super Spleef/SP_Tibbles.zip
Normal file
BIN
Maps/Super Spleef/SP_Tibbles.zip
Normal file
Binary file not shown.
BIN
Maps/Super Spleef/Spleef_Volcanic.zip
Normal file
BIN
Maps/Super Spleef/Spleef_Volcanic.zip
Normal file
Binary file not shown.
BIN
Maps/Super Spleef/Spleef_Wood.zip
Normal file
BIN
Maps/Super Spleef/Spleef_Wood.zip
Normal file
Binary file not shown.
BIN
Maps/The Bridges/BR_Icelands.zip
Normal file
BIN
Maps/The Bridges/BR_Icelands.zip
Normal file
Binary file not shown.
BIN
Maps/The Bridges/BR_Skylands.zip
Normal file
BIN
Maps/The Bridges/BR_Skylands.zip
Normal file
Binary file not shown.
BIN
Maps/The Bridges/BR_Volcano.zip
Normal file
BIN
Maps/The Bridges/BR_Volcano.zip
Normal file
Binary file not shown.
BIN
Maps/Turf Wars/TF_DoubleForts.zip
Normal file
BIN
Maps/Turf Wars/TF_DoubleForts.zip
Normal file
Binary file not shown.
BIN
Maps/Turf Wars/TF_FireWater.zip
Normal file
BIN
Maps/Turf Wars/TF_FireWater.zip
Normal file
Binary file not shown.
BIN
Maps/Turf Wars/TF_FrostForts.zip
Normal file
BIN
Maps/Turf Wars/TF_FrostForts.zip
Normal file
Binary file not shown.
@ -1 +0,0 @@
|
||||
{\rtf1}
|
Binary file not shown.
@ -27,7 +27,7 @@ public class LobbyBalancer implements Listener, Runnable
|
||||
{
|
||||
_plugin = plugin;
|
||||
_repository = new LobbyBalancerRepository();
|
||||
_repository.initialize(true);
|
||||
_repository.initialize(false);
|
||||
|
||||
loadLobbyServers();
|
||||
|
||||
|
@ -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())
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
@ -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"));
|
||||
|
||||
|
@ -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())
|
||||
|
@ -216,7 +216,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
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("");
|
||||
}
|
||||
|
27
Plugins/Mineplex.ServerMonitor/.project
Normal file
27
Plugins/Mineplex.ServerMonitor/.project
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Mineplex.ServerMonitor</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/ServerMonitor.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -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<String, Integer> ServerGroupCount = new HashMap<String, Integer>();
|
||||
public boolean US;
|
||||
|
||||
public void setServerGroupCount(ServerGroupData groupData, int count)
|
||||
{
|
||||
|
@ -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<ServerStatusData> EmptyServers = new ArrayList<ServerStatusData>();
|
||||
public List<ServerStatusData> Servers = new ArrayList<ServerStatusData>();
|
||||
public HashMap<Integer, ServerStatusData> Servers = new HashMap<Integer, ServerStatusData>();
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<DynamicServerData> dynamicServers = new ArrayList<DynamicServerData>(_repository.retrieveDynamicServers());
|
||||
Collection<ServerGroupData> serverGroups = _repository.retrieveServerGroups();
|
||||
HashMap<String, GroupStatusData> 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") + ")");
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user