Add SERVER_STATS to DBPool. Rename STATS to MINEPLEX_STATS

This commit is contained in:
Shaun Bennett 2016-02-19 19:54:06 -06:00
parent 8d7453b78e
commit 82d51a896f
5 changed files with 27 additions and 10 deletions

View File

@ -14,7 +14,7 @@ public class PlayerStatsRepository extends RepositoryBase
public PlayerStatsRepository()
{
super(DBPool.getStats());
super(DBPool.getPlayerStats());
}
@Override

View File

@ -47,7 +47,16 @@ public class PlayerCache
{
try
{
return _repository.getElement(uuid.toString());
System.out.println("Getting PlayerCache for " + uuid.toString());
PlayerInfo playerInfo = _repository.getElement(uuid.toString());
System.out.println("Got playerINfo: " + playerInfo);
if (playerInfo != null)
{
System.out.println("account id: " + playerInfo.getAccountId());
System.out.println("name: " + playerInfo.getName());
}
return playerInfo;
}
catch (Exception exception)
{

View File

@ -33,7 +33,7 @@ public class AntiHackRepository
{
PreparedStatement preparedStatement = null;
try (Connection connection = DBPool.getStats().getConnection())
try (Connection connection = DBPool.getMineplexStats().getConnection())
{
preparedStatement = connection.prepareStatement(UPDATE_PLAYER_OFFENSES);

View File

@ -15,8 +15,9 @@ public final class DBPool
private static DataSource ACCOUNT;
private static DataSource QUEUE;
private static DataSource MINEPLEX;
private static DataSource STATS_MINEPLEX;
private static DataSource MINEPLEX_STATS;
private static DataSource PLAYER_STATS;
private static DataSource SERVER_STATS;
private static DataSource openDataSource(String url, String username, String password)
{
@ -60,12 +61,12 @@ public final class DBPool
return MINEPLEX;
}
public static DataSource getStats()
public static DataSource getMineplexStats()
{
if (STATS_MINEPLEX == null)
if (MINEPLEX_STATS == null)
loadDataSources();
return STATS_MINEPLEX;
return MINEPLEX_STATS;
}
public static DataSource getPlayerStats()
@ -76,6 +77,11 @@ public final class DBPool
return PLAYER_STATS;
}
public static DataSource getServerStats()
{
return SERVER_STATS;
}
private static void loadDataSources()
{
try
@ -122,10 +128,12 @@ public final class DBPool
QUEUE = openDataSource("jdbc:mysql://" + dbHost, userName, password);
else if (dbSource.toUpperCase().equalsIgnoreCase("MINEPLEX"))
MINEPLEX = openDataSource("jdbc:mysql://" + dbHost, userName, password);
else if (dbSource.toUpperCase().equalsIgnoreCase("STATS"))
STATS_MINEPLEX = openDataSource("jdbc:mysql://" + dbHost, userName, password);
else if (dbSource.toUpperCase().equalsIgnoreCase("MINEPLEX_STATS"))
MINEPLEX_STATS = openDataSource("jdbc:mysql://" + dbHost, userName, password);
else if (dbSource.toUpperCase().equalsIgnoreCase("PLAYER_STATS"))
PLAYER_STATS = openDataSource("jdbc:mysql://" + dbHost, userName, password);
else if (dbSource.toUpperCase().equalsIgnoreCase("SERVER_STATS"))
SERVER_STATS = openDataSource("jdbc:mysql://" + dbHost, userName, password);
}
}
}

View File

@ -34,7 +34,7 @@ public class StatusHistoryRepository extends RepositoryBase
public StatusHistoryRepository()
{
super(DBPool.getStats());
super(DBPool.getServerStats());
PreparedStatement preparedStatement = null;