Reverted database connection pooling because it caused severe login delays.
This commit is contained in:
parent
30a1df1473
commit
1a09c14642
@ -0,0 +1,49 @@
|
||||
package mineplex.bungee.playerTracker;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class PlayerTracker implements Listener
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private PlayerTrackerRepository _repository = null;
|
||||
|
||||
public PlayerTracker(Plugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
|
||||
_repository = new PlayerTrackerRepository();
|
||||
_repository.initialize(!new File("eu.dat").exists());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerConnect(final ServerSwitchEvent event)
|
||||
{
|
||||
_plugin.getProxy().getScheduler().runAsync(_plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.updatePlayerServer(event.getPlayer().getName(), event.getPlayer().getServer().getInfo().getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerDisconnect(final PlayerDisconnectEvent event)
|
||||
{
|
||||
_plugin.getProxy().getScheduler().runAsync(_plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.deleteServerTransfers(event.getPlayer().getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.playerTracker;
|
||||
package mineplex.bungee.playerTracker;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
@ -6,29 +6,37 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
|
||||
public class PlayerTrackerRepository
|
||||
{
|
||||
private String _serverName = "";
|
||||
private static Object _connectionLock = new Object();
|
||||
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private boolean _us = true;
|
||||
|
||||
private static String CREATE_PLAYERMAP_TABLE = "CREATE TABLE IF NOT EXISTS playerMap (id INT NOT NULL AUTO_INCREMENT, playerName VARCHAR(256), serverName VARCHAR(256), us BOOLEAN NOT NULL DEFAULT 1, PRIMARY KEY (id), UNIQUE INDEX playerIndex (playerName));";
|
||||
private static String RETRIEVE_PLAYERMAP = "SELECT playerName, serverName FROM playerMap WHERE playerName = ? AND us = ?;";
|
||||
private static String INSERT_PLAYERMAP = "INSERT INTO playerMap (playerName, serverName, us) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE serverName = VALUES(serverName), us = VALUES(us);";
|
||||
private static String DELETE_PLAYERMAP = "DELETE FROM playerMap WHERE playerName = ? AND serverName = ? AND us = ?;";
|
||||
private static String DELETE_PLAYERMAP = "DELETE FROM playerMap WHERE playerName = ? AND us = ?;";
|
||||
|
||||
public void initialize(String serverName, boolean us)
|
||||
private Connection _connection = null;
|
||||
|
||||
public void initialize(boolean us)
|
||||
{
|
||||
_serverName = serverName;
|
||||
_us = us;
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.ACCOUNT.getConnection())
|
||||
try
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = connection.prepareStatement(CREATE_PLAYERMAP_TABLE);
|
||||
preparedStatement = _connection.prepareStatement(CREATE_PLAYERMAP_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -57,9 +65,16 @@ public class PlayerTrackerRepository
|
||||
PreparedStatement preparedStatement = null;
|
||||
String server = "N/A";
|
||||
|
||||
try (Connection connection = DBPool.ACCOUNT.getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(RETRIEVE_PLAYERMAP);
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_PLAYERMAP);
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setBoolean(2, _us);
|
||||
|
||||
@ -70,6 +85,7 @@ public class PlayerTrackerRepository
|
||||
server = resultSet.getString(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
@ -108,15 +124,22 @@ public class PlayerTrackerRepository
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.ACCOUNT.getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(DELETE_PLAYERMAP);
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(DELETE_PLAYERMAP);
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setString(2, _serverName);
|
||||
preparedStatement.setBoolean(3, _us);
|
||||
preparedStatement.setBoolean(2, _us);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
@ -137,19 +160,27 @@ public class PlayerTrackerRepository
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePlayerServer(String playerName)
|
||||
public void updatePlayerServer(String playerName, String serverName)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.ACCOUNT.getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(INSERT_PLAYERMAP);
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_PLAYERMAP);
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setString(2, _serverName);
|
||||
preparedStatement.setString(2, serverName);
|
||||
preparedStatement.setBoolean(3, _us);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
@ -20,9 +20,9 @@ public class RankBenefitsGiver9000Repository extends RepositoryBase
|
||||
private static String INSERT_BENEFIT = "INSERT INTO rankBenefits (uuid, benefit) VALUES (?, ?);";
|
||||
private static String RETRIEVE_BENEFITS = "SELECT benefit FROM rankBenefits WHERE uuid = ?;";
|
||||
|
||||
public RankBenefitsGiver9000Repository(Plugin plugin)
|
||||
public RankBenefitsGiver9000Repository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,14 +5,13 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.repository.token.LoginToken;
|
||||
import mineplex.core.account.repository.token.RankUpdateToken;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
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.column.ColumnBoolean;
|
||||
@ -33,9 +32,9 @@ public class AccountRepository extends RepositoryBase
|
||||
|
||||
private String _webAddress;
|
||||
|
||||
public AccountRepository(Plugin plugin, String webAddress)
|
||||
public AccountRepository(JavaPlugin plugin, String webAddress)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
|
||||
_webAddress = webAddress;
|
||||
}
|
||||
|
@ -1,44 +1,57 @@
|
||||
package mineplex.core.database;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.column.Column;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class RepositoryBase implements Listener
|
||||
{
|
||||
protected static Object _connectionLock = new Object();
|
||||
|
||||
private Connection _connection = null;
|
||||
|
||||
private static Object _queueLock = new Object();
|
||||
|
||||
private NautHashMap<DatabaseRunnable, String> _failedQueue = new NautHashMap<DatabaseRunnable, String>();
|
||||
|
||||
private final Plugin _plugin;
|
||||
private final DataSource _dataSource;
|
||||
private String _connectionString;
|
||||
private String _userName;
|
||||
private String _password;
|
||||
|
||||
public RepositoryBase(Plugin plugin, DataSource dataSource)
|
||||
protected JavaPlugin Plugin;
|
||||
|
||||
public RepositoryBase(JavaPlugin plugin, String connectionString, String username, String password)
|
||||
{
|
||||
_plugin = plugin;
|
||||
_dataSource = dataSource;
|
||||
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);
|
||||
@ -48,9 +61,19 @@ public abstract class RepositoryBase implements Listener
|
||||
|
||||
protected abstract void update();
|
||||
|
||||
protected Connection getConnection() throws SQLException
|
||||
protected Connection getConnection()
|
||||
{
|
||||
return getDataSource().getConnection();
|
||||
try
|
||||
{
|
||||
if (_connection == null || !_connection.isValid(1))
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return _connection;
|
||||
}
|
||||
|
||||
protected int executeUpdate(String query, Column<?>...columns)
|
||||
@ -59,9 +82,12 @@ public abstract class RepositoryBase implements Listener
|
||||
|
||||
int affectedRows = 0;
|
||||
|
||||
try (Connection connection = getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(query);
|
||||
if (_connection == null || !_connection.isValid(1))
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(query);
|
||||
|
||||
for (int i=0; i < columns.length; i++)
|
||||
{
|
||||
@ -131,9 +157,12 @@ public abstract class RepositoryBase implements Listener
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(query);
|
||||
if (_connection == null || !_connection.isValid(1))
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(query);
|
||||
|
||||
executeQuery(preparedStatement, callable, columns);
|
||||
}
|
||||
@ -254,14 +283,4 @@ public abstract class RepositoryBase implements Listener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
public DataSource getDataSource()
|
||||
{
|
||||
return _dataSource;
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,10 @@ package mineplex.core.donation.repository;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
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.column.ColumnInt;
|
||||
@ -30,9 +28,9 @@ public class DonationRepository extends RepositoryBase
|
||||
|
||||
private String _webAddress;
|
||||
|
||||
public DonationRepository(Plugin plugin, String webAddress)
|
||||
public DonationRepository(JavaPlugin plugin, String webAddress)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
|
||||
_webAddress = webAddress;
|
||||
}
|
||||
|
@ -22,11 +22,27 @@ public class EloManager extends MiniPlugin
|
||||
{
|
||||
super("Elo Rating", plugin);
|
||||
|
||||
_repository = new EloRepository();
|
||||
setupConfigValues(plugin);
|
||||
|
||||
_repository = new EloRepository(plugin.getConfig().getString("elo.connectionurl"));
|
||||
_ratingSystem = new EloRatingSystem(new KFactor(0, 1200, 25), new KFactor(1201, 1600, 20), new KFactor(1601, 2000, 15), new KFactor(2001, 2500, 10));
|
||||
_playerElos = new NautHashMap<String, NautHashMap<String, Integer>>();
|
||||
}
|
||||
|
||||
private void setupConfigValues(JavaPlugin plugin)
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.getConfig().addDefault("elo.connectionurl", "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
|
||||
plugin.getConfig().set("elo.connectionurl", plugin.getConfig().getString("elo.connectionurl"));
|
||||
plugin.saveConfig();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void retrievePlayersElos(final RetrieveClientInformationEvent event)
|
||||
{
|
||||
|
@ -7,18 +7,24 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.DBPool;
|
||||
|
||||
public class EloRepository
|
||||
{
|
||||
private String _connectionString;
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
|
||||
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
|
||||
private static String RETRIEVE_ELO = "SELECT gameType, elo FROM eloRating WHERE uuid = ?;";
|
||||
|
||||
public EloRepository()
|
||||
private Connection _connection = null;
|
||||
|
||||
public EloRepository(String connectionUrl)
|
||||
{
|
||||
_connectionString = connectionUrl;
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
@ -26,10 +32,12 @@ public class EloRepository
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
|
||||
try
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = connection.prepareStatement(CREATE_ELO_TABLE);
|
||||
preparedStatement = _connection.prepareStatement(CREATE_ELO_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -58,9 +66,14 @@ public class EloRepository
|
||||
|
||||
int affectedRows = 0;
|
||||
|
||||
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(INSERT_ELO);
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_ELO);
|
||||
|
||||
preparedStatement.setString(1, uuid);
|
||||
preparedStatement.setString(2, gameType);
|
||||
@ -105,9 +118,14 @@ public class EloRepository
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(RETRIEVE_ELO);
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_ELO);
|
||||
preparedStatement.setString(1, uuid.toString());
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
@ -5,11 +5,9 @@ import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
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;
|
||||
@ -28,9 +26,9 @@ public class FriendRepository extends RepositoryBase
|
||||
// Not mutual, need to drop accountFriend to recreate with constraint.
|
||||
// On add record need to check for a reverse uuidsource/uuidtarget and set mutual
|
||||
|
||||
public FriendRepository(Plugin plugin)
|
||||
public FriendRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,10 +5,8 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
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,9 +29,9 @@ public class InventoryRepository extends RepositoryBase
|
||||
private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);";
|
||||
private static String RETRIEVE_CLIENT_INVENTORY = "SELECT items.name, ic.name as category, count FROM accountInventory AS ai INNER JOIN items ON items.id = ai.itemId INNER JOIN itemCategories AS ic ON ic.id = items.categoryId INNER JOIN accounts ON accounts.id = ai.accountId WHERE accounts.uuid = ?;";
|
||||
|
||||
public InventoryRepository(Plugin plugin)
|
||||
public InventoryRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +21,9 @@ public class Logger
|
||||
|
||||
public Logger(JavaPlugin plugin)
|
||||
{
|
||||
_repository = new LoggerRepository(plugin.getConfig().getString("serverstatus.name"));
|
||||
setupConfigValues(plugin);
|
||||
|
||||
_repository = new LoggerRepository(plugin.getConfig().getString("log.connectionurl"), plugin.getConfig().getString("serverstatus.name"));
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler()
|
||||
{
|
||||
@ -34,6 +36,20 @@ public class Logger
|
||||
});
|
||||
}
|
||||
|
||||
private void setupConfigValues(JavaPlugin plugin)
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.getConfig().addDefault("log.connectionurl", "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
|
||||
plugin.getConfig().set("log.connectionurl", plugin.getConfig().getString("log.connectionurl"));
|
||||
plugin.saveConfig();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void log(final String message)
|
||||
{
|
||||
System.out.println(message);
|
||||
|
@ -5,17 +5,23 @@ import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
|
||||
public class LoggerRepository
|
||||
{
|
||||
private static Object _connectionLock = new Object();
|
||||
|
||||
private String _connectionString;
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_LOG_TABLE = "CREATE TABLE IF NOT EXISTS errorLog (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(256), message VARCHAR(256), date LONG, PRIMARY KEY (id));";
|
||||
private static String INSERT_LOG = "INSERT INTO errorLog (server, message, date) VALUES (?, ?, now());";
|
||||
|
||||
private Connection _connection = null;
|
||||
private String _serverName;
|
||||
|
||||
public LoggerRepository(String serverName)
|
||||
public LoggerRepository(String connectionUrl, String serverName)
|
||||
{
|
||||
_connectionString = connectionUrl;
|
||||
_serverName = serverName;
|
||||
|
||||
initialize();
|
||||
@ -25,10 +31,12 @@ public class LoggerRepository
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
|
||||
try
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = connection.prepareStatement(CREATE_LOG_TABLE);
|
||||
preparedStatement = _connection.prepareStatement(CREATE_LOG_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -55,9 +63,16 @@ public class LoggerRepository
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(INSERT_LOG);
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_LOG);
|
||||
|
||||
for (String msg : message)
|
||||
{
|
||||
@ -68,6 +83,7 @@ public class LoggerRepository
|
||||
|
||||
preparedStatement.executeBatch();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
|
@ -1,46 +0,0 @@
|
||||
package mineplex.core.playerTracker;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
|
||||
public class PlayerTracker extends MiniPlugin
|
||||
{
|
||||
private PlayerTrackerRepository _repository = null;
|
||||
|
||||
public PlayerTracker(JavaPlugin plugin, String serverName, boolean us)
|
||||
{
|
||||
super("Player Tracker", plugin);
|
||||
|
||||
_repository = new PlayerTrackerRepository();
|
||||
_repository.initialize(serverName, us);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void trackPlayer(final PlayerJoinEvent event)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.updatePlayerServer(event.getPlayer().getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void untrackPlayer(final ClientUnloadEvent event)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.deleteServerTransfers(event.GetName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -36,13 +36,28 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
|
||||
{
|
||||
super("Preferences", plugin);
|
||||
|
||||
_repository = new PreferencesRepository(plugin);
|
||||
setupConfigValues();
|
||||
|
||||
_repository = new PreferencesRepository(plugin, plugin.getConfig().getString("preferences.connectionurl"));
|
||||
_shop = new PreferencesShop(this, clientManager, donationManager);
|
||||
|
||||
AddCommand(new PreferencesCommand(this));
|
||||
}
|
||||
|
||||
private void setupConfigValues()
|
||||
{
|
||||
try
|
||||
{
|
||||
GetPlugin().getConfig().addDefault("preferences.connectionurl", "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10");
|
||||
GetPlugin().getConfig().set("preferences.connectionurl", GetPlugin().getConfig().getString("preferences.connectionurl"));
|
||||
GetPlugin().saveConfig();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UserPreferences AddPlayer(String player)
|
||||
{
|
||||
|
@ -1,17 +1,14 @@
|
||||
package mineplex.core.preferences;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
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;
|
||||
@ -23,9 +20,9 @@ public class PreferencesRepository extends RepositoryBase
|
||||
private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests FROM accountPreferences WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ? WHERE uuid=?;";
|
||||
|
||||
public PreferencesRepository(Plugin plugin)
|
||||
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, connectionString, "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -43,9 +40,9 @@ public class PreferencesRepository extends RepositoryBase
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(UPDATE_ACCOUNT_PREFERENCES);
|
||||
preparedStatement = getConnection().prepareStatement(UPDATE_ACCOUNT_PREFERENCES);
|
||||
|
||||
for (Entry<String, UserPreferences> entry : preferences.entrySet())
|
||||
{
|
||||
|
@ -1,13 +1,8 @@
|
||||
package mineplex.core.reward;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.database.Tables;
|
||||
import org.jooq.DSLContext;
|
||||
@ -18,9 +13,9 @@ import org.jooq.impl.DSL;
|
||||
*/
|
||||
public class RewardRepository extends RepositoryBase
|
||||
{
|
||||
public RewardRepository(Plugin plugin)
|
||||
public RewardRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -37,11 +32,12 @@ public class RewardRepository extends RepositoryBase
|
||||
|
||||
public void logReward(Player player, String type, String rarity, String reward)
|
||||
{
|
||||
try
|
||||
DSLContext context;
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
try (Connection connection = getConnection())
|
||||
{
|
||||
DSLContext context = DSL.using(connection);
|
||||
context = DSL.using(getConnection());
|
||||
}
|
||||
|
||||
context.insertInto(Tables.rewardLog)
|
||||
.set(Tables.rewardLog.accountId, DSL.select(Tables.accounts.id)
|
||||
@ -54,9 +50,3 @@ public class RewardRepository extends RepositoryBase
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,25 +6,35 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.DBPool;
|
||||
|
||||
public class SimpleStatsRepository
|
||||
{
|
||||
private static Object _connectionLock = new Object();
|
||||
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh"; //try to obfuscate this in the future!
|
||||
|
||||
private static String CREATE_STATS_TABLE = "CREATE TABLE IF NOT EXISTS simpleStats (id INT NOT NULL AUTO_INCREMENT, statName VARCHAR(64), statValue VARCHAR(64), PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_STATS_RECORDS = "SELECT simpleStats.statName, simpleStats.statValue FROM simpleStats;";
|
||||
private static String STORE_STATS_RECORD = "INSERT INTO simpleStats (statName,statValue) VALUES(?,?);";
|
||||
private static String RETRIEVE_STAT_RECORD = "SELECT simpleStats.statName, simpleStats.statValue FROM simpleStats WHERE statName = '?';";
|
||||
|
||||
private Connection _connection = null;
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
|
||||
try
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = connection.prepareStatement(CREATE_STATS_TABLE);
|
||||
preparedStatement = _connection.prepareStatement(CREATE_STATS_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -53,9 +63,16 @@ public class SimpleStatsRepository
|
||||
PreparedStatement preparedStatement = null;
|
||||
NautHashMap<String, String> statRecords = new NautHashMap<String, String>();
|
||||
|
||||
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(RETRIEVE_STATS_RECORDS);
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_STATS_RECORDS);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
@ -64,6 +81,7 @@ public class SimpleStatsRepository
|
||||
statRecords.put(resultSet.getString(1), resultSet.getString(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
@ -102,14 +120,22 @@ public class SimpleStatsRepository
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(STORE_STATS_RECORD);
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(STORE_STATS_RECORD);
|
||||
preparedStatement.setString(1, statName);
|
||||
preparedStatement.setString(2, statValue);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
@ -136,9 +162,16 @@ public class SimpleStatsRepository
|
||||
PreparedStatement preparedStatement = null;
|
||||
NautHashMap<String, String> statRecords = new NautHashMap<String, String>();
|
||||
|
||||
try (Connection connection = DBPool.STATS_MINEPLEX.getConnection())
|
||||
try
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(RETRIEVE_STAT_RECORD);
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_STAT_RECORD);
|
||||
preparedStatement.setString(1, statName);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
@ -148,6 +181,7 @@ public class SimpleStatsRepository
|
||||
statRecords.put(resultSet.getString(1), resultSet.getString(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineplex.core.stats;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -8,11 +7,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
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;
|
||||
@ -39,9 +36,9 @@ public class StatsRepository extends RepositoryBase
|
||||
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
|
||||
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";
|
||||
|
||||
public StatsRepository(Plugin plugin)
|
||||
public StatsRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,9 +85,9 @@ public class StatsRepository extends RepositoryBase
|
||||
{
|
||||
System.out.println("saving stats.");
|
||||
|
||||
try (Connection connection = getConnection())
|
||||
try
|
||||
{
|
||||
DSLContext context = DSL.using(connection);
|
||||
DSLContext context = DSL.using(getConnection());
|
||||
|
||||
List<Update> updates = new ArrayList<>();
|
||||
List<Insert> inserts = new ArrayList<>();
|
||||
@ -137,13 +134,16 @@ public class StatsRepository extends RepositoryBase
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerStats loadOfflinePlayerStats(String playerName) throws SQLException
|
||||
{
|
||||
try (Connection connection = getConnection())
|
||||
public PlayerStats loadOfflinePlayerStats(String playerName)
|
||||
{
|
||||
PlayerStats playerStats = null;
|
||||
|
||||
DSLContext context = DSL.using(connection);
|
||||
DSLContext context;
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
context = DSL.using(getConnection());
|
||||
}
|
||||
|
||||
Result<Record2<String, Integer>> result = context.select(Tables.stats.name, Tables.accountStats.value).from(Tables.accountStats)
|
||||
.join(Tables.stats)
|
||||
@ -153,6 +153,7 @@ public class StatsRepository extends RepositoryBase
|
||||
.where(Tables.accounts.name.eq(playerName)))
|
||||
).fetch();
|
||||
|
||||
|
||||
if (result.isNotEmpty())
|
||||
{
|
||||
playerStats = new PlayerStats();
|
||||
@ -164,7 +165,6 @@ public class StatsRepository extends RepositoryBase
|
||||
|
||||
return playerStats;
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerStats loadClientInformation(String uuid)
|
||||
{
|
||||
|
@ -1,9 +1,7 @@
|
||||
package mineplex.enjinTranslator;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
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,9 +10,9 @@ public class TempRepository extends RepositoryBase
|
||||
{
|
||||
private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, 5, ? FROM accounts WHERE accounts.name = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);";
|
||||
|
||||
public TempRepository(Plugin plugin)
|
||||
public TempRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
|
||||
public void addGemBooster(String name, int amount)
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.CustomTagFix;
|
||||
import mineplex.core.Replay;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.antistack.AntiStack;
|
||||
@ -26,12 +25,12 @@ import mineplex.core.movement.Movement;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.playerTracker.PlayerTracker;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.spawn.Spawn;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
@ -81,6 +80,8 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
DonationManager donationManager = new DonationManager(this, webServerAddress);
|
||||
|
||||
ServerConfiguration configuration = new ServerConfiguration(this);
|
||||
|
||||
//Other Modules
|
||||
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
|
||||
preferenceManager.GiveItem = true;
|
||||
@ -100,7 +101,6 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
||||
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager);
|
||||
new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs());
|
||||
|
||||
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager);
|
||||
|
||||
@ -134,7 +134,7 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
new ClassCombatShop(shopManager, clientManager, donationManager, "Knight", classManager.GetClass("Knight"));
|
||||
new ClassCombatShop(shopManager, clientManager, donationManager, "Assassin", classManager.GetClass("Assassin"));
|
||||
|
||||
new FriendManager(this, preferenceManager);
|
||||
new FriendManager(this, clientManager, preferenceManager);
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
|
@ -8,7 +8,6 @@ import java.util.UUID;
|
||||
|
||||
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;
|
||||
@ -29,7 +28,7 @@ public class PollRepository extends RepositoryBase
|
||||
|
||||
public PollRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,7 +9,6 @@ import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.memory.MemoryFix;
|
||||
import mineplex.core.monitor.LagMeter;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.playerTracker.PlayerTracker;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
@ -37,7 +37,6 @@ import mineplex.core.mount.MountManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.playerTracker.PlayerTracker;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
@ -122,12 +121,11 @@ public class Arcade extends JavaPlugin
|
||||
|
||||
//Arcade Manager
|
||||
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, webServerAddress);
|
||||
new PlayerTracker(this, serverStatusManager.getCurrentServerName(), serverStatusManager.getUs());
|
||||
|
||||
new MemoryFix(this);
|
||||
new CustomTagFix(this, packetHandler);
|
||||
|
||||
new FriendManager(this, preferenceManager);
|
||||
new FriendManager(this, _clientManager, preferenceManager);
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
|
@ -997,16 +997,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
getArcadeRepository().saveBasicStats(game.GetType(), IsTournamentServer(), (int) (System.currentTimeMillis() - game.getGameLiveTime()), data);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1028,16 +1021,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
getArcadeRepository().saveLeaderboardStats(0, type.ordinal(), data);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,12 @@
|
||||
package nautilus.game.arcade;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
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.GamesRecord;
|
||||
@ -22,9 +18,9 @@ public class ArcadeRepository extends RepositoryBase
|
||||
{
|
||||
private final String serverName;
|
||||
|
||||
public ArcadeRepository(Plugin plugin)
|
||||
public ArcadeRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
|
||||
serverName = plugin.getConfig().getString("serverstatus.name");
|
||||
}
|
||||
@ -41,11 +37,14 @@ public class ArcadeRepository extends RepositoryBase
|
||||
|
||||
}
|
||||
|
||||
public void saveBasicStats(GameType type, boolean tournament, int duration, Map<UUID, Boolean> players) throws SQLException
|
||||
public void saveBasicStats(GameType type, boolean tournament, int duration, Map<UUID, Boolean> players)
|
||||
{
|
||||
try (Connection connection = getConnection())
|
||||
DSLContext context;
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
DSLContext context = DSL.using(connection);
|
||||
context = DSL.using(getConnection());
|
||||
}
|
||||
|
||||
GamesRecord record = context.newRecord(Tables.games);
|
||||
record.setDuration(duration);
|
||||
@ -71,13 +70,15 @@ public class ArcadeRepository extends RepositoryBase
|
||||
|
||||
context.batch(queryList).execute();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveLeaderboardStats(int tournamentId, int gameId, Map<UUID, Boolean> players) throws SQLException
|
||||
public void saveLeaderboardStats(int tournamentId, int gameId, Map<UUID, Boolean> players)
|
||||
{
|
||||
try (Connection connection = getConnection())
|
||||
DSLContext context;
|
||||
|
||||
synchronized (this)
|
||||
{
|
||||
DSLContext context = DSL.using(connection);
|
||||
context = DSL.using(getConnection());
|
||||
}
|
||||
|
||||
List<Query> queryList = new ArrayList<>(players.size());
|
||||
|
||||
@ -104,4 +105,3 @@ public class ArcadeRepository extends RepositoryBase
|
||||
context.batch(queryList).execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user