Optimized mysql queries with server status' address/updated fields.
Removed double gems. Added BETA check for Hero only beta games.
This commit is contained in:
parent
b3f10b9d62
commit
d99a3c9253
Binary file not shown.
@ -13,6 +13,7 @@ import java.util.Map;
|
||||
import mineplex.bungee.lobbyBalancer.LobbyBalancer;
|
||||
import mineplex.bungee.motd.MotdManager;
|
||||
import mineplex.bungee.playerCount.PlayerCount;
|
||||
import mineplex.bungee.playerStats.PlayerStats;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.conf.YamlConfig;
|
||||
|
||||
@ -66,6 +67,7 @@ public class Mineplexer extends Plugin
|
||||
new LobbyBalancer(this);
|
||||
new PlayerCount(this);
|
||||
new FileUpdater(this);
|
||||
new PlayerStats(this);
|
||||
}
|
||||
|
||||
protected String readString(DataInputStream dataInputStream, int maxLength) throws IOException
|
||||
|
@ -5,6 +5,7 @@ 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.List;
|
||||
|
||||
@ -16,8 +17,8 @@ public class LobbyBalancerRepository
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
private boolean _us;
|
||||
|
||||
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, motd VARCHAR(256), players INT, maxPlayers INT, tps INT, ram INT, maxRam INT, PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_SERVER_STATUSES = "SELECT ServerStatus.serverName, ServerStatus.address, motd, players, maxPlayers FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = ? AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) < 10;";
|
||||
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), port VARCHAR(11), updated LONG, motd VARCHAR(256), players INT, maxPlayers INT, tps INT, ram INT, maxRam INT, PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_SERVER_STATUSES = "SELECT ServerStatus.serverName, ServerStatus.address, ServerStatus.port, motd, players, maxPlayers, now(), updated FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address = DynamicServers.privateAddress WHERE DynamicServers.US = ?;";
|
||||
|
||||
public void initialize(boolean us)
|
||||
{
|
||||
@ -59,6 +60,7 @@ public class LobbyBalancerRepository
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
List<ServerStatusData> serverData = new ArrayList<ServerStatusData>();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
try
|
||||
{
|
||||
@ -76,14 +78,17 @@ public class LobbyBalancerRepository
|
||||
|
||||
serverStatusData.Name = resultSet.getString(1);
|
||||
|
||||
String addressPortString = resultSet.getString(2);
|
||||
serverStatusData.Address = addressPortString.split(":")[0];
|
||||
serverStatusData.Port = Integer.parseInt(addressPortString.split(":")[1]);
|
||||
serverStatusData.Motd = resultSet.getString(3);
|
||||
serverStatusData.Players = resultSet.getInt(4);
|
||||
serverStatusData.MaxPlayers = resultSet.getInt(5);
|
||||
serverStatusData.Address = resultSet.getString(2);
|
||||
serverStatusData.Port = Integer.parseInt(resultSet.getString(3));
|
||||
serverStatusData.Motd = resultSet.getString(4);
|
||||
serverStatusData.Players = resultSet.getInt(5);
|
||||
serverStatusData.MaxPlayers = resultSet.getInt(6);
|
||||
|
||||
serverData.add(serverStatusData);
|
||||
long current = dateFormat.parse(resultSet.getString(7)).getTime();
|
||||
long updated = dateFormat.parse(resultSet.getString(8)).getTime();
|
||||
|
||||
if (current - updated < 10000)
|
||||
serverData.add(serverStatusData);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
@ -52,7 +52,9 @@ public class ServerStatusManager extends MiniPlugin
|
||||
plugin.getConfig().getBoolean("serverstatus.us"),
|
||||
_name,
|
||||
plugin.getConfig().getString("serverstatus.group"),
|
||||
address + ":" + _plugin.getServer().getPort(), event.getMaxPlayers()
|
||||
address,
|
||||
_plugin.getServer().getPort() + "",
|
||||
event.getMaxPlayers()
|
||||
);
|
||||
|
||||
if (_enabled)
|
||||
|
@ -6,7 +6,9 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerStatusRepository
|
||||
@ -16,22 +18,23 @@ public class ServerStatusRepository
|
||||
private String _password;
|
||||
|
||||
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 INSERT_PLAYER_COUNT = "INSERT INTO ServerStatus (serverName, serverGroup, address, updated, motd, players, maxPlayers, tps, ram, maxRam) values(?, ?, ?, now(), 'Configuring server.', ?, ?, 0, ?, ?);";
|
||||
private static String INSERT_PLAYER_COUNT = "INSERT INTO ServerStatus (serverName, serverGroup, address, port, updated, motd, players, maxPlayers, tps, ram, maxRam) values(?, ?, ?, ?, now(), 'Configuring server.', ?, ?, 0, ?, ?);";
|
||||
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 ServerStatus.serverName, motd, players, maxPlayers FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = ? AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) < 10;";
|
||||
private static String RETRIEVE_ID = "SELECT id FROM ServerStatus WHERE address = ? AND port = ?;";
|
||||
private static String RETRIEVE_SERVER_STATUSES = "SELECT ServerStatus.serverName, motd, players, maxPlayers, now(), updated FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address = DynamicServers.privateAddress WHERE DynamicServers.US = ?";
|
||||
|
||||
private int _id = -1;
|
||||
private boolean _us;
|
||||
private String _serverName;
|
||||
private String _serverGroup;
|
||||
private String _address;
|
||||
private String _port;
|
||||
private int _maxPlayers = 0;
|
||||
|
||||
Connection _connection = null;
|
||||
|
||||
public ServerStatusRepository(String connectionUrl, String username, String password, boolean us, String serverName, String serverGroup, String address, int maxPlayers)
|
||||
public ServerStatusRepository(String connectionUrl, String username, String password, boolean us, String serverName, String serverGroup, String address, String port, int maxPlayers)
|
||||
{
|
||||
_connectionString = connectionUrl;
|
||||
_userName = username;
|
||||
@ -40,6 +43,7 @@ public class ServerStatusRepository
|
||||
_serverName = serverName;
|
||||
_serverGroup = serverGroup;
|
||||
_address = address;
|
||||
_port = port;
|
||||
_maxPlayers = maxPlayers;
|
||||
}
|
||||
|
||||
@ -62,6 +66,7 @@ public class ServerStatusRepository
|
||||
// Retrieve id
|
||||
preparedStatementRetrieve = _connection.prepareStatement(RETRIEVE_ID);
|
||||
preparedStatementRetrieve.setString(1, _address);
|
||||
preparedStatementRetrieve.setString(2, _port);
|
||||
resultSet = preparedStatementRetrieve.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
@ -77,10 +82,11 @@ public class ServerStatusRepository
|
||||
preparedStatementInsert.setString(1, _serverName);
|
||||
preparedStatementInsert.setString(2, _serverGroup);
|
||||
preparedStatementInsert.setString(3, _address);
|
||||
preparedStatementInsert.setInt(4, 0);
|
||||
preparedStatementInsert.setInt(5, _maxPlayers);
|
||||
preparedStatementInsert.setInt(6, (int) ((Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()) / 1048576));
|
||||
preparedStatementInsert.setInt(7, (int) (Runtime.getRuntime().maxMemory() / 1048576));
|
||||
preparedStatementInsert.setString(4, _port);
|
||||
preparedStatementInsert.setInt(5, 0);
|
||||
preparedStatementInsert.setInt(6, _maxPlayers);
|
||||
preparedStatementInsert.setInt(7, (int) ((Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()) / 1048576));
|
||||
preparedStatementInsert.setInt(8, (int) (Runtime.getRuntime().maxMemory() / 1048576));
|
||||
|
||||
int affectedRows = preparedStatementInsert.executeUpdate();
|
||||
|
||||
@ -216,6 +222,7 @@ public class ServerStatusRepository
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
List<ServerStatusData> serverData = new ArrayList<ServerStatusData>();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
try
|
||||
{
|
||||
@ -237,8 +244,11 @@ public class ServerStatusRepository
|
||||
serverStatusData.Motd = resultSet.getString(2);
|
||||
serverStatusData.Players = resultSet.getInt(3);
|
||||
serverStatusData.MaxPlayers = resultSet.getInt(4);
|
||||
|
||||
serverData.add(serverStatusData);
|
||||
long current = dateFormat.parse(resultSet.getString(5)).getTime();
|
||||
long updated = dateFormat.parse(resultSet.getString(6)).getTime();
|
||||
|
||||
if (current - updated < 10000)
|
||||
serverData.add(serverStatusData);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
@ -390,6 +390,11 @@ public class ServerManager extends MiniPlugin
|
||||
if (partyPlayer == null)
|
||||
continue;
|
||||
|
||||
if ((serverInfo.Name.contains("BETA") && !_clientManager.Get(partyPlayer).GetRank().Has(Rank.HERO)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_clientManager.Get(partyPlayer).GetRank().Has(Rank.ULTRA) || _donationManager.Get(partyPlayer.getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA"))
|
||||
continue;
|
||||
|
||||
@ -406,6 +411,11 @@ public class ServerManager extends MiniPlugin
|
||||
if (partyPlayer == null)
|
||||
continue;
|
||||
|
||||
if ((serverInfo.Name.contains("BETA") && !_clientManager.Get(partyPlayer).GetRank().Has(Rank.HERO)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_clientManager.Get(partyPlayer).GetRank().Has(Rank.ULTRA) || _donationManager.Get(partyPlayer.getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA"))
|
||||
{
|
||||
partyPlayer.leaveVehicle();
|
||||
|
@ -63,11 +63,14 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
int greenCount = 0;
|
||||
int yellowCount = 0;
|
||||
String openFull = ChatColor.RESET + C.Line + "Get Ultra to join full servers!";
|
||||
String beta = ChatColor.RESET + C.Line + "Get Hero to join Beta servers!";
|
||||
String openFullUltra = ChatColor.RESET + C.Line + "Click to join!";
|
||||
|
||||
for (ServerInfo serverInfo : serverList)
|
||||
{
|
||||
boolean ownsUltraPackage = DonationManager.Get(Player.getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || Client.GetRank().Has(Rank.ULTRA);
|
||||
boolean hero = Client.GetRank().Has(Rank.HERO);
|
||||
|
||||
String inProgress = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? (ChatColor.RESET + C.Line + "Game in progress.") : (ChatColor.RESET + C.Line + "Click to spectate");
|
||||
String inProgressLine2 = (serverInfo.Game == null || serverInfo.ServerType.equalsIgnoreCase("Competitive")) ? null : (ChatColor.RESET + C.Line + "and wait for next game!");
|
||||
|
||||
@ -96,24 +99,31 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
lore.add(ChatColor.RESET + "");
|
||||
lore.add(ChatColor.RESET + serverInfo.MOTD);
|
||||
|
||||
if (serverInfo.CurrentPlayers >= serverInfo.MaxPlayers)
|
||||
if (serverInfo.Name.contains("BETA") && !hero)
|
||||
{
|
||||
if (serverInfo.Game.equalsIgnoreCase("Survival Games"))
|
||||
{
|
||||
lore.add(ChatColor.RESET + C.Line + "Full Survival Games servers");
|
||||
lore.add(ChatColor.RESET + C.Line + "cannot be joined.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ownsUltraPackage)
|
||||
lore.add(openFull);
|
||||
else
|
||||
lore.add(openFullUltra);
|
||||
}
|
||||
lore.add(beta);
|
||||
}
|
||||
else
|
||||
{
|
||||
lore.add(ChatColor.RESET + C.Line + "Click to join!");
|
||||
if (serverInfo.CurrentPlayers >= serverInfo.MaxPlayers)
|
||||
{
|
||||
if (serverInfo.Game.equalsIgnoreCase("Survival Games"))
|
||||
{
|
||||
lore.add(ChatColor.RESET + C.Line + "Full Survival Games servers");
|
||||
lore.add(ChatColor.RESET + C.Line + "cannot be joined.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ownsUltraPackage)
|
||||
lore.add(openFull);
|
||||
else
|
||||
lore.add(openFullUltra);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lore.add(ChatColor.RESET + C.Line + "Click to join!");
|
||||
}
|
||||
}
|
||||
|
||||
greenCount++;
|
||||
@ -194,7 +204,7 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
|
||||
{
|
||||
int slots = Plugin.GetRequiredSlots(player, serverInfo.ServerType);
|
||||
|
||||
if (serverInfo.MaxPlayers - serverInfo.CurrentPlayers < slots && !(DonationManager.Get(Player.getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || Client.GetRank().Has(Rank.ULTRA)))
|
||||
if ((serverInfo.Name.contains("BETA") && ! Client.GetRank().Has(Rank.HERO)) || (serverInfo.MaxPlayers - serverInfo.CurrentPlayers < slots && !(DonationManager.Get(Player.getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || Client.GetRank().Has(Rank.ULTRA))))
|
||||
{
|
||||
PlayDenySound(player);
|
||||
return;
|
||||
|
@ -5,6 +5,7 @@ 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;
|
||||
@ -16,14 +17,14 @@ public class Repository
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
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 ServerStatus.serverName, DynamicServers.address, ServerStatus.address, motd, players, maxPlayers FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = true AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) > 15;";
|
||||
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), port VARCHAR(11), 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 ServerStatus.serverName, DynamicServers.address, ServerStatus.address, ServerStatus.port, motd, players, maxPlayers, now(), updated FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address = DynamicServers.privateAddress WHERE DynamicServers.US = false;";
|
||||
|
||||
private static String CREATE_DYNAMIC_TABLE = "CREATE TABLE IF NOT EXISTS DynamicServers (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(256), address VARCHAR(256), privateAddress VARCHAR(256), US BOOLEAN NOT NULL DEFAULT 'true', PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_AVAILABLE_SERVERS = "SELECT DynamicServers.serverName, DynamicServers.address, DynamicServers.privateAddress, DynamicServers.US, DynamicServers.availableCpu, DynamicServers.availableRam, ServerStatus.serverGroup, COUNT(*) As serverCount FROM DynamicServers LEFT JOIN ServerStatus ON ServerStatus.address LIKE CONCAT(DynamicServers.privateAddress, '%') WHERE DynamicServers.US = true GROUP BY DynamicServers.address, ServerStatus.serverGroup;";
|
||||
private static String RETRIEVE_SERVERGROUP_STATUSES = "SELECT ServerStatus.serverName, serverGroup, motd, DynamicServers.address, 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.privateAddress, '%') WHERE DynamicServers.US = true AND TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.updated)) <= 15";
|
||||
private static String RETRIEVE_AVAILABLE_SERVERS = "SELECT DynamicServers.serverName, DynamicServers.address, DynamicServers.privateAddress, DynamicServers.US, DynamicServers.availableCpu, DynamicServers.availableRam, ServerStatus.serverGroup, COUNT(*) As serverCount FROM DynamicServers LEFT JOIN ServerStatus ON ServerStatus.address = DynamicServers.privateAddress WHERE DynamicServers.US = false GROUP BY DynamicServers.address, ServerStatus.serverGroup;";
|
||||
private static String RETRIEVE_SERVERGROUP_STATUSES = "SELECT ServerStatus.serverName, serverGroup, motd, DynamicServers.address, ServerStatus.address, ServerStatus.port, players, maxPlayers, case when TIME_TO_SEC(TIMEDIFF(now(), ServerStatus.lastTimeWithPlayers)) > 300 then 1 else 0 end as empty, now(), updated FROM ServerStatus INNER JOIN DynamicServers ON ServerStatus.address = DynamicServers.privateAddress WHERE DynamicServers.US = false";
|
||||
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 = ?;";
|
||||
private static String DELETE_SERVER_STATUS = "DELETE FROM ServerStatus WHERE address = ? AND port = ? AND serverName = ?;";
|
||||
|
||||
public static Connection connection;
|
||||
|
||||
@ -96,6 +97,7 @@ public class Repository
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
List<ServerStatusData> serverData = new ArrayList<ServerStatusData>();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
try
|
||||
{
|
||||
@ -112,14 +114,17 @@ public class Repository
|
||||
serverStatusData.Name = resultSet.getString(1);
|
||||
|
||||
serverStatusData.Address = resultSet.getString(2);
|
||||
String addressPortString = resultSet.getString(3);
|
||||
serverStatusData.PrivateAddress = addressPortString.split(":")[0];
|
||||
serverStatusData.Port = Integer.parseInt(addressPortString.split(":")[1]);
|
||||
serverStatusData.Motd = resultSet.getString(4);
|
||||
serverStatusData.Players = resultSet.getInt(5);
|
||||
serverStatusData.MaxPlayers = resultSet.getInt(6);
|
||||
serverStatusData.PrivateAddress = resultSet.getString(3);
|
||||
serverStatusData.Port = Integer.parseInt(resultSet.getString(4));
|
||||
serverStatusData.Motd = resultSet.getString(5);
|
||||
serverStatusData.Players = resultSet.getInt(6);
|
||||
serverStatusData.MaxPlayers = resultSet.getInt(7);
|
||||
|
||||
serverData.add(serverStatusData);
|
||||
long current = dateFormat.parse(resultSet.getString(8)).getTime();
|
||||
long updated = dateFormat.parse(resultSet.getString(9)).getTime();
|
||||
|
||||
if (current - updated > 15000)
|
||||
serverData.add(serverStatusData);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -161,7 +166,8 @@ public class Repository
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
HashMap<String, GroupStatusData> groupData = new HashMap<String, GroupStatusData>();
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
try
|
||||
{
|
||||
if (connection == null || connection.isClosed())
|
||||
@ -178,19 +184,22 @@ public class Repository
|
||||
String serverGroup = resultSet.getString(2);
|
||||
serverStatusData.Motd = resultSet.getString(3);
|
||||
serverStatusData.Address = resultSet.getString(4);
|
||||
String addressPortString = resultSet.getString(5);
|
||||
serverStatusData.PrivateAddress = addressPortString.split(":")[0];
|
||||
serverStatusData.Port = Integer.parseInt(addressPortString.split(":")[1]);
|
||||
serverStatusData.Players = resultSet.getInt(6);
|
||||
serverStatusData.MaxPlayers = resultSet.getInt(7);
|
||||
serverStatusData.Empty = resultSet.getBoolean(8);
|
||||
serverStatusData.PrivateAddress = resultSet.getString(5);
|
||||
serverStatusData.Port = Integer.parseInt(resultSet.getString(6));
|
||||
serverStatusData.Players = resultSet.getInt(7);
|
||||
serverStatusData.MaxPlayers = resultSet.getInt(8);
|
||||
serverStatusData.Empty = resultSet.getBoolean(9);
|
||||
|
||||
if (!groupData.containsKey(serverGroup))
|
||||
{
|
||||
groupData.put(serverGroup, new GroupStatusData());
|
||||
}
|
||||
|
||||
groupData.get(serverGroup).addServer(serverStatusData);
|
||||
long current = dateFormat.parse(resultSet.getString(10)).getTime();
|
||||
long updated = dateFormat.parse(resultSet.getString(11)).getTime();
|
||||
|
||||
if (current - updated < 15000)
|
||||
groupData.get(serverGroup).addServer(serverStatusData);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -392,8 +401,9 @@ public class Repository
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = connection.prepareStatement(DELETE_SERVER_STATUS);
|
||||
preparedStatement.setString(1, serverToKill.PrivateAddress + ":" + serverToKill.Port);
|
||||
preparedStatement.setString(2, serverToKill.Name);
|
||||
preparedStatement.setString(1, serverToKill.PrivateAddress);
|
||||
preparedStatement.setString(2, serverToKill.Port + "");
|
||||
preparedStatement.setString(3, serverToKill.Name);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
@ -29,7 +29,7 @@ public class ServerMonitor
|
||||
killServer(statusData);
|
||||
//restartServer(statusData);
|
||||
}
|
||||
|
||||
|
||||
List<DynamicServerData> dynamicServers = new ArrayList<DynamicServerData>(_repository.retrieveDynamicServers());
|
||||
|
||||
if (_count % 15 == 0)
|
||||
@ -84,25 +84,7 @@ public class ServerMonitor
|
||||
}
|
||||
|
||||
System.out.println("[" + bestServer.Name + ":" + bestServer.Address + "] Adding " + serverGroup.Name + " Req Total: " + serverGroup.RequiredTotalServers + " Req Joinable: " + serverGroup.RequiredJoinableServers + " | Actual Total: " + groupStatus.getTotalServers() + " Actual Joinable: " + groupStatus.getJoinableCount());
|
||||
|
||||
/*
|
||||
// Kill if any previous attempts stack up
|
||||
ServerStatusData newServer = new ServerStatusData();
|
||||
newServer.Address = bestServer.Address;
|
||||
newServer.Name = serverGroup.Prefix + "-" + serverNum;
|
||||
killServer(newServer, false);
|
||||
|
||||
// Delay between kill and start so we don't kill the new process
|
||||
try
|
||||
{
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
startServer(bestServer, serverGroup, serverNum);
|
||||
|
||||
serversToAdd--;
|
||||
@ -115,7 +97,7 @@ public class ServerMonitor
|
||||
serversToKill--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int processWaits = 0;
|
||||
|
||||
while (_processes.size() > 0)
|
||||
@ -163,7 +145,7 @@ public class ServerMonitor
|
||||
|
||||
processWaits++;
|
||||
}
|
||||
|
||||
|
||||
processWaits = 0;
|
||||
|
||||
try
|
||||
|
@ -30,7 +30,7 @@ public class GameGemManager implements Listener
|
||||
{
|
||||
ArcadeManager Manager;
|
||||
|
||||
boolean DoubleGem = true;
|
||||
boolean DoubleGem = false;
|
||||
|
||||
public GameGemManager(ArcadeManager manager)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ public class Dominate extends GamePlugin
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
{
|
||||
super.onEnable();
|
||||
|
||||
_gameEngine = new DominateGameEngine(this, HubConnection, ClientManager, DonationManager, ClassManager, ConditionManager, Energy, NpcManager,
|
||||
|
Loading…
Reference in New Issue
Block a user