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 5cb5e1aa4..1d723e808 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/lobbyBalancer/LobbyBalancer.java @@ -37,7 +37,7 @@ public class LobbyBalancer implements Listener, Runnable loadLobbyServers(); _plugin.getProxy().getPluginManager().registerListener(_plugin, this); - _plugin.getProxy().getScheduler().schedule(_plugin, this, 150L, 150L, TimeUnit.MILLISECONDS); + _plugin.getProxy().getScheduler().schedule(_plugin, this, 250L, 250L, TimeUnit.MILLISECONDS); } @EventHandler diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java index 1430e36e4..f91366095 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStats.java @@ -28,6 +28,8 @@ public class PlayerStats implements Listener public void run() { _repository.addPlayer(event.getPlayer().getName()); + _repository.addPlayerVersion(event.getPlayer().getName(), event.getPlayer().getPendingConnection().getVersion()); + _repository.addPlayerIP(event.getPlayer().getName(), event.getPlayer().getPendingConnection().getAddress().getAddress().getHostAddress()); } }); } diff --git a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java index 4c7c3b23c..b1a18dcd2 100644 --- a/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java +++ b/Plugins/Mineplex.Bungee.Mineplexer/src/mineplex/bungee/playerStats/PlayerStatsRepository.java @@ -1,5 +1,6 @@ package mineplex.bungee.playerStats; +import java.net.InetAddress; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; @@ -16,8 +17,12 @@ public class PlayerStatsRepository private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS DailyUnique (id INT NOT NULL AUTO_INCREMENT, day VARCHAR(100), playerName VARCHAR(20), PRIMARY KEY (id), UNIQUE KEY unique_player_per_day (day, playerName));"; private static String INSERT_PLAYER = "INSERT INTO DailyUnique (day, playerName) values(curdate(), ?) ON DUPLICATE KEY UPDATE playerName=playerName;"; - private static String CREATE_VER_TABLE = "CREATE TABLE IF NOT EXISTS PlayerVersion (id INT NOT NULL AUTO_INCREMENT, playerName VARCHAR(20), version VARCHAR(40), PRIMARY KEY (id), UNIQUE KEY unique_player (playerName));"; - private static String INSERT_VER_PLAYER = "INSERT INTO PlayerVersion (playerName, version) values(?, ?) ON DUPLICATE KEY UPDATE version=version;"; + private static String CREATE_VER_TABLE = "CREATE TABLE IF NOT EXISTS PlayerVersion (id INT NOT NULL AUTO_INCREMENT, playerName VARCHAR(20), version INT, PRIMARY KEY (id), UNIQUE KEY unique_player (playerName));"; + private static String INSERT_VER_PLAYER = "INSERT INTO PlayerVersion (playerName, version) values(?, ?);"; + private static String UPDATE_VER_PLAYER = "UPDATE PlayerVersion SET version = ? WHERE playerName = ?;"; + + private static String CREATE_IP_TABLE = "CREATE TABLE IF NOT EXISTS PlayerIP (id INT NOT NULL AUTO_INCREMENT, playerName VARCHAR(20), ip VARCHAR(20), PRIMARY KEY (id), UNIQUE INDEX unique_player_ip (playerName, ip));"; + private static String INSERT_IP_PLAYER = "INSERT IGNORE INTO PlayerIP (playerName, ip) values(?, ?);"; public void initialize() { @@ -36,6 +41,11 @@ public class PlayerStatsRepository preparedStatement = _connection.prepareStatement(CREATE_VER_TABLE); preparedStatement.execute(); + + preparedStatement.close(); + + preparedStatement = _connection.prepareStatement(CREATE_IP_TABLE); + preparedStatement.execute(); } catch (Exception exception) { @@ -103,7 +113,7 @@ public class PlayerStatsRepository } } - public boolean addPlayerVersion(String playerName, String version) + public void addPlayerVersion(String playerName, int version) { PreparedStatement preparedStatement = null; @@ -112,34 +122,63 @@ public class PlayerStatsRepository if (_connection == null || _connection.isClosed()) _connection = DriverManager.getConnection(_connectionString, _userName, _password); - preparedStatement = _connection.prepareStatement(INSERT_VER_PLAYER, Statement.RETURN_GENERATED_KEYS); + preparedStatement = _connection.prepareStatement(UPDATE_VER_PLAYER); - preparedStatement.setString(1, playerName); - preparedStatement.setString(2, version); + preparedStatement.setInt(1, version); + preparedStatement.setString(2, playerName); int affectedRows = preparedStatement.executeUpdate(); if (affectedRows == 0) { - throw new SQLException("Adding player version record failed, no rows affected."); - } - - return true; + preparedStatement.close(); + preparedStatement = _connection.prepareStatement(INSERT_VER_PLAYER, Statement.RETURN_GENERATED_KEYS); + + preparedStatement.setString(1, playerName); + preparedStatement.setInt(2, version); + + preparedStatement.executeUpdate(); + } } catch (Exception exception) { exception.printStackTrace(); - - try + } + finally + { + if (preparedStatement != null) { - Thread.sleep(10); - } - catch (InterruptedException e) - { - e.printStackTrace(); + try + { + preparedStatement.close(); + } + catch (SQLException e) + { + e.printStackTrace(); + } } + } + } + + public void addPlayerIP(String playerName, String address) + { + PreparedStatement preparedStatement = null; + + try + { + if (_connection == null || _connection.isClosed()) + _connection = DriverManager.getConnection(_connectionString, _userName, _password); + + preparedStatement = _connection.prepareStatement(INSERT_IP_PLAYER, Statement.RETURN_GENERATED_KEYS); - return addPlayer(playerName); + preparedStatement.setString(1, playerName); + preparedStatement.setString(2, address); + + preparedStatement.executeUpdate(); + } + catch (Exception exception) + { + exception.printStackTrace(); } finally { diff --git a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/BungeeRotator.java b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/BungeeRotator.java index 359087bbe..5cd4b495f 100644 --- a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/BungeeRotator.java +++ b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/BungeeRotator.java @@ -119,21 +119,31 @@ public class BungeeRotator for (String address : usServers) { recordsToAdd.add(new ARecord("us", address, 300)); - log("Addding server address in DNS : " + "us " + address); + log("Adding server address in DNS : " + "us " + address); } - for (String address : euServers) - { - recordsToAdd.add(new ARecord("eu", address, 300)); - log("Addding server address in DNS : " + "eu " + address); - } - if (recordsToAdd.size() > 0) { new ApiPostCall("https://api.dnsmadeeasy.com/V2.0/dns/managed/", 962728, "/records/", "createMulti").Execute(recordsToAdd); log("Created " + recordsToAdd.size() + " records."); } + + recordsToAdd.clear(); + + for (String address : euServers) + { + recordsToAdd.add(new ARecord("eu", address, 300)); + log("Adding server address in DNS : " + "eu " + address); + } + + if (recordsToAdd.size() > 0) + { + new ApiPostCall("https://api.dnsmadeeasy.com/V2.0/dns/managed/", 962728, "/records/", "createMulti").Execute(recordsToAdd); + log("Created " + recordsToAdd.size() + " records."); + } + recordsToAdd.clear(); + if (recordsToDelete.size() > 0) { StringBuilder idBuilder = new StringBuilder(); diff --git a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java index 87ade774a..f4e7aac72 100644 --- a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java +++ b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/DnsMadeEasyApiCallBase.java @@ -51,13 +51,13 @@ public abstract class DnsMadeEasyApiCallBase try { String timeStamp = getServerTime(); - SecretKeySpec keySpec = new SecretKeySpec("8c9af8cc-d306-4df3-8de8-944deafa8239".getBytes(), "HmacSHA1"); + SecretKeySpec keySpec = new SecretKeySpec("35bb3b97-3815-4b63-b60b-eb1882c07b40".getBytes(), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(keySpec); byte[] hashBytes = mac.doFinal((timeStamp + "").getBytes()); Hex.encodeHexString(hashBytes); - request.addHeader("x-dnsme-apiKey", "610e21ee-4250-4b55-b637-a1fcc3847850"); + request.addHeader("x-dnsme-apiKey", "a9750980-b7df-4a7e-a047-2ade43628f0d"); request.addHeader("x-dnsme-requestDate", timeStamp + ""); request.addHeader("x-dnsme-hmac", Hex.encodeHexString(hashBytes)); request.addHeader("Content-Type", "application/json"); diff --git a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/token/DnsRecord.java b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/token/DnsRecord.java index a4d50c840..469b600be 100644 --- a/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/token/DnsRecord.java +++ b/Plugins/Mineplex.BungeeRotator/src/mineplex/bungee/api/token/DnsRecord.java @@ -6,6 +6,6 @@ public class DnsRecord public String name; public String type; public String value; - public String gtdLocation; + public String gtdLocation = "DEFAULT"; public int ttl; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index ae3ce09c2..602e2fd62 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -1,5 +1,6 @@ package mineplex.core.account.repository; +import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -19,6 +20,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.Callback; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UUIDFetcher; +import mineplex.core.database.DBPool; import mineplex.core.database.DatabaseRunnable; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; @@ -43,34 +45,9 @@ public class AccountRepository extends RepositoryBase public AccountRepository(JavaPlugin plugin, String webAddress) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true", "root", "tAbechAk3wR7tuTh"); + super(plugin, DBPool.ACCOUNT); _webAddress = webAddress; - - Statement statement = null; - - try - { - statement = getConnection().createStatement(); - } - catch (Exception exception) - { - exception.printStackTrace(); - } - finally - { - if (statement != null) - { - try - { - statement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } } @Override @@ -81,13 +58,11 @@ public class AccountRepository extends RepositoryBase public void login(NautHashMap loginProcessors, String uuid, String name) { - Statement statement = null; - ResultSet resultSet = null; - - try + try ( + Connection connection = getConnection(); + Statement statement = connection.createStatement() + ) { - statement = getConnection().createStatement(); - /* boolean statementStatus = statement.execute( "UPDATE accounts SET name='" + name + "', lastLogin=now() WHERE accounts.uuid = '" + uuid + "';" @@ -152,32 +127,6 @@ public class AccountRepository extends RepositoryBase { exception.printStackTrace(); } - finally - { - if (statement != null) - { - try - { - statement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } } public String GetClient(String name, UUID uuid, String ipAddress) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java index 2fa7140aa..5affc2a0b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/benefit/BenefitManagerRepository.java @@ -3,6 +3,7 @@ package mineplex.core.benefit; import java.sql.ResultSet; import java.sql.SQLException; +import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.column.ColumnVarChar; @@ -16,7 +17,7 @@ public class BenefitManagerRepository extends RepositoryBase public BenefitManagerRepository(JavaPlugin plugin) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); + super(plugin, DBPool.ACCOUNT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java b/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java index 8dacde695..d7747d086 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/DBPool.java @@ -16,6 +16,7 @@ public final class DBPool { BasicDataSource source = new BasicDataSource(); source.addConnectionProperty("autoReconnect", "true"); + source.addConnectionProperty("allowMultiQueries", "true"); source.setDefaultAutoCommit(true); source.setEnableAutoCommitOnReturn(true); source.setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); @@ -23,8 +24,8 @@ public final class DBPool source.setUrl(url); source.setUsername(username); source.setPassword(password); - source.setMaxTotal(2); - source.setMaxIdle(2); + source.setMaxTotal(3); + source.setMaxIdle(3); source.setTimeBetweenEvictionRunsMillis(180 * 1000); source.setSoftMinEvictableIdleTimeMillis(180 * 1000); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java index 88d3686bf..eab9840f2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/database/RepositoryBase.java @@ -1,7 +1,6 @@ package mineplex.core.database; import java.sql.Connection; -import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -22,58 +21,29 @@ import org.bukkit.plugin.java.JavaPlugin; public abstract class RepositoryBase implements Listener { - protected static Object _connectionLock = new Object(); - - private Connection _connection = null; - + // Queue for failed processes private static Object _queueLock = new Object(); - private NautHashMap _failedQueue = new NautHashMap(); - private String _connectionString; - private String _userName; - private String _password; - - protected JavaPlugin Plugin; - protected DataSource DataSource; - - public RepositoryBase(JavaPlugin plugin, String connectionString, String username, String password) - { - Plugin = plugin; - - _connectionString = connectionString; - _userName = username; - _password = password; - - Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() - { - public void run() - { - synchronized (_connectionLock) - { - initialize(); - update(); - } - } - }); - - plugin.getServer().getPluginManager().registerEvents(this, plugin); - } + private DataSource _dataSource; // Connection pool + protected JavaPlugin Plugin; // Plugin responsible for this repository + /** + * Constructor + * @param plugin - the {@link JavaPlugin} module responsible for this repository. + * @param dataSource - the {@link DataSource} responsible for providing the connection pool to this repository. + */ public RepositoryBase(JavaPlugin plugin, DataSource dataSource) { Plugin = plugin; - DataSource = dataSource; + _dataSource = dataSource; Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { public void run() { - synchronized (_connectionLock) - { - initialize(); - update(); - } + initialize(); + update(); } }); @@ -84,34 +54,39 @@ public abstract class RepositoryBase implements Listener protected abstract void update(); + /** + * @return the {@link DataSource} used by the repository for connection pooling. + */ + protected DataSource getConnectionPool() + { + return _dataSource; + } + + /** + * Requirements: {@link Connection}s must be closed after usage so they may be returned to the pool! + * @see Connection#close() + * @return a newly fetched {@link Connection} from the connection pool, if a connection can be made, null otherwise. + */ protected Connection getConnection() { - return getConnection(false); - } - - protected Connection getConnection(boolean validate) - { - synchronized (_connectionLock) + try { - try - { - if (_connection == null || (validate && !_connection.isValid(2))) - { - if (DataSource != null) - _connection = DataSource.getConnection(); - else - _connection = DriverManager.getConnection(_connectionString, _userName, _password); - } - } - catch (SQLException e) - { - e.printStackTrace(); - } + return _dataSource.getConnection(); + } + catch (SQLException e) + { + e.printStackTrace(); + // TODO: Log connection failures? + return null; } - - return _connection; } + /** + * Execute a query against the repository. + * @param query - the concatenated query to execute in string form. + * @param columns - the column data values used for insertion into the query. + * @return the number of rows affected by this query in the repository. + */ protected int executeUpdate(String query, Column...columns) { return executeInsert(query, null, columns); @@ -119,16 +94,14 @@ public abstract class RepositoryBase implements Listener protected int executeInsert(String query, ResultSetCallable callable, Column...columns) { - PreparedStatement preparedStatement = null; - int affectedRows = 0; - try + // Automatic resource management for handling/closing objects. + try ( + Connection connection = getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS) + ) { - getConnection(false); - - preparedStatement = _connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS); - for (int i=0; i < columns.length; i++) { columns[i].setValue(preparedStatement, i+1); @@ -137,49 +110,24 @@ public abstract class RepositoryBase implements Listener affectedRows = preparedStatement.executeUpdate(); if (callable != null) + { callable.processResultSet(preparedStatement.getGeneratedKeys()); + } } catch (SQLException exception) { - getConnection(true); executeInsert(query, callable, columns); } catch (Exception exception) { exception.printStackTrace(); } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - try - { - if (DataSource != null) - _connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } return affectedRows; } protected void executeQuery(PreparedStatement statement, ResultSetCallable callable, Column...columns) { - ResultSet resultSet = null; - try { for (int i=0; i < columns.length; i++) @@ -187,118 +135,41 @@ public abstract class RepositoryBase implements Listener columns[i].setValue(statement, i+1); } - resultSet = statement.executeQuery(); - - callable.processResultSet(resultSet); + try (ResultSet resultSet = statement.executeQuery()) + { + callable.processResultSet(resultSet); + } } catch (SQLException exception) { - getConnection(true); executeQuery(statement, callable, columns); } catch (Exception exception) { exception.printStackTrace(); } - finally - { - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - try - { - if (DataSource != null) - _connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } } protected void executeQuery(String query, ResultSetCallable callable, Column...columns) { - PreparedStatement preparedStatement = null; - - try + // Automatic resource management for handling/closing objects. + try ( + Connection connection = getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement(query) + ) { - getConnection(false); - - preparedStatement = _connection.prepareStatement(query); - executeQuery(preparedStatement, callable, columns); } catch (SQLException exception) { - getConnection(true); executeQuery(query, callable, columns); } catch (Exception exception) { exception.printStackTrace(); } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - - try - { - if (DataSource != null) - _connection.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } } - - protected int executeUpdate(PreparedStatement preparedStatement, Column...columns) - { - int affectedRows = 0; - try - { - for (int i=0; i < columns.length; i++) - { - columns[i].setValue(preparedStatement, i+1); - } - - affectedRows = preparedStatement.executeUpdate(); - } - catch (SQLException exception) - { - getConnection(true); - executeUpdate(preparedStatement, columns); - } - catch (Exception exception) - { - exception.printStackTrace(); - } - - return affectedRows; - } - protected void handleDatabaseCall(final DatabaseRunnable databaseRunnable, final String errorMessage) { Thread asyncThread = new Thread(new Runnable() @@ -341,24 +212,6 @@ public abstract class RepositoryBase implements Listener processFailedQueue(); } - @EventHandler - public void validateConnection(UpdateEvent event) - { - if (event.getType() != UpdateType.MIN_02 || DataSource != null) - return; - - Bukkit.getScheduler().runTaskAsynchronously(Plugin, new Runnable() - { - public void run() - { - synchronized (_connectionLock) - { - getConnection(true); - } - } - }); - } - private void processFailedQueue() { synchronized (_queueLock) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index 818c95df9..b7246e8be 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -8,6 +8,7 @@ import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.common.util.Callback; +import mineplex.core.database.DBPool; import mineplex.core.database.DatabaseRunnable; import mineplex.core.database.RepositoryBase; import mineplex.core.database.column.ColumnInt; @@ -33,7 +34,7 @@ public class DonationRepository extends RepositoryBase public DonationRepository(JavaPlugin plugin, String webAddress) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); + super(plugin, DBPool.ACCOUNT); _webAddress = webAddress; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java index 2a1cb7f27..444e98bbf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/inventory/data/InventoryRepository.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnInt; @@ -31,7 +32,7 @@ public class InventoryRepository extends RepositoryBase public InventoryRepository(JavaPlugin plugin) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); + super(plugin, DBPool.ACCOUNT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java index 2e0888f1e..1679bc36d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java @@ -1,5 +1,6 @@ package mineplex.core.leaderboard; +import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.column.ColumnInt; import mineplex.core.database.column.ColumnVarChar; @@ -35,7 +36,7 @@ public class StatEventsRepository extends RepositoryBase */ public StatEventsRepository(JavaPlugin plugin) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); + super(plugin, DBPool.ACCOUNT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 47b1948b5..6096e46e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -490,6 +490,7 @@ public class MessageManager extends MiniClientPlugin // If this is a admin message, or the sender isn't muted/ignoring the target if (adminMessage || canSenderMessageThem(sender, playerTarget)) { + /* // Construct the command to send to redis RedisMessage globalMessage = new RedisMessage(_serverName, @@ -529,6 +530,7 @@ public class MessageManager extends MiniClientPlugin // Time to send the message! globalMessage.publish(); + */ } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java index 5c334f60d..20601c066 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/PartyManager.java @@ -92,6 +92,7 @@ public class PartyManager extends MiniPlugin @EventHandler public void serverTransfer(ServerTransferEvent event) { + /* for (Party party : _parties) { if (party.GetLeader().equals(event.getPlayer().getName())) @@ -123,6 +124,7 @@ public class PartyManager extends MiniPlugin break; } } + */ } @EventHandler(priority = EventPriority.MONITOR) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java index 40f7815f0..84a1a2664 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java @@ -42,49 +42,11 @@ public class PetFactory _pets.put(EntityType.OCELOT, new Pet("Cat", EntityType.OCELOT, 6000)); _pets.put(EntityType.MUSHROOM_COW, new Pet("Mooshroom", EntityType.MUSHROOM_COW, 5000)); _pets.put(EntityType.WITHER, new Pet("Widder", EntityType.WITHER, -1)); - - List petTokens = new ArrayList(); - - for (Pet pet : _pets.values()) - { - PetSalesToken petToken = new PetSalesToken(); - petToken.Name = pet.GetPetName(); - petToken.PetType = pet.GetPetType().toString(); - - petTokens.add(petToken); - } - - for (PetSalesToken petToken : _repository.GetPets(petTokens)) - { - if (_pets.containsKey(EntityType.valueOf(petToken.PetType))) - { - _pets.get(EntityType.valueOf(petToken.PetType)).Update(petToken); - } - } } private void CreatePetExtras() { _petExtras.put(Material.SIGN, new PetExtra("Name Tag", Material.NAME_TAG, 100)); - - List petExtraTokens = new ArrayList(); - - for (PetExtra petExtra : _petExtras.values()) - { - PetExtraToken petToken = new PetExtraToken(); - petToken.Name = petExtra.GetName(); - petToken.Material = petExtra.GetMaterial().toString(); - - petExtraTokens.add(petToken); - } - - for (PetExtraToken token : _repository.GetPetExtras(petExtraTokens)) - { - if (_petExtras.containsKey(Material.valueOf(token.Material))) - { - _petExtras.get(Material.valueOf(token.Material)).Update(token); - } - } } public Collection GetPets() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java index a451cea77..44852c23e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/PreferencesRepository.java @@ -1,5 +1,6 @@ package mineplex.core.preferences; +import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -14,7 +15,7 @@ import mineplex.core.database.column.ColumnVarChar; public class PreferencesRepository extends RepositoryBase { - private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));"; + //private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));"; private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;"; private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ? WHERE uuid=?;"; @@ -36,12 +37,12 @@ public class PreferencesRepository extends RepositoryBase public void saveUserPreferences(NautHashMap preferences) { - PreparedStatement preparedStatement = null; - - try + try + ( + Connection connection = getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_ACCOUNT_PREFERENCES); + ) { - preparedStatement = getConnection().prepareStatement(UPDATE_ACCOUNT_PREFERENCES); - for (Entry entry : preferences.entrySet()) { preparedStatement.setBoolean(1, entry.getValue().HubGames); @@ -93,20 +94,6 @@ public class PreferencesRepository extends RepositoryBase { exception.printStackTrace(); } - finally - { - if (preparedStatement != null) - { - try - { - preparedStatement.close(); - } - catch (SQLException e) - { - e.printStackTrace(); - } - } - } } public UserPreferences loadClientInformation(final ResultSet resultSet) throws SQLException diff --git a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java index ad0cf6594..e84a1c1bd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/punish/Punish.java @@ -167,7 +167,7 @@ public class Punish extends MiniPlugin if (target != null) target.kickPlayer(kickReason); else - new mineplex.serverdata.transfers.PunishCommand(playerName, true, false, kickReason).publish(); + ;//new mineplex.serverdata.transfers.PunishCommand(playerName, true, false, kickReason).publish(); } }); @@ -193,7 +193,7 @@ public class Punish extends MiniPlugin target.playSound(target.getLocation(), Sound.CAT_MEOW, 1f, 1f); } else - new mineplex.serverdata.transfers.PunishCommand(playerName, false, finalDuration != 0, F.main("Punish", F.elem(C.cGray + C.Bold + (finalDuration != 0 ? "Mute" : "Warning") + " Reason: ") + reason)).publish(); + ;//new mineplex.serverdata.transfers.PunishCommand(playerName, false, finalDuration != 0, F.main("Punish", F.elem(C.cGray + C.Bold + (finalDuration != 0 ? "Mute" : "Warning") + " Reason: ") + reason)).publish(); _repository.LoadPunishClient(playerName, new Callback() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java index 968010e9c..4a9f91215 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/report/ReportRepository.java @@ -7,6 +7,7 @@ import java.util.UUID; import java.util.Map.Entry; import mineplex.core.common.util.NautHashMap; +import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnInt; @@ -40,7 +41,7 @@ This will be used to determine if staff are handling public ReportRepository(JavaPlugin plugin, String connectionString) { - super(plugin, connectionString, "root", "tAbechAk3wR7tuTh"); // TODO: Config file for host/pass? + super(plugin, DBPool.ACCOUNT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java index 69a5e3b64..eb85bae9d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/spawn/SpawnRepository.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnVarChar; @@ -22,8 +23,7 @@ public class SpawnRepository extends RepositoryBase public SpawnRepository(JavaPlugin plugin, String serverName) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); - + super(plugin, DBPool.ACCOUNT); _serverName = serverName; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java index 827b3605c..58c81c9f8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsRepository.java @@ -9,6 +9,7 @@ import java.util.List; import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.common.util.NautHashMap; +import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnVarChar; @@ -18,6 +19,7 @@ import org.jooq.DSLContext; import org.jooq.Insert; import org.jooq.Record2; import org.jooq.Result; +import org.jooq.SQLDialect; import org.jooq.Update; import org.jooq.impl.DSL; @@ -31,7 +33,7 @@ public class StatsRepository extends RepositoryBase public StatsRepository(JavaPlugin plugin) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); + super(plugin, DBPool.ACCOUNT); } @Override @@ -79,8 +81,7 @@ public class StatsRepository extends RepositoryBase { try { - - DSLContext context = DSL.using(getConnection(true)); + DSLContext context = DSL.using(getConnectionPool(), SQLDialect.MYSQL); List updates = new ArrayList<>(); List inserts = new ArrayList<>(); @@ -133,7 +134,7 @@ public class StatsRepository extends RepositoryBase synchronized (this) { - context = DSL.using(getConnection()); + context = DSL.using(getConnectionPool(), SQLDialect.MYSQL); } Result> result = context.select(Tables.stats.name, Tables.accountStats.value).from(Tables.accountStats) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java index f466d2c37..e8dba0b5f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java @@ -26,7 +26,7 @@ import mineplex.serverdata.transfers.SuicideCommand; public class ServerStatusManager extends MiniPlugin { // The default timeout (in seconds) before the ServerStatus expires. - public final int DEFAULT_SERVER_TIMEOUT = 15; + public final int DEFAULT_SERVER_TIMEOUT = 30; private ServerRepository _repository; private CoreClientManager _clientManager; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java index 67dd351f0..6e13426a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java @@ -46,17 +46,19 @@ public class Teleport extends MiniPlugin _serverName = getPlugin().getConfig().getString("serverstatus.name"); + /* RedisLocateHandler locateHandler = new RedisLocateHandler(this); ServerCommandManager.getInstance().registerCommandType("RedisLocate", RedisLocate.class, locateHandler); ServerCommandManager.getInstance().registerCommandType("RedisLocateCallback", RedisLocateCallback.class, locateHandler); + */ } @Override public void addCommands() { addCommand(new TeleportCommand(this)); - addCommand(new LocateCommand(this)); + //addCommand(new LocateCommand(this)); } public void handleLocateCallback(RedisLocateCallback callback) diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java index e052ee72e..ba4cd2729 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/TempRepository.java @@ -2,6 +2,7 @@ package mineplex.enjinTranslator; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.column.ColumnInt; import mineplex.core.database.column.ColumnVarChar; @@ -12,7 +13,7 @@ public class TempRepository extends RepositoryBase public TempRepository(JavaPlugin plugin) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); + super(plugin, DBPool.ACCOUNT); } public void addGemBooster(String name, int amount) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java index cad9425ef..f5be7a077 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/fields/repository/FieldRepository.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnByte; @@ -31,7 +32,7 @@ public class FieldRepository extends RepositoryBase public FieldRepository(JavaPlugin plugin) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); + super(plugin, DBPool.ACCOUNT); } public List getFieldBlocks(String server) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java index 59e7e796c..af43ab9f5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mail/MailRepository.java @@ -6,9 +6,11 @@ import java.util.UUID; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.database.Tables; import mineplex.database.tables.records.MailRecord; + import org.jooq.DSLContext; import org.jooq.Result; import org.jooq.impl.DSL; @@ -19,8 +21,8 @@ public class MailRepository extends RepositoryBase public MailRepository(JavaPlugin plugin, MailManager manager) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); - + super(plugin, DBPool.ACCOUNT); + _manager = manager; } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java index f47ee6a16..90cc6faa1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/LobbyMenu.java @@ -57,7 +57,7 @@ public class LobbyMenu extends ShopPageBase implements slot = Integer.parseInt(serverInfo.Name.split("-")[1]) - 1; if (slot >= 54) - break; + continue; if (serverInfo.Name.equalsIgnoreCase(getPlugin().getStatusManager().getCurrentServerName())) status = Material.EMERALD_BLOCK; @@ -81,6 +81,12 @@ public class LobbyMenu extends ShopPageBase implements else addItem(slot, new ShopItem(status, ChatColor.UNDERLINE + "" + ChatColor.BOLD + "" + ChatColor.WHITE + "Server " + serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1), lore.toArray(new String[lore.size()]), Integer.parseInt(serverInfo.Name.substring(serverInfo.Name.indexOf('-') + 1)), false)); } + + while (slot < 54) + { + clear(slot); + slot++; + } } public void Update() diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java index a0b5bab4f..87bd41db6 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/RedisServerRepository.java @@ -51,6 +51,12 @@ public class RedisServerRepository implements ServerRepository @Override public Collection getServerStatuses() + { + return getServerStatusesByPrefix(""); + } + + @Override + public Collection getServerStatusesByPrefix(String prefix) { Collection servers = new HashSet(); Jedis jedis = _readPool.getResource(); @@ -63,8 +69,11 @@ public class RedisServerRepository implements ServerRepository List> responses = new ArrayList>(); for (String serverName : getActiveNames(setKey)) { - String dataKey = concatenate(setKey, serverName); - responses.add(pipeline.get(dataKey)); + if (prefix.isEmpty() || serverName.startsWith(prefix)) + { + String dataKey = concatenate(setKey, serverName); + responses.add(pipeline.get(dataKey)); + } } pipeline.sync(); @@ -96,7 +105,7 @@ public class RedisServerRepository implements ServerRepository return servers; } - + @Override public Collection getServersByGroup(String serverGroup) { diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandManager.java index a66ebb936..5102d46e7 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerCommandManager.java @@ -28,8 +28,9 @@ public class ServerCommandManager */ private ServerCommandManager() { - _writePool = Utility.generatePool(ServerManager.getPubSubConnection()); // Hardcoded connection to standalone redis instance - _readPool = _writePool; + _writePool = Utility.generatePool(ServerManager.getMasterConnection()); // Publish to master instance + _readPool = Utility.generatePool(ServerManager.getSlaveConnection()); // Read from slave instance + _commandTypes = new HashMap(); initialize(); diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerManager.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerManager.java index ce9f54e49..224044738 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerManager.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerManager.java @@ -11,8 +11,12 @@ import java.util.Random; */ public class ServerManager { + + // Connection host to server database + private static final String DATABASE_HOST = "10.33.53.16"; + // Ports associated with slave redis instances - private static final int[] SLAVE_PORTS = {6378, 6380, 6381}; + private static final int[] SLAVE_PORTS = {6377, 6378, 6380, 6381, 6382}; private static Random random = new Random(); // The cached repository instances @@ -49,7 +53,7 @@ public class ServerManager */ public static ConnectionData getMasterConnection() { - return new ConnectionData("10.33.53.16", 6379); + return new ConnectionData(DATABASE_HOST, 6379); } /** @@ -59,14 +63,6 @@ public class ServerManager public static ConnectionData getSlaveConnection() { int port = SLAVE_PORTS[random.nextInt(SLAVE_PORTS.length)]; - return new ConnectionData("10.33.53.16", port); - } - - /** - * @return the {@link ConnectionData} associated with the dedicated PubSub instance. - */ - public static ConnectionData getPubSubConnection() - { - return new ConnectionData("10.33.53.16", 6377); + return new ConnectionData(DATABASE_HOST, port); } } diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerRepository.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerRepository.java index cd5e4a881..1c2bd5146 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerRepository.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/ServerRepository.java @@ -18,6 +18,8 @@ public interface ServerRepository */ public Collection getServerStatuses(); + public Collection getServerStatusesByPrefix(String prefix); + public Collection getServersByGroup(String serverGroup); /** diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java index 4007b59a3..52624bf4a 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/StaffServer.java @@ -1,5 +1,7 @@ package mineplex.staffServer; +import java.util.UUID; + import mineplex.core.account.CoreClientManager; import mineplex.core.antihack.AntiHack; import mineplex.core.chat.Chat; @@ -75,52 +77,10 @@ public class StaffServer extends JavaPlugin ((CraftServer)getServer()).setWhitelist(true); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() - { - public void run() - { - ((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("NDrew").toString(), "NDrew").loadProfile()); - } - }, 20L); - - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() - { - public void run() - { - ((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Morena").toString(), "Morena").loadProfile()); - } - }, 40L); - - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() - { - public void run() - { - ((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Revolark").toString(), "Revolark").loadProfile()); - } - }, 60L); - - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() - { - public void run() - { - ((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("EvilEsther").toString(), "EvilEsther").loadProfile()); - } - }, 80L); - - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() - { - public void run() - { - ((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Timmy48081_").toString(), "Timmy48081_").loadProfile()); - } - }, 100L); - - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() - { - public void run() - { - ((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("issh").toString(), "issh").loadProfile()); - } - }, 120L); + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("377bdea3-badc-448d-81c1-65db43b17ea4"), "Strutt20")); + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("cf1b629c-cc55-4eb4-be9e-3ca86dfc7b9d"), "mannalou")); + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("04a484d0-93e0-4777-a70c-808046917e3a"), "EvilEsther")); + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("adaa7613-6683-400f-baf8-7272c04b2cb4"), "Timmy48081_")); + ((CraftServer)getServer()).getHandle().addWhitelist(new GameProfile(UUID.fromString("2d5fd31b-0aa5-41db-a62d-a4611a24349a"), "ishh")); } } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java index 796bde45d..20cb041e0 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/password/PasswordRepository.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.plugin.java.JavaPlugin; +import mineplex.core.database.DBPool; import mineplex.core.database.RepositoryBase; import mineplex.core.database.ResultSetCallable; import mineplex.core.database.column.ColumnVarChar; @@ -23,8 +24,7 @@ public class PasswordRepository extends RepositoryBase public PasswordRepository(JavaPlugin plugin, String serverName) { - super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh"); - + super(plugin, DBPool.ACCOUNT); _serverName = serverName; }