Merge branch 'master' of http://184.154.0.242:7990/scm/min/mineplex
This commit is contained in:
commit
b7a4dd775c
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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();
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -212,6 +212,11 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
// Ignore Armor stand packets
|
||||
if (spawnPacket.b == 30 || spawnPacket.l == null || spawnPacket.l.c() == null || spawnPacket.a == 777777)
|
||||
{
|
||||
if (spawnPacket.b == 30)
|
||||
{
|
||||
_ignoreSkulls.add(spawnPacket.a);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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<String, ILoginProcessor> 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)
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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<DatabaseRunnable, String> _failedQueue = new NautHashMap<DatabaseRunnable, String>();
|
||||
|
||||
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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package mineplex.core.gadget.types;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -29,4 +31,10 @@ public abstract class MorphGadget extends Gadget
|
||||
if (_active.remove(player))
|
||||
UtilPlayer.message(player, F.main("Gadget", "You unmorphed from " + F.elem(GetName()) + "."));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
Disable(event.getEntity());
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
@ -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
|
||||
|
@ -490,6 +490,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
// 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<ClientMessage>
|
||||
|
||||
// Time to send the message!
|
||||
globalMessage.publish();
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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<PetSalesToken> petTokens = new ArrayList<PetSalesToken>();
|
||||
|
||||
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<PetExtraToken> petExtraTokens = new ArrayList<PetExtraToken>();
|
||||
|
||||
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<Pet> GetPets()
|
||||
|
@ -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<String, UserPreferences> preferences)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
try
|
||||
(
|
||||
Connection connection = getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_ACCOUNT_PREFERENCES);
|
||||
)
|
||||
{
|
||||
preparedStatement = getConnection().prepareStatement(UPDATE_ACCOUNT_PREFERENCES);
|
||||
|
||||
for (Entry<String, UserPreferences> 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
|
||||
|
@ -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<PunishClientToken>()
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<Update> updates = new ArrayList<>();
|
||||
List<Insert> 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<Record2<String, Integer>> result = context.select(Tables.stats.name, Tables.accountStats.value).from(Tables.accountStats)
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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<FieldBlockToken> getFieldBlocks(String server)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class LobbyMenu extends ShopPageBase<ServerManager, LobbyShop> 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<ServerManager, LobbyShop> 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()
|
||||
|
@ -51,6 +51,12 @@ public class RedisServerRepository implements ServerRepository
|
||||
|
||||
@Override
|
||||
public Collection<MinecraftServer> getServerStatuses()
|
||||
{
|
||||
return getServerStatusesByPrefix("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<MinecraftServer> getServerStatusesByPrefix(String prefix)
|
||||
{
|
||||
Collection<MinecraftServer> servers = new HashSet<MinecraftServer>();
|
||||
Jedis jedis = _readPool.getResource();
|
||||
@ -63,8 +69,11 @@ public class RedisServerRepository implements ServerRepository
|
||||
List<Response<String>> responses = new ArrayList<Response<String>>();
|
||||
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<MinecraftServer> getServersByGroup(String serverGroup)
|
||||
{
|
||||
|
@ -18,6 +18,8 @@ public interface ServerRepository
|
||||
*/
|
||||
public Collection<MinecraftServer> getServerStatuses();
|
||||
|
||||
public Collection<MinecraftServer> getServerStatusesByPrefix(String prefix);
|
||||
|
||||
public Collection<MinecraftServer> getServersByGroup(String serverGroup);
|
||||
|
||||
/**
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -155,10 +155,12 @@ public abstract class Game implements Listener
|
||||
public boolean DamageTeamOther = true;
|
||||
|
||||
public boolean BlockBreak = false;
|
||||
public boolean BlockBreakCreative = false;
|
||||
public HashSet<Integer> BlockBreakAllow = new HashSet<Integer>();
|
||||
public HashSet<Integer> BlockBreakDeny = new HashSet<Integer>();
|
||||
|
||||
public boolean BlockPlace = false;
|
||||
public boolean BlockPlaceCreative = false;
|
||||
public HashSet<Integer> BlockPlaceAllow = new HashSet<Integer>();
|
||||
public HashSet<Integer> BlockPlaceDeny = new HashSet<Integer>();
|
||||
|
||||
|
@ -1,20 +1,39 @@
|
||||
package nautilus.game.arcade.game.games.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -23,6 +42,7 @@ import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
@ -32,10 +52,12 @@ import mineplex.core.disguise.disguises.DisguiseChicken;
|
||||
import mineplex.core.disguise.disguises.DisguiseEnderman;
|
||||
import mineplex.core.disguise.disguises.DisguiseWither;
|
||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.mount.event.MountActivateEvent;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
||||
import nautilus.game.arcade.game.games.event.kits.*;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
@ -56,6 +78,8 @@ public class EventGame extends SoloGame
|
||||
private boolean _gadgetsEnabled = true;
|
||||
private NautHashMap<String, Integer> _radius = new NautHashMap<String, Integer>();
|
||||
|
||||
private NautHashMap<Material, Integer> _kitItems = new NautHashMap<Material, Integer>();
|
||||
|
||||
public EventGame(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.Event,
|
||||
@ -83,7 +107,10 @@ public class EventGame extends SoloGame
|
||||
this.TeleportsDisqualify = false;
|
||||
|
||||
this.PrepareFreeze = false;
|
||||
|
||||
|
||||
this.BlockPlaceCreative = true;
|
||||
this.BlockBreakCreative = true;
|
||||
|
||||
//Dont timeout
|
||||
this.GameTimeout = -1;
|
||||
|
||||
@ -97,29 +124,29 @@ public class EventGame extends SoloGame
|
||||
if (InProgress())
|
||||
joinTeam(event.getPlayer());
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// public void specToTeam(UpdateEvent event)
|
||||
// {
|
||||
// if (!InProgress())
|
||||
// return;
|
||||
//
|
||||
// if (event.getType() != UpdateType.FAST)
|
||||
// return;
|
||||
//
|
||||
// for (Player player : UtilServer.getPlayers())
|
||||
// {
|
||||
// if (!GetTeamList().get(0).HasPlayer(player))
|
||||
// {
|
||||
// joinTeam(player);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// @EventHandler
|
||||
// public void specToTeam(UpdateEvent event)
|
||||
// {
|
||||
// if (!InProgress())
|
||||
// return;
|
||||
//
|
||||
// if (event.getType() != UpdateType.FAST)
|
||||
// return;
|
||||
//
|
||||
// for (Player player : UtilServer.getPlayers())
|
||||
// {
|
||||
// if (!GetTeamList().get(0).HasPlayer(player))
|
||||
// {
|
||||
// joinTeam(player);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public void joinTeam(Player player)
|
||||
{
|
||||
Announce(C.cRed + C.Bold + player.getName() + " joined " + GetTeamList().get(0).GetName());
|
||||
|
||||
|
||||
//Set Team
|
||||
SetPlayerTeam(player, GetTeamList().get(0), true);
|
||||
|
||||
@ -133,10 +160,10 @@ public class EventGame extends SoloGame
|
||||
other.hidePlayer(player);
|
||||
other.showPlayer(player);
|
||||
}
|
||||
|
||||
|
||||
//Spawn
|
||||
GetTeamList().get(0).SpawnTeleport(player);
|
||||
|
||||
|
||||
//GameMode
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
@ -158,13 +185,32 @@ public class EventGame extends SoloGame
|
||||
UtilPlayer.message(player, F.value("/e scoreboard <Line #> [Text]", "Sets Scoreboard Text"));
|
||||
}
|
||||
|
||||
private void commandHelpSettings(Player player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Event", "Displaying Settings Commands;"));
|
||||
UtilPlayer.message(player, F.value("/e damage all", "Toggles All Damage"));
|
||||
UtilPlayer.message(player, F.value("/e damage pvp", "Toggles PvP Damage"));
|
||||
UtilPlayer.message(player, F.value("/e damage pve", "Toggles PvE Damage"));
|
||||
UtilPlayer.message(player, F.value("/e damage pve", "Toggles EvP Damage"));
|
||||
UtilPlayer.message(player, F.value("/e health <-1 to 20>", "Locks Players Health"));
|
||||
UtilPlayer.message(player, F.value("/e hunger <-1 to 20>", "Locks Players Hunger"));
|
||||
UtilPlayer.message(player, F.value("/e item drop", "Toggles Item Drop"));
|
||||
UtilPlayer.message(player, F.value("/e item pickup", "Toggles Item Pickup"));
|
||||
UtilPlayer.message(player, F.value("/e blockplace", "Toggles Block Placing (On/Off)"));
|
||||
UtilPlayer.message(player, F.value("/e blockplace whitelist <id>", "Whitelists Block Place"));
|
||||
UtilPlayer.message(player, F.value("/e blockplace blacklist <id>", "Whitelists Block Place"));
|
||||
UtilPlayer.message(player, F.value("/e blockbreak", "Toggles Block Breaking (On/Off)"));
|
||||
UtilPlayer.message(player, F.value("/e blockbreak whitelist <id>", "Whitelists Block Break"));
|
||||
UtilPlayer.message(player, F.value("/e blockbreak blacklist <id>", "Blacklists Block Break"));
|
||||
}
|
||||
|
||||
//Command Handler
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void commandHandler(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (!InProgress())
|
||||
return;
|
||||
|
||||
|
||||
if (!event.getMessage().toLowerCase().startsWith("/e "))
|
||||
return;
|
||||
|
||||
@ -176,10 +222,16 @@ public class EventGame extends SoloGame
|
||||
//Trim off /e and split to args
|
||||
String[] args = event.getMessage().substring(3, event.getMessage().length()).split(" ");
|
||||
|
||||
if (args.length == 0)
|
||||
if (args.length == 0 || args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
commandHelp(event.getPlayer());
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("settings"))
|
||||
{
|
||||
commandHelpSettings(event.getPlayer());
|
||||
}
|
||||
|
||||
//XXX Commands
|
||||
else if (args[0].equalsIgnoreCase("tp"))
|
||||
{
|
||||
commandTeleport(event.getPlayer(), args);
|
||||
@ -208,6 +260,221 @@ public class EventGame extends SoloGame
|
||||
{
|
||||
commandScoreboard(event.getPlayer(), args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("whitelist"))
|
||||
{
|
||||
commandWhitelist(event.getPlayer(), args);
|
||||
}
|
||||
|
||||
|
||||
//XXX Settings
|
||||
else if (event.getMessage().toLowerCase().equals("/e damage all"))
|
||||
{
|
||||
Damage = !Damage;
|
||||
Announce(F.main("Event Settings", F.value("Damage All", F.tf(Damage))));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().equals("/e damage pvp"))
|
||||
{
|
||||
DamagePvP = !DamagePvP;
|
||||
Announce(F.main("Event Settings", F.value("Damage PvP", F.tf(DamagePvP))));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().equals("/e damage pve"))
|
||||
{
|
||||
DamagePvE = !DamagePvE;
|
||||
Announce(F.main("Event Settings", F.value("Damage PvE", F.tf(DamagePvE))));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().equals("/e damage evp"))
|
||||
{
|
||||
DamageEvP = !DamageEvP;
|
||||
Announce(F.main("Event Settings", F.value("Damage EvP", F.tf(DamageEvP))));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("health"))
|
||||
{
|
||||
commandHealth(event.getPlayer(), args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("hunger"))
|
||||
{
|
||||
commandHunger(event.getPlayer(), args);
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().equals("/e item drop"))
|
||||
{
|
||||
ItemDrop = !ItemDrop;
|
||||
Announce(F.main("Event Settings", F.value("Item Drop", F.tf(ItemDrop))));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().equals("/e item pickup"))
|
||||
{
|
||||
ItemPickup = !ItemPickup;
|
||||
Announce(F.main("Event Settings", F.value("Item Pickup", F.tf(ItemPickup))));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().equals("/e blockplace"))
|
||||
{
|
||||
BlockPlace = !BlockPlace;
|
||||
Announce(F.main("Event Settings", F.value("Block Place", F.tf(BlockPlace))));
|
||||
}
|
||||
else if (args.length >= 4 && args[0].equalsIgnoreCase("blockplace")
|
||||
&& (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist"))
|
||||
&& (args[2].equalsIgnoreCase("add") || args[2].equalsIgnoreCase("remove")))
|
||||
{
|
||||
commandBlockPlace(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2].equalsIgnoreCase("add"));
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().equals("/e blockbreak"))
|
||||
{
|
||||
BlockBreak = !BlockBreak;
|
||||
Announce(F.main("Event Settings", F.value("Block Break", F.tf(BlockBreak))));
|
||||
}
|
||||
else if (args.length >= 4 && args[0].equalsIgnoreCase("blockbreak")
|
||||
&& (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist"))
|
||||
&& (args[2].equalsIgnoreCase("add") || args[2].equalsIgnoreCase("remove")))
|
||||
{
|
||||
commandBlockBreak(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2].equalsIgnoreCase("add"));
|
||||
}
|
||||
}
|
||||
|
||||
private void commandBlockPlace(Player player, String[] args, boolean whitelist, boolean add)
|
||||
{
|
||||
try
|
||||
{
|
||||
int blockId = Integer.parseInt(args[3]);
|
||||
|
||||
if (whitelist)
|
||||
{
|
||||
if (add)
|
||||
{
|
||||
BlockPlaceAllow.add(blockId);
|
||||
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Added " + blockId)));
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockPlaceAllow.remove(blockId);
|
||||
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Removed " + blockId)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (add)
|
||||
{
|
||||
BlockPlaceDeny.add(blockId);
|
||||
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Added " + blockId)));
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockPlaceDeny.remove(blockId);
|
||||
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Removed " + blockId)));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
commandHelpSettings(player);
|
||||
}
|
||||
|
||||
private void commandBlockBreak(Player player, String[] args, boolean whitelist, boolean add)
|
||||
{
|
||||
try
|
||||
{
|
||||
int blockId = Integer.parseInt(args[3]);
|
||||
|
||||
if (whitelist)
|
||||
{
|
||||
if (add)
|
||||
{
|
||||
BlockBreakAllow.add(blockId);
|
||||
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Added " + blockId)));
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockBreakAllow.remove(blockId);
|
||||
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Removed " + blockId)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (add)
|
||||
{
|
||||
BlockBreakDeny.add(blockId);
|
||||
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Added " + blockId)));
|
||||
}
|
||||
else
|
||||
{
|
||||
BlockBreakDeny.remove(blockId);
|
||||
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Removed " + blockId)));
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
commandHelpSettings(player);
|
||||
}
|
||||
|
||||
private void commandHealth(Player player, String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (args.length >= 2)
|
||||
{
|
||||
int health = Integer.parseInt(args[1]);
|
||||
|
||||
if (health <= 0)
|
||||
health = -1;
|
||||
if (health > 20)
|
||||
health = 20;
|
||||
|
||||
HealthSet = health;
|
||||
|
||||
if (HealthSet == -1)
|
||||
Announce(F.main("Event Settings", F.value("Health Set", "Disabled")));
|
||||
else
|
||||
Announce(F.main("Event Settings", F.value("Health Set", HealthSet + "")));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
commandHelpSettings(player);
|
||||
}
|
||||
|
||||
private void commandHunger(Player player, String[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (args.length >= 2)
|
||||
{
|
||||
int hunger = Integer.parseInt(args[1]);
|
||||
|
||||
if (hunger <= 0)
|
||||
hunger = -1;
|
||||
if (hunger > 20)
|
||||
hunger = 20;
|
||||
|
||||
HungerSet = hunger;
|
||||
|
||||
if (HungerSet == -1)
|
||||
Announce(F.main("Event Settings", F.value("Hunger Set", "Disabled")));
|
||||
else
|
||||
Announce(F.main("Event Settings", F.value("Hunger Set", HungerSet + "")));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
commandHelpSettings(player);
|
||||
}
|
||||
|
||||
//Teleport Command (To, Here, All)
|
||||
@ -258,17 +525,17 @@ public class EventGame extends SoloGame
|
||||
public void commandGadget(Player player, String[] args)
|
||||
{
|
||||
_gadgetsEnabled = !_gadgetsEnabled;
|
||||
|
||||
|
||||
if (!_gadgetsEnabled)
|
||||
{
|
||||
Manager.getCosmeticManager().getMountManager().DisableAll();
|
||||
Manager.getCosmeticManager().getGadgetManager().DisableAll();
|
||||
}
|
||||
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
other.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(_gadgetsEnabled ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled"));
|
||||
}
|
||||
|
||||
|
||||
//Silence
|
||||
@EventHandler
|
||||
public void commandSilence(Player player, String[] args)
|
||||
@ -359,13 +626,6 @@ public class EventGame extends SoloGame
|
||||
|
||||
}
|
||||
|
||||
//Game Settings - PvP, Blocks, etc
|
||||
@EventHandler
|
||||
public void commandSetting(Player player, String[] args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//Double Jump
|
||||
@EventHandler
|
||||
public void commandDoubleJump(Player player, String[] args)
|
||||
@ -448,6 +708,255 @@ public class EventGame extends SoloGame
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void commandWhitelist(Player player, String[] args)
|
||||
{
|
||||
//On and Off
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("of"))
|
||||
{
|
||||
UtilServer.getServer().setWhitelist(args[1].equalsIgnoreCase("on"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Add and Remove
|
||||
if (args.length >= 3)
|
||||
{
|
||||
if (args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("remove"))
|
||||
{
|
||||
OfflinePlayer target = Bukkit.getOfflinePlayer(args[2]);
|
||||
|
||||
if (args[1].equalsIgnoreCase("add"))
|
||||
UtilServer.getServer().getWhitelistedPlayers().add(target);
|
||||
else
|
||||
UtilServer.getServer().getWhitelistedPlayers().remove(target);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
commandHelp(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
protected void commandMob(Player caller, String[] args)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
HashMap<EntityType, Integer> entMap = new HashMap<EntityType, Integer>();
|
||||
|
||||
int count = 0;
|
||||
for (World world : UtilServer.getServer().getWorlds())
|
||||
{
|
||||
for (Entity ent : world.getEntities())
|
||||
{
|
||||
if (!entMap.containsKey(ent.getType()))
|
||||
entMap.put(ent.getType(), 0);
|
||||
|
||||
entMap.put(ent.getType(), 1 + entMap.get(ent.getType()));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.main("Creature", "Listing Entities:"));
|
||||
for (EntityType cur : entMap.keySet())
|
||||
{
|
||||
UtilPlayer.message(caller, F.desc(UtilEnt.getName(cur), entMap.get(cur)+""));
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.desc("Total", count+""));
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityType type = UtilEnt.searchEntity(caller, args[1], true);
|
||||
|
||||
if (type == null)
|
||||
return;
|
||||
|
||||
UtilPlayer.message(caller, F.main("Creature", "Spawning Creature(s);"));
|
||||
|
||||
//Store Args
|
||||
HashSet<String> argSet = new HashSet<String>();
|
||||
for (int i = 2 ; i < args.length ; i++)
|
||||
if (args[i].length() > 0)
|
||||
argSet.add(args[i]);
|
||||
|
||||
|
||||
//Search Count
|
||||
int count = 1;
|
||||
HashSet<String> argHandle = new HashSet<String>();
|
||||
for (String arg : argSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
int newCount = Integer.parseInt(arg);
|
||||
|
||||
if (newCount <= 0)
|
||||
continue;
|
||||
|
||||
//Set Count
|
||||
count = newCount;
|
||||
UtilPlayer.message(caller, F.desc("Amount", count+""));
|
||||
|
||||
//Flag Arg
|
||||
argHandle.add(arg);
|
||||
break;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//None
|
||||
}
|
||||
}
|
||||
for (String arg : argHandle)
|
||||
argSet.remove(arg);
|
||||
|
||||
//Spawn
|
||||
HashSet<Entity> entSet = new HashSet<Entity>();
|
||||
for (int i = 0 ; i < count ; i++)
|
||||
{
|
||||
CreatureAllowOverride = true;
|
||||
entSet.add(Manager.GetCreature().SpawnEntity(caller.getTargetBlock(null, 0).getLocation().add(0.5, 1, 0.5), type));
|
||||
CreatureAllowOverride = false;
|
||||
}
|
||||
|
||||
//Search Vars
|
||||
for (String arg : argSet)
|
||||
{
|
||||
if (arg.length() == 0)
|
||||
continue;
|
||||
|
||||
//Baby
|
||||
else if (arg.equalsIgnoreCase("baby") || arg.equalsIgnoreCase("b"))
|
||||
{
|
||||
for (Entity ent : entSet)
|
||||
{
|
||||
if (ent instanceof Ageable)
|
||||
((Ageable)ent).setBaby();
|
||||
else if (ent instanceof Zombie)
|
||||
((Zombie)ent).setBaby(true);
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, F.desc("Baby", "True"));
|
||||
argHandle.add(arg);
|
||||
}
|
||||
|
||||
//Lock
|
||||
else if (arg.equalsIgnoreCase("age") || arg.equalsIgnoreCase("lock"))
|
||||
{
|
||||
for (Entity ent : entSet)
|
||||
if (ent instanceof Ageable)
|
||||
{
|
||||
((Ageable)ent).setAgeLock(true);
|
||||
UtilPlayer.message(caller, F.desc("Age", "False"));
|
||||
}
|
||||
|
||||
argHandle.add(arg);
|
||||
}
|
||||
|
||||
//Angry
|
||||
else if (arg.equalsIgnoreCase("angry") || arg.equalsIgnoreCase("a"))
|
||||
{
|
||||
for (Entity ent : entSet)
|
||||
if (ent instanceof Wolf)
|
||||
((Wolf)ent).setAngry(true);
|
||||
|
||||
for (Entity ent : entSet)
|
||||
if (ent instanceof Skeleton)
|
||||
((Skeleton)ent).setSkeletonType(SkeletonType.WITHER);
|
||||
|
||||
UtilPlayer.message(caller, F.desc("Angry", "True"));
|
||||
argHandle.add(arg);
|
||||
}
|
||||
|
||||
//Profession
|
||||
else if (arg.toLowerCase().charAt(0) == 'p')
|
||||
{
|
||||
try
|
||||
{
|
||||
String prof = arg.substring(1, arg.length());
|
||||
|
||||
Profession profession = null;
|
||||
for (Profession cur : Profession.values())
|
||||
if (cur.name().toLowerCase().contains(prof.toLowerCase()))
|
||||
profession = cur;
|
||||
|
||||
UtilPlayer.message(caller, F.desc("Profession", profession.name()));
|
||||
|
||||
for (Entity ent : entSet)
|
||||
if (ent instanceof Villager)
|
||||
((Villager)ent).setProfession(profession);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.desc("Profession", "Invalid [" + arg + "] on " + type.name()));
|
||||
}
|
||||
argHandle.add(arg);
|
||||
}
|
||||
|
||||
//Size
|
||||
else if (arg.toLowerCase().charAt(0) == 's')
|
||||
{
|
||||
try
|
||||
{
|
||||
String size = arg.substring(1, arg.length());
|
||||
|
||||
UtilPlayer.message(caller, F.desc("Size", Integer.parseInt(size)+""));
|
||||
|
||||
for (Entity ent : entSet)
|
||||
if (ent instanceof Slime)
|
||||
((Slime)ent).setSize(Integer.parseInt(size));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.desc("Size", "Invalid [" + arg + "] on " + type.name()));
|
||||
}
|
||||
argHandle.add(arg);
|
||||
}
|
||||
|
||||
else if (arg.toLowerCase().charAt(0) == 'n' && arg.length() > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
String name = "";
|
||||
|
||||
for (char c : arg.substring(1, arg.length()).toCharArray())
|
||||
{
|
||||
if (c != '_')
|
||||
name += c;
|
||||
else
|
||||
name += " ";
|
||||
}
|
||||
|
||||
for (Entity ent : entSet)
|
||||
{
|
||||
if (ent instanceof CraftLivingEntity)
|
||||
{
|
||||
CraftLivingEntity cEnt = (CraftLivingEntity)ent;
|
||||
cEnt.setCustomName(name);
|
||||
cEnt.setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(caller, F.desc("Size", "Invalid [" + arg + "] on " + type.name()));
|
||||
}
|
||||
argHandle.add(arg);
|
||||
}
|
||||
}
|
||||
for (String arg : argHandle)
|
||||
argSet.remove(arg);
|
||||
|
||||
for (String arg : argSet)
|
||||
UtilPlayer.message(caller, F.desc("Unhandled", arg));
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(caller, F.main("Creature", "Spawned " + count + " " + UtilEnt.getName(type) + "."));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void doubleJumpTrigger(PlayerToggleFlightEvent event)
|
||||
{
|
||||
@ -483,7 +992,7 @@ public class EventGame extends SoloGame
|
||||
{
|
||||
if (!_doubleJump)
|
||||
return;
|
||||
|
||||
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
@ -506,20 +1015,20 @@ public class EventGame extends SoloGame
|
||||
if (!_gadgetsEnabled)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void mountActivate(MountActivateEvent event)
|
||||
{
|
||||
if (!_gadgetsEnabled)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void forcefieldUpdate(UpdateEvent event)
|
||||
{
|
||||
if (!InProgress())
|
||||
return;
|
||||
|
||||
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
return;
|
||||
|
||||
@ -547,7 +1056,7 @@ public class EventGame extends SoloGame
|
||||
Entity bottom = other;
|
||||
while (bottom.getVehicle() != null)
|
||||
bottom = bottom.getVehicle();
|
||||
|
||||
|
||||
UtilAction.velocity(bottom, UtilAlg.getTrajectory2d(player, bottom), 1.6, true, 0.8, 0, 10, true);
|
||||
other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f);
|
||||
}
|
||||
@ -555,48 +1064,54 @@ public class EventGame extends SoloGame
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// public void updateVisibility(UpdateEvent event)
|
||||
// {
|
||||
// if (!InProgress())
|
||||
// return;
|
||||
//
|
||||
// if (event.getType() != UpdateType.FAST)
|
||||
// return;
|
||||
//
|
||||
// for (Player player : UtilServer.getPlayers())
|
||||
// {
|
||||
// if (!Manager.getPreferences().Get(player).ShowPlayers)
|
||||
// {
|
||||
// for (Player other : UtilServer.getPlayers())
|
||||
// {
|
||||
// if (player.equals(other))
|
||||
// continue;
|
||||
//
|
||||
// ((CraftPlayer)player).hidePlayer(other, true, false);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// for (Player other : UtilServer.getPlayers())
|
||||
// {
|
||||
// if (player.equals(other))
|
||||
// continue;
|
||||
//
|
||||
// if ((Manager.getPreferences().Get(player).Invisibility && _mps.isAdmin(player, false)) || )
|
||||
// {
|
||||
// ((CraftPlayer)other).hidePlayer(player, true, false);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// other.showPlayer(player);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void explosionBlocks(EntityExplodeEvent event)
|
||||
{
|
||||
event.blockList().clear();
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// public void updateVisibility(UpdateEvent event)
|
||||
// {
|
||||
// if (!InProgress())
|
||||
// return;
|
||||
//
|
||||
// if (event.getType() != UpdateType.FAST)
|
||||
// return;
|
||||
//
|
||||
// for (Player player : UtilServer.getPlayers())
|
||||
// {
|
||||
// if (!Manager.getPreferences().Get(player).ShowPlayers)
|
||||
// {
|
||||
// for (Player other : UtilServer.getPlayers())
|
||||
// {
|
||||
// if (player.equals(other))
|
||||
// continue;
|
||||
//
|
||||
// ((CraftPlayer)player).hidePlayer(other, true, false);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// for (Player other : UtilServer.getPlayers())
|
||||
// {
|
||||
// if (player.equals(other))
|
||||
// continue;
|
||||
//
|
||||
// if ((Manager.getPreferences().Get(player).Invisibility && _mps.isAdmin(player, false)) || )
|
||||
// {
|
||||
// ((CraftPlayer)other).hidePlayer(player, true, false);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// other.showPlayer(player);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void EndCheck()
|
||||
{
|
||||
@ -627,12 +1142,23 @@ public class EventGame extends SoloGame
|
||||
|
||||
Scoreboard.Draw();
|
||||
}
|
||||
|
||||
|
||||
//This re-enables cosmetic hotbar, because MPS disables it
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void fixHotbarItemTemp(PlayerCommandPreprocessEvent event)
|
||||
public void fixHotbarItemTemp(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.getMessage().toLowerCase().startsWith("/sethost"))
|
||||
Manager.GetServerConfig().HotbarInventory = true;
|
||||
Manager.GetServerConfig().HotbarInventory = true;
|
||||
}
|
||||
|
||||
public void giveItems(Player player)
|
||||
{
|
||||
UtilInv.Clear(player);
|
||||
|
||||
for (Material mat : _kitItems.keySet())
|
||||
{
|
||||
int amount = _kitItems.get(mat);
|
||||
|
||||
player.getInventory().addItem(new ItemStack(mat, amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.game.games.event.EventGame;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.kit.KitAvailability;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
@ -32,6 +33,6 @@ public class KitPlayer extends Kit
|
||||
@Override
|
||||
public void GiveItems(Player player)
|
||||
{
|
||||
|
||||
((EventGame)Manager.GetGame()).giveItems(player);
|
||||
}
|
||||
}
|
||||
|
@ -315,8 +315,7 @@ class TeamBomb implements Comparable<TeamBomb>
|
||||
|
||||
public void setupHologram()
|
||||
{
|
||||
_hologram = new Hologram(this._game.getArcadeManager().getHologramManager(), getBlockLocation().clone().add(0, 1, 0))
|
||||
.setUsesWitherSkull();
|
||||
_hologram = new Hologram(this._game.getArcadeManager().getHologramManager(), getBlockLocation().clone().add(0, 1, 0));
|
||||
_hologram.setText(getTeam().GetColor() + C.Bold + getTeam().GetName() + " Team's Bomb");
|
||||
_hologram.start();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,7 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.party.Party;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.Game.GameState;
|
||||
|
||||
@ -68,11 +69,17 @@ public class GameChatManager implements Listener
|
||||
//Rank Prefix & MPS Host Prefix
|
||||
if (Manager.GetGameHostManager().isHost(event.getPlayer()))
|
||||
{
|
||||
rankStr = C.cDGreen + C.Bold + "MPS Host ";
|
||||
if (Manager.GetGame() != null && Manager.GetGame().GetType() == GameType.Event)
|
||||
rankStr = C.cDGreen + C.Bold + "Event Host ";
|
||||
else
|
||||
rankStr = C.cDGreen + C.Bold + "MPS Host ";
|
||||
}
|
||||
else if (Manager.GetGameHostManager().isAdmin(event.getPlayer(), false))
|
||||
{
|
||||
rankStr = C.cDGreen + C.Bold + "MPS Admin ";
|
||||
if (Manager.GetGame() != null && Manager.GetGame().GetType() == GameType.Event)
|
||||
rankStr = C.cDGreen + C.Bold + "Event Admin ";
|
||||
else
|
||||
rankStr = C.cDGreen + C.Bold + "MPS Admin ";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -319,6 +319,10 @@ public class GameFlagManager implements Listener
|
||||
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (game.BlockPlaceCreative && player.getGameMode() == GameMode.CREATIVE) // Event Server Allowance
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (game.BlockPlace)
|
||||
@ -356,6 +360,10 @@ public class GameFlagManager implements Listener
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (game.BlockBreakCreative && player.getGameMode() == GameMode.CREATIVE) // Event Server Allowance
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (game.BlockBreak)
|
||||
|
Loading…
Reference in New Issue
Block a user