Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex into SurvivalGames
Conflicts: Plugins/Mineplex.Core/src/mineplex/core/disguise/DisguiseManager.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/survivalgames/SurvivalGames.java Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/subclasses/HealingRune.java
This commit is contained in:
commit
1f0e204eb3
@ -264,6 +264,9 @@
|
||||
<fileset dir="../Mineplex.BungeeRotator/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.ServerData/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/mysql.zip" />
|
||||
|
||||
@ -272,14 +275,18 @@
|
||||
value="mineplex.bungee.BungeeRotator"/>
|
||||
</manifest>
|
||||
|
||||
<zipfileset src="../Libraries/jooq-3.5.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpcore-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-cache-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpmime-4.2.jar" />
|
||||
<zipfileset src="../Libraries/gson-2.2.1.jar" />
|
||||
<zipfileset src="../Libraries/javax.mail.jar" />
|
||||
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
|
||||
<zipfileset src="../Libraries/commons-dbcp2-2.0.1.jar" />
|
||||
<zipfileset src="../Libraries/jedis-2.4.2.jar" />
|
||||
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
|
||||
<zipfileset src="../Libraries/commons-dbcp2-2.0.1.jar" />
|
||||
</jar>
|
||||
<copy file="../bin/BungeeRotator.jar" todir="../../Testing/BungeeRotator/"/>
|
||||
</target>
|
||||
@ -314,6 +321,33 @@
|
||||
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
|
||||
</jar>
|
||||
<copy file="../bin/ServerMonitor.jar" todir="../../Testing/ServerMonitor/"/>
|
||||
</target>
|
||||
<target name ="ChestConverter" description="ChestConverter">
|
||||
<jar jarfile="../bin/ChestConverter.jar">
|
||||
<fileset dir="../Mineplex.Core.Common/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="../Mineplex.ChestConverter/bin">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
|
||||
<zipfileset src="../Libraries/mysql.zip" />
|
||||
|
||||
<manifest>
|
||||
<attribute name="Main-Class"
|
||||
value="mineplex.chestConverter.ChestConverter"/>
|
||||
</manifest>
|
||||
|
||||
<zipfileset src="../Libraries/httpclient-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpcore-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpclient-cache-4.2.jar" />
|
||||
<zipfileset src="../Libraries/httpmime-4.2.jar" />
|
||||
<zipfileset src="../Libraries/gson-2.2.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
|
||||
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
|
||||
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
|
||||
</jar>
|
||||
<copy file="../bin/ChestConverter.jar" todir="../../Testing/ChestConverter/"/>
|
||||
</target>
|
||||
<target name ="Queuer" description="Queuer">
|
||||
<jar jarfile="../bin/Queuer.jar">
|
||||
|
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/BungeeCord.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-codec-1.6.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-io-2.4.jar"/>
|
||||
|
@ -19,7 +19,7 @@ public class Mineplexer extends Plugin
|
||||
PlayerCount playerCount = new PlayerCount(this);
|
||||
new FileUpdater(this);
|
||||
new PlayerStats(this);
|
||||
new InternetStatus(this);
|
||||
//new InternetStatus(this);
|
||||
new PlayerTracker(this);
|
||||
new AccountManager(this, playerCount);
|
||||
}
|
||||
|
@ -8,10 +8,11 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.serverdata.MinecraftServer;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerManager;
|
||||
import mineplex.serverdata.ServerRepository;
|
||||
import mineplex.serverdata.data.MinecraftServer;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ServerRepository;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
@ -37,7 +38,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
|
||||
|
@ -2,7 +2,7 @@ package mineplex.bungee.lobbyBalancer;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import mineplex.serverdata.MinecraftServer;
|
||||
import mineplex.serverdata.data.MinecraftServer;
|
||||
|
||||
public class LobbySorter implements Comparator<MinecraftServer>
|
||||
{
|
||||
|
@ -0,0 +1,40 @@
|
||||
package mineplex.bungee.motd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.serverdata.data.Data;
|
||||
|
||||
/**
|
||||
* A GlobalMotd represents a set of MOTD packaged lines.
|
||||
* @author MrTwiggy
|
||||
*
|
||||
*/
|
||||
public class GlobalMotd implements Data
|
||||
{
|
||||
|
||||
// The unique name representing this MOTD set
|
||||
private String _name;
|
||||
|
||||
// List of lines describing the MOTD
|
||||
private List<String> _motd;
|
||||
public List<String> getMotd() { return _motd; }
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param name
|
||||
* @param motd
|
||||
*/
|
||||
public GlobalMotd(String name, List<String> motd)
|
||||
{
|
||||
_name = name;
|
||||
_motd = motd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifying ID associated with this {@link GlobalMotd}.
|
||||
*/
|
||||
public String getDataId()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
}
|
@ -106,7 +106,7 @@ public class Motd implements CustomMotd
|
||||
List<String> lines = _manager.getMotdLines();
|
||||
if (lines != null && lines.size() > 0)
|
||||
{
|
||||
int index = _ticks / (MAX_TICKS / (lines.size()-1));
|
||||
int index = _ticks / (MAX_TICKS / (lines.size()));
|
||||
String currentLine = index >= lines.size() ? lines.get(lines.size() - 1) : lines.get(index);
|
||||
desc += "\n" + currentLine;
|
||||
}
|
||||
|
@ -1,8 +1,14 @@
|
||||
package mineplex.bungee.motd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.BungeeServer;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
@ -14,7 +20,8 @@ import net.md_5.bungee.event.EventHandler;
|
||||
public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private MotdRepository _repository;
|
||||
|
||||
private DataRepository<GlobalMotd> _repository;
|
||||
|
||||
private String firstLine = " §b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r";
|
||||
private List<String> _motdLines;
|
||||
@ -26,8 +33,8 @@ public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 5L, 30L, TimeUnit.SECONDS);
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
|
||||
_repository = new MotdRepository();
|
||||
_repository.initialize();
|
||||
_repository = new RedisDataRepository<GlobalMotd>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
Region.ALL, GlobalMotd.class, "globalMotd");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -37,7 +44,9 @@ public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
|
||||
String motd = firstLine;
|
||||
if (_motdLines != null && _motdLines.size() > 0)
|
||||
{
|
||||
motd += "\n" + _motdLines.get(0);
|
||||
}
|
||||
|
||||
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), motd, serverPing.getFaviconObject()));
|
||||
}
|
||||
@ -45,16 +54,25 @@ public class MotdManager implements Listener, Runnable, CustomMotdFactory
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_motdLines = _repository.retrieveMotd();
|
||||
|
||||
if (_repository.retrieveMotdAnimated())
|
||||
// Add in default MOTD listing to database
|
||||
if (!_repository.elementExists("MainMotd") || true)
|
||||
{
|
||||
List<String> lines = new ArrayList<String>();
|
||||
lines.add(" §b§lUltra Sale §a§l50% Off"); // TODO: Implement in-game command to update MOTD?
|
||||
updateMainMotd(lines);
|
||||
}
|
||||
|
||||
_motdLines = _repository.getElement("MainMotd").getMotd(); // Update MOTD lines
|
||||
InitialHandler.setCustomMotdFactory(this);
|
||||
}
|
||||
else
|
||||
|
||||
/**
|
||||
* Update the main {@link GlobalMotd} determining the MOTD for Bungee instances.
|
||||
* @param motdLines - the lines to update the MOTD to.
|
||||
*/
|
||||
public void updateMainMotd(List<String> motdLines)
|
||||
{
|
||||
InitialHandler.setCustomMotdFactory(null);
|
||||
}
|
||||
_repository.addElement(new GlobalMotd("MainMotd", motdLines));
|
||||
}
|
||||
|
||||
public List<String> getMotdLines()
|
||||
|
@ -1,171 +0,0 @@
|
||||
package mineplex.bungee.motd;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class MotdRepository
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS BungeeMotd (id INT NOT NULL AUTO_INCREMENT, motd VARCHAR(256), PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_MOTD = "SELECT motd FROM BungeeMotd;";
|
||||
private static String RETRIEVE_ANIMATED = "SELECT value FROM bungeeSettings WHERE id='animatedMotd'";
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Initialized MOTD.");
|
||||
}
|
||||
|
||||
public List<String> retrieveMotd()
|
||||
{
|
||||
// String motd = "§b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r §c§l§m§kZ§6§l§m§kZ§e§l§m§kZ§a§l§m§kZ§b§l§m§kZ§r §f§lPLAY NOW§r §b§l§m§kZ§a§l§m§kZ§e§l§m§kZ§6§l§m§kZ§c§l§m§kZ";
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
// lines.add(" " + ChatColor.WHITE + ChatColor.BOLD + "New Game" + ChatColor.RED + ChatColor.BOLD + " Christmas Chaos");
|
||||
// lines.add(" " + ChatColor.WHITE + ChatColor.BOLD + "Winter Sale" + ChatColor.BLUE + ChatColor.BOLD + " 33% Off Everything");
|
||||
// lines.add(" " + ChatColor.WHITE + ChatColor.BOLD + "New Game" + ChatColor.RED + ChatColor.BOLD + " Christmas Chaos");
|
||||
// return lines;
|
||||
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_MOTD);
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
lines.add(resultSet.getString(1));
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
public boolean retrieveMotdAnimated()
|
||||
{
|
||||
boolean enabled = false;
|
||||
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_ANIMATED);
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
enabled = resultSet.getBoolean(1);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return enabled;
|
||||
}
|
||||
}
|
@ -1,7 +1,16 @@
|
||||
package mineplex.bungee.playerCount;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.bungee.status.InternetStatus;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.BungeeServer;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ServerRepository;
|
||||
import net.md_5.bungee.api.ServerPing.Players;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
@ -11,31 +20,64 @@ import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class PlayerCount implements Listener, Runnable
|
||||
{
|
||||
private DataRepository<BungeeServer> _repository;
|
||||
private UUID _uuid;
|
||||
private Region _region;
|
||||
|
||||
private ListenerInfo _listenerInfo;
|
||||
private Plugin _plugin;
|
||||
private PlayerCountRepository _repository;
|
||||
|
||||
private int _totalPlayers = -1;
|
||||
|
||||
public PlayerCount(Plugin plugin)
|
||||
{
|
||||
_uuid = UUID.randomUUID();
|
||||
_region = !new File("eu.dat").exists() ? Region.US : Region.EU;
|
||||
_plugin = plugin;
|
||||
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.SECONDS);
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 500L, 500L, TimeUnit.MILLISECONDS);
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
|
||||
ListenerInfo listenerInfo = _plugin.getProxy().getConfigurationAdapter().getListeners().iterator().next();
|
||||
_listenerInfo = _plugin.getProxy().getConfigurationAdapter().getListeners().iterator().next();
|
||||
|
||||
_repository = new PlayerCountRepository(listenerInfo.getHost().getAddress().getHostAddress() + ":" + listenerInfo.getHost().getPort(), listenerInfo.getMaxPlayers());
|
||||
_repository.initialize();
|
||||
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
_repository.updatePlayerCountInDatabase(_plugin.getProxy().getOnlineCount());
|
||||
|
||||
PlayerTotalData playerTotalData = _repository.retrievePlayerCount();
|
||||
BungeeServer snapshot = generateSnapshot();
|
||||
_repository.addElement(snapshot, 15); // Update with a 15 second expiry on session
|
||||
|
||||
_totalPlayers = playerTotalData.CurrentPlayers;
|
||||
_totalPlayers = fetchPlayerCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an up-to-date total player count across all active Bungee Servers.
|
||||
*/
|
||||
private int fetchPlayerCount()
|
||||
{
|
||||
int totalPlayers = 0;
|
||||
for (BungeeServer server : _repository.getElements())
|
||||
{
|
||||
totalPlayers += server.getPlayerCount();
|
||||
}
|
||||
|
||||
return totalPlayers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a newly instantiated {@link BungeeServer} snapshot of the current state of this server.
|
||||
*/
|
||||
private BungeeServer generateSnapshot()
|
||||
{
|
||||
String name = _uuid.toString(); // Use random UUID for unique id name.
|
||||
String host = _listenerInfo.getHost().getAddress().getHostAddress();
|
||||
int port = _listenerInfo.getHost().getPort();
|
||||
boolean connected = InternetStatus.isConnected();
|
||||
int playerCount = _plugin.getProxy().getOnlineCount();
|
||||
return new BungeeServer(name, _region, host, port, playerCount, connected);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -1,257 +0,0 @@
|
||||
package mineplex.bungee.playerCount;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class PlayerCountRepository
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS BungeeServers (id INT NOT NULL AUTO_INCREMENT, address VARCHAR(256), updated LONG, players INT, maxPlayers INT, ram INT, maxRam INT, PRIMARY KEY (id));";
|
||||
private static String INSERT_PLAYER_COUNT = "INSERT INTO BungeeServers(address, updated, players, maxPlayers, ram, maxRam) values(?, now(), ?, ?, ?, ?);";
|
||||
private static String UPDATE_PLAYER_COUNT = "UPDATE BungeeServers SET updated = now(), players = ?, maxPlayers = ?, ram = ?, maxRam = ? WHERE id = ?;";
|
||||
private static String RETRIEVE_ID = "SELECT id FROM BungeeServers WHERE address = ?;";
|
||||
private static String RETRIEVE_PLAYER_COUNT = "SELECT SUM(players) AS playerCount, SUM(maxPlayers) AS maxPlayerCount FROM BungeeServers WHERE TIME_TO_SEC(TIMEDIFF(now(), BungeeServers.updated)) < 10;";
|
||||
|
||||
private int _id = -1;
|
||||
private String _address;
|
||||
private int _maxPlayers = 0;
|
||||
|
||||
public PlayerCountRepository(String address, int maxPlayers)
|
||||
{
|
||||
_address = address;
|
||||
_maxPlayers = maxPlayers;
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
PreparedStatement preparedStatementRetrieve = null;
|
||||
PreparedStatement preparedStatementInsert = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_TABLE);
|
||||
preparedStatement.execute();
|
||||
|
||||
|
||||
// Retrieve id
|
||||
preparedStatementRetrieve = _connection.prepareStatement(RETRIEVE_ID);
|
||||
preparedStatementRetrieve.setString(1, _address);
|
||||
resultSet = preparedStatementRetrieve.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
_id = resultSet.getInt("id");
|
||||
}
|
||||
|
||||
// Insert if not there
|
||||
if (_id == -1)
|
||||
{
|
||||
preparedStatementInsert = _connection.prepareStatement(INSERT_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
preparedStatementInsert.setString(1, _address);
|
||||
preparedStatementInsert.setInt(2, 0);
|
||||
preparedStatementInsert.setInt(3, _maxPlayers);
|
||||
preparedStatementInsert.setInt(4, (int) ((Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()) / 1048576));
|
||||
preparedStatementInsert.setInt(5, (int) (Runtime.getRuntime().maxMemory() / 1048576));
|
||||
|
||||
int affectedRows = preparedStatementInsert.executeUpdate();
|
||||
|
||||
if (affectedRows == 0)
|
||||
{
|
||||
throw new SQLException("Creating bungee server failed, no rows affected.");
|
||||
}
|
||||
|
||||
resultSet.close();
|
||||
resultSet = preparedStatementInsert.getGeneratedKeys();
|
||||
|
||||
if (resultSet.next())
|
||||
{
|
||||
_id = resultSet.getInt(1);
|
||||
System.out.println("id = " + _id);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (preparedStatementRetrieve != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatementRetrieve.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (preparedStatementInsert != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatementInsert.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Initialized PlayerCount.");
|
||||
}
|
||||
|
||||
public boolean updatePlayerCountInDatabase(int players)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(UPDATE_PLAYER_COUNT, Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
preparedStatement.setInt(1, players);
|
||||
preparedStatement.setInt(2, _maxPlayers);
|
||||
preparedStatement.setInt(3, (int) ((Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()) / 1048576));
|
||||
preparedStatement.setInt(4, (int) (Runtime.getRuntime().maxMemory() / 1048576));
|
||||
preparedStatement.setInt(5, _id);
|
||||
|
||||
int affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
if (affectedRows == 0)
|
||||
{
|
||||
throw new SQLException("Updating bungee server player count failed, no rows affected.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(10);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return updatePlayerCountInDatabase(players);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerTotalData retrievePlayerCount()
|
||||
{
|
||||
PlayerTotalData playerData = new PlayerTotalData();
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_PLAYER_COUNT);
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
playerData.CurrentPlayers = resultSet.getInt(1);
|
||||
playerData.MaxPlayers = resultSet.getInt(2);
|
||||
return playerData;
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return playerData;
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package mineplex.bungee.playerCount;
|
||||
|
||||
public class PlayerTotalData
|
||||
{
|
||||
public int CurrentPlayers;
|
||||
public int MaxPlayers;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package mineplex.bungee.playerStats;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
@ -7,9 +9,13 @@ import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class PlayerStats implements Listener
|
||||
{
|
||||
private static Object _cacheLock = new Object();
|
||||
|
||||
private Plugin _plugin;
|
||||
private PlayerStatsRepository _repository;
|
||||
|
||||
private HashMap<String, Integer> _ipCache = new HashMap<String, Integer>();
|
||||
|
||||
public PlayerStats(Plugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
@ -28,6 +34,28 @@ public class PlayerStats implements Listener
|
||||
public void run()
|
||||
{
|
||||
_repository.addPlayer(event.getPlayer().getName());
|
||||
_repository.addPlayerVersion(event.getPlayer().getName(), event.getPlayer().getPendingConnection().getVersion());
|
||||
|
||||
String address = event.getPlayer().getPendingConnection().getAddress().getAddress().getHostAddress();
|
||||
/*
|
||||
boolean addNewIp = false;
|
||||
int addressId = 0;
|
||||
|
||||
synchronized (_cacheLock)
|
||||
{
|
||||
if (_ipCache.containsKey(address))
|
||||
addressId = _ipCache.get(address);
|
||||
else
|
||||
addNewIp = true;
|
||||
}
|
||||
|
||||
if (addNewIp)
|
||||
addressId = _repository.addNewIP(address);
|
||||
|
||||
_repository.addPlayerIP(event.getPlayer().getName(), addressId);
|
||||
*/
|
||||
|
||||
_repository.addPlayerIP(event.getPlayer().getName(), address);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -16,8 +16,14 @@ 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(?, ?);";
|
||||
//private static String INSERT_IP_PLAYER = "INSERT IGNORE INTO playerIp (playerName, ip) values(?, ?);";
|
||||
//private static String INSERT_IP_PLAYER = "INSERT IGNORE INTO playerIp (playerName, ip) values(?, ?);";
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
@ -36,6 +42,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 +114,7 @@ public class PlayerStatsRepository
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addPlayerVersion(String playerName, String version)
|
||||
public void addPlayerVersion(String playerName, int version)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
@ -112,34 +123,27 @@ 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.");
|
||||
}
|
||||
preparedStatement.close();
|
||||
preparedStatement = _connection.prepareStatement(INSERT_VER_PLAYER, Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
return true;
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setInt(2, version);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(10);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return addPlayer(playerName);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -156,4 +160,77 @@ public class PlayerStatsRepository
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setString(2, address);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int addNewIP(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);
|
||||
|
||||
preparedStatement.setString(1, address);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,11 @@ package mineplex.bungee.playerTracker;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.data.PlayerStatus;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
@ -10,8 +15,13 @@ import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class PlayerTracker implements Listener
|
||||
{
|
||||
// Default period before status expiry (8 hours)
|
||||
private static final int DEFAULT_STATUS_TIMEOUT = 60 * 60 * 8;
|
||||
|
||||
// Repository storing player status' across network.
|
||||
private DataRepository<PlayerStatus> _repository;
|
||||
|
||||
private Plugin _plugin;
|
||||
private PlayerTrackerRepository _repository = null;
|
||||
|
||||
public PlayerTracker(Plugin plugin)
|
||||
{
|
||||
@ -19,8 +29,9 @@ public class PlayerTracker implements Listener
|
||||
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
|
||||
_repository = new PlayerTrackerRepository();
|
||||
_repository.initialize(!new File("eu.dat").exists());
|
||||
Region region = !new File("eu.dat").exists() ? Region.US : Region.EU;
|
||||
_repository = new RedisDataRepository<PlayerStatus>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
region, PlayerStatus.class, "playerStatus");
|
||||
|
||||
System.out.println("Initialized PlayerTracker.");
|
||||
}
|
||||
@ -32,7 +43,8 @@ public class PlayerTracker implements Listener
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.updatePlayerServer(event.getPlayer().getName(), event.getServer().getInfo().getName());
|
||||
PlayerStatus snapshot = new PlayerStatus(event.getPlayer().getName(), event.getServer().getInfo().getName());
|
||||
_repository.addElement(snapshot, DEFAULT_STATUS_TIMEOUT);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -44,7 +56,7 @@ public class PlayerTracker implements Listener
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.deleteServerTransfers(event.getPlayer().getName());
|
||||
_repository.removeElement(event.getPlayer().getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,203 +0,0 @@
|
||||
package mineplex.bungee.playerTracker;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class PlayerTrackerRepository
|
||||
{
|
||||
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 us = ?;";
|
||||
|
||||
private Connection _connection = null;
|
||||
|
||||
public void initialize(boolean us)
|
||||
{
|
||||
_us = us;
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_PLAYERMAP_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String retrievePlayerServer(String playerName)
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
String server = "N/A";
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_PLAYERMAP);
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setBoolean(2, _us);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
server = resultSet.getString(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
public void deleteServerTransfers(String playerName)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(DELETE_PLAYERMAP);
|
||||
preparedStatement.setString(1, playerName);
|
||||
preparedStatement.setBoolean(2, _us);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePlayerServer(String playerName, String serverName)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
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.setBoolean(3, _us);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,20 +10,15 @@ import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
public class InternetStatus implements Runnable
|
||||
{
|
||||
// Current internet connectivity status
|
||||
private static boolean _connected = true;
|
||||
public static boolean isConnected() { return _connected; }
|
||||
|
||||
private Plugin _plugin;
|
||||
private StatusRepository _repository;
|
||||
|
||||
public InternetStatus(Plugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
|
||||
ListenerInfo listenerInfo = _plugin.getProxy().getConfigurationAdapter().getListeners().iterator().next();
|
||||
boolean us = !new File("eu.dat").exists();
|
||||
String address = listenerInfo.getHost().getAddress().getHostAddress() + ":" + listenerInfo.getHost().getPort();
|
||||
|
||||
_repository = new StatusRepository(address, us);
|
||||
_repository.initialize();
|
||||
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 1L, 1L, TimeUnit.MINUTES);
|
||||
|
||||
System.out.println("Initialized InternetStatus.");
|
||||
@ -32,48 +27,28 @@ public class InternetStatus implements Runnable
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_repository.updateOnlineStatus(isOnline());
|
||||
_connected = isOnline(); // Update _connected flag.
|
||||
}
|
||||
|
||||
private boolean isOnline()
|
||||
{
|
||||
if (testUrl("www.google.com"))
|
||||
return true;
|
||||
else if (testUrl("www.espn.com"))
|
||||
return true;
|
||||
else if (testUrl("www.bing.com"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return testUrl("www.google.com")
|
||||
|| testUrl("www.espn.com")
|
||||
|| testUrl("www.bing.com");
|
||||
}
|
||||
|
||||
private boolean testUrl(String url)
|
||||
{
|
||||
Socket socket = null;
|
||||
boolean reachable = false;
|
||||
|
||||
try
|
||||
try (Socket socket = new Socket(url, 80))
|
||||
{
|
||||
socket = new Socket(url, 80);
|
||||
reachable = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Meh i don't care
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (socket != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
socket.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return reachable;
|
||||
}
|
||||
|
@ -1,120 +0,0 @@
|
||||
package mineplex.bungee.status;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class StatusRepository
|
||||
{
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private String _address;
|
||||
private boolean _us;
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS bungeeOnlineStatus (id INT NOT NULL AUTO_INCREMENT, address VARCHAR(40), online BOOLEAN NOT NULL DEFAULT 0, updated LONG, us BOOLEAN NOT NULL DEFAULT 1, lastOnline LONG, PRIMARY KEY (id), UNIQUE INDEX addressIndex(address));";
|
||||
private static String INSERT_SERVER = "INSERT INTO bungeeOnlineStatus (address, online, us, updated) values(?, ?, ?, now()) ON DUPLICATE KEY UPDATE online = VALUES(online), updated = VALUES(updated);";
|
||||
private static String INSERT_ONLINE_SERVER = "INSERT INTO bungeeOnlineStatus (address, online, us, updated, lastOnline) values(?, ?, ?, now(), now()) ON DUPLICATE KEY UPDATE online = VALUES(online), updated = VALUES(updated), lastOnline = VALUES(lastOnline);";
|
||||
|
||||
public StatusRepository(String address, boolean us)
|
||||
{
|
||||
_address = address;
|
||||
_us = us;
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = connection.prepareStatement(CREATE_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateOnlineStatus(boolean online)
|
||||
{
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = connection.prepareStatement(online ? INSERT_ONLINE_SERVER : INSERT_SERVER);
|
||||
|
||||
preparedStatement.setString(1, _address);
|
||||
preparedStatement.setBoolean(2, online);
|
||||
preparedStatement.setBoolean(3, _us);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpclient-4.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/httpcore-4.2.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/commons-codec-1.6.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/gson-2.2.1.jar"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/javax.mail.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.ServerData"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -1,142 +0,0 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BungeeRepository
|
||||
{
|
||||
// Yip Yip actual IP because if null route happens we can't resolve the HOSTNAME DERP FACE DEFEK7!!! -defek7
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/BungeeServers?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_ONLINE_TABLE = "CREATE TABLE IF NOT EXISTS bungeeOnlineStatus (id INT NOT NULL AUTO_INCREMENT, address VARCHAR(40), online BOOLEAN NOT NULL DEFAULT 0, updated LONG, us BOOLEAN NOT NULL DEFAULT 1, lastOnline LONG, PRIMARY KEY (id), UNIQUE INDEX addressIndex(address));";
|
||||
private static String CREATE_PLAYER_TABLE = "CREATE TABLE IF NOT EXISTS BungeeServers (id INT NOT NULL AUTO_INCREMENT, address VARCHAR(256), updated LONG, players INT, maxPlayers INT, ram INT, maxRam INT, PRIMARY KEY (id));";
|
||||
|
||||
private static String RETRIEVE_SERVERS_PLAYERCOUNTS = "SELECT bos.address, players, maxPlayers, BungeeServers.updated, bos.lastOnline, BungeeServers.US, now() FROM BungeeServers INNER JOIN bungeeOnlineStatus AS bos ON bos.address = BungeeServers.address WHERE TIME_TO_SEC(TIMEDIFF(now(), BungeeServers.updated)) < 15;";
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = connection.prepareStatement(CREATE_ONLINE_TABLE);
|
||||
preparedStatement.execute();
|
||||
|
||||
preparedStatement.close();
|
||||
|
||||
preparedStatement = connection.prepareStatement(CREATE_PLAYER_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<BungeeServer> getBungeeServers()
|
||||
{
|
||||
List<BungeeServer> bungeeServers = new ArrayList<BungeeServer>();
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = connection.prepareStatement(RETRIEVE_SERVERS_PLAYERCOUNTS);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
long current = dateFormat.parse(resultSet.getString(7)).getTime();
|
||||
long updated = dateFormat.parse(resultSet.getString(4)).getTime();
|
||||
long lastOnline = dateFormat.parse(resultSet.getString(5)).getTime();
|
||||
|
||||
if (current - updated <= 15000 && current - lastOnline <= 300000)
|
||||
{
|
||||
BungeeServer server = new BungeeServer();
|
||||
server.Address = resultSet.getString(1).split(":")[0];
|
||||
server.Players = resultSet.getInt(2);
|
||||
server.MaxPlayers = resultSet.getInt(3);
|
||||
server.US = resultSet.getBoolean(6);
|
||||
|
||||
bungeeServers.add(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bungeeServers;
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
@ -15,19 +17,34 @@ import java.util.logging.Logger;
|
||||
import mineplex.bungee.api.ApiDeleteCall;
|
||||
import mineplex.bungee.api.ApiGetCall;
|
||||
import mineplex.bungee.api.ApiPostCall;
|
||||
import mineplex.bungee.api.HttpCallBase;
|
||||
import mineplex.bungee.api.token.ARecord;
|
||||
import mineplex.bungee.api.token.DnsRecord;
|
||||
import mineplex.bungee.api.token.DomainRecords;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.BungeeServer;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ServerRepository;
|
||||
|
||||
public class BungeeRotator
|
||||
{
|
||||
private static BungeeRepository _repository = null;
|
||||
private static DataRepository<BungeeServer> _repository;
|
||||
//private static ServerRepository _repository = null;
|
||||
|
||||
private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
|
||||
private static Logger _logger = Logger.getLogger("BungeeRotator");
|
||||
private static boolean _debug = false;
|
||||
|
||||
public static void main(String args[])
|
||||
{
|
||||
/*
|
||||
IPGeoData recor = new HttpCallBase("http://www.freegeoip.net/json/124.149.22.183").Execute(IPGeoData.class);
|
||||
|
||||
System.out.println(recor.country_name + " " + recor.region_name);
|
||||
*/
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
@ -56,7 +73,11 @@ public class BungeeRotator
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
_repository = new BungeeRepository();
|
||||
_debug = new File("debug.dat").exists();
|
||||
|
||||
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||
|
||||
BungeeSorter bungeeSorter = new BungeeSorter();
|
||||
int maxRecordCount = 10;
|
||||
|
||||
@ -64,29 +85,55 @@ public class BungeeRotator
|
||||
{
|
||||
try
|
||||
{
|
||||
List<BungeeServer> bungeeServers = _repository.getBungeeServers();
|
||||
HashSet<String> usServers = new HashSet<String>();
|
||||
HashSet<String> euServers = new HashSet<String>();
|
||||
|
||||
List<BungeeServer> bungeeServers = new ArrayList<BungeeServer>(_repository.getElements());
|
||||
Collections.sort(bungeeServers, bungeeSorter);
|
||||
|
||||
if (_debug)
|
||||
{
|
||||
int totalPlayers = 0;
|
||||
int usPlayers = 0;
|
||||
int euPlayers = 0;
|
||||
|
||||
for (BungeeServer server : bungeeServers)
|
||||
{
|
||||
if (usServers.size() < maxRecordCount && server.US)
|
||||
{
|
||||
if (usServers.size() >= 2 && server.Players > 900)
|
||||
continue;
|
||||
totalPlayers += server.getPlayerCount();
|
||||
|
||||
log("SELECTED " + server.Address + " " + (server.US ? "us" : "eu") + " " + server.Players + "/" + server.MaxPlayers);
|
||||
usServers.add(server.Address);
|
||||
if (server.getRegion() == Region.US)
|
||||
usPlayers += server.getPlayerCount();
|
||||
else
|
||||
euPlayers += server.getPlayerCount();
|
||||
|
||||
System.out.println(server.getRegion().toString() + " " + server.getPublicAddress() + " " + server.getPlayerCount() + "/" + server.getPlayerCount());
|
||||
}
|
||||
else if (euServers.size() < maxRecordCount && !server.US)
|
||||
|
||||
System.out.println("US Players : " + usPlayers);
|
||||
System.out.println("EU Players : " + euPlayers);
|
||||
System.out.println("Total Players : " + totalPlayers);
|
||||
System.out.println("Count : " + bungeeServers.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (euServers.size() >= 2 && server.Players > 900)
|
||||
HashSet<String> usServers = new HashSet<String>();
|
||||
HashSet<String> euServers = new HashSet<String>();
|
||||
|
||||
|
||||
for (BungeeServer server : bungeeServers)
|
||||
{
|
||||
if (usServers.size() < maxRecordCount && server.getRegion() == Region.US)
|
||||
{
|
||||
if (usServers.size() >= 2 && server.getPlayerCount() > 900)
|
||||
continue;
|
||||
|
||||
log("SELECTED " + server.Address + " " + (server.US ? "us" : "eu") + " " + server.Players + "/" + server.MaxPlayers);
|
||||
euServers.add(server.Address);
|
||||
log("SELECTED " + server.getPublicAddress() + " " + (server.getRegion() == Region.US ? "us" : "eu") + " " + server.getPlayerCount() + "/" + server.getPlayerCount());
|
||||
usServers.add(server.getPublicAddress());
|
||||
}
|
||||
else if (euServers.size() < maxRecordCount && server.getRegion() != Region.US)
|
||||
{
|
||||
if (euServers.size() >= 2 && server.getPlayerCount() > 900)
|
||||
continue;
|
||||
|
||||
log("SELECTED " + server.getPublicAddress() + " " + (server.getRegion() == Region.US ? "us" : "eu") + " " + server.getPlayerCount() + "/" + server.getPlayerCount());
|
||||
euServers.add(server.getPublicAddress());
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,13 +166,7 @@ public class BungeeRotator
|
||||
for (String address : usServers)
|
||||
{
|
||||
recordsToAdd.add(new ARecord("us", address, 300));
|
||||
log("Addding 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);
|
||||
log("Adding server address in DNS : " + "us " + address);
|
||||
}
|
||||
|
||||
if (recordsToAdd.size() > 0)
|
||||
@ -134,6 +175,22 @@ public class BungeeRotator
|
||||
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();
|
||||
@ -149,6 +206,7 @@ public class BungeeRotator
|
||||
new ApiDeleteCall("https://api.dnsmadeeasy.com/V2.0/dns/managed/", 962728, "/records?" + idBuilder.toString()).Execute();
|
||||
log("Deleted " + recordsToDelete.size() + " records.");
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -1,9 +0,0 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
public class BungeeServer
|
||||
{
|
||||
public String Address;
|
||||
public int Players;
|
||||
public int MaxPlayers;
|
||||
public boolean US;
|
||||
}
|
@ -2,14 +2,16 @@ package mineplex.bungee;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import mineplex.serverdata.data.BungeeServer;
|
||||
|
||||
public class BungeeSorter implements Comparator<BungeeServer>
|
||||
{
|
||||
public int compare(BungeeServer a, BungeeServer b)
|
||||
{
|
||||
if (a.Players < b.Players)
|
||||
if (a.getPlayerCount() < b.getPlayerCount())
|
||||
return -1;
|
||||
|
||||
if (b.Players < a.Players)
|
||||
if (b.getPlayerCount() < a.getPlayerCount())
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -0,0 +1,16 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
public class IPGeoData
|
||||
{
|
||||
public String ip;
|
||||
public String country_code;
|
||||
public String country_name;
|
||||
public String region_code;
|
||||
public String region_name;
|
||||
public String city;
|
||||
public int zip_code;
|
||||
public String time_zone;
|
||||
public double latitude;
|
||||
public double longitude;
|
||||
public int metro_code;
|
||||
}
|
@ -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");
|
||||
|
@ -0,0 +1,122 @@
|
||||
package mineplex.bungee.api;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.conn.scheme.PlainSocketFactory;
|
||||
import org.apache.http.conn.scheme.Scheme;
|
||||
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.conn.PoolingClientConnectionManager;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class HttpCallBase
|
||||
{
|
||||
private String _url;
|
||||
|
||||
public HttpCallBase(String url)
|
||||
{
|
||||
_url = url;
|
||||
}
|
||||
|
||||
public <T> T Execute(Type returnType)
|
||||
{
|
||||
HttpGet request = new HttpGet(_url);
|
||||
|
||||
String response = execute(request);
|
||||
System.out.println(response);
|
||||
return new Gson().fromJson(response, returnType);
|
||||
}
|
||||
|
||||
protected String execute(HttpRequestBase request)
|
||||
{
|
||||
SchemeRegistry schemeRegistry = new SchemeRegistry();
|
||||
schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
|
||||
|
||||
PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager(schemeRegistry);
|
||||
connectionManager.setMaxTotal(200);
|
||||
connectionManager.setDefaultMaxPerRoute(20);
|
||||
|
||||
HttpClient httpClient = new DefaultHttpClient(connectionManager);
|
||||
InputStream in = null;
|
||||
String response = "";
|
||||
|
||||
try
|
||||
{
|
||||
request.addHeader("Content-Type", "application/json");
|
||||
HttpResponse httpResponse = httpClient.execute(request);
|
||||
|
||||
if (httpResponse != null)
|
||||
{
|
||||
in = httpResponse.getEntity().getContent();
|
||||
response = convertStreamToString(in);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.println("HttpCall Error:\n" + ex.getMessage());
|
||||
|
||||
for (StackTraceElement trace : ex.getStackTrace())
|
||||
{
|
||||
System.out.println(trace);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
httpClient.getConnectionManager().shutdown();
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
protected String convertStreamToString(InputStream is)
|
||||
{
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line = null;
|
||||
try
|
||||
{
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ public enum Rank
|
||||
MAPDEV("Mapper", ChatColor.BLUE),
|
||||
MAPLEAD("MapKing", ChatColor.DARK_PURPLE),
|
||||
|
||||
EVENT("Event", ChatColor.WHITE),
|
||||
|
||||
//Staff ^^
|
||||
|
||||
YOUTUBE("YouTube", ChatColor.RED),
|
||||
|
@ -135,6 +135,13 @@ public class F
|
||||
else return indent + C.listTitle + variable + ": " + C.listValueOff + value;
|
||||
}
|
||||
|
||||
public static String ed(boolean var)
|
||||
{
|
||||
if (var)
|
||||
return C.listValueOn + "Enabled" + C.mBody;
|
||||
return C.listValueOff + "Disabled" + C.mBody;
|
||||
}
|
||||
|
||||
public static String oo(boolean var)
|
||||
{
|
||||
if (var)
|
||||
|
@ -379,7 +379,7 @@ public class UtilEnt
|
||||
|
||||
for (Entity cur : loc.getWorld().getEntities())
|
||||
{
|
||||
if (!(cur instanceof LivingEntity) || (cur instanceof Player && ((Player)cur).getGameMode() == GameMode.CREATIVE))
|
||||
if (!(cur instanceof LivingEntity) || UtilPlayer.isSpectator(cur))
|
||||
continue;
|
||||
|
||||
LivingEntity ent = (LivingEntity)cur;
|
||||
|
@ -0,0 +1,130 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class UtilItem
|
||||
{
|
||||
public static LinkedList<Entry<Material, Byte>> matchItem(Player caller, String items, boolean inform)
|
||||
{
|
||||
LinkedList<Entry<Material, Byte>> matchList = new LinkedList<Entry<Material, Byte>>();
|
||||
|
||||
String failList = "";
|
||||
|
||||
//Mass Search
|
||||
for (String cur : items.split(","))
|
||||
{
|
||||
Entry<Material, Byte> match = searchItem(caller, cur, inform);
|
||||
|
||||
if (match != null)
|
||||
matchList.add(match);
|
||||
|
||||
else
|
||||
failList += cur + " " ;
|
||||
}
|
||||
|
||||
if (inform && failList.length() > 0)
|
||||
{
|
||||
failList = failList.substring(0, failList.length() - 1);
|
||||
UtilPlayer.message(caller, F.main("Item(s) Search", "" +
|
||||
C.mBody + " Invalid [" +
|
||||
C.mElem + failList +
|
||||
C.mBody + "]."));
|
||||
}
|
||||
|
||||
return matchList;
|
||||
}
|
||||
|
||||
public static Entry<Material, Byte> searchItem(Player caller, String args, boolean inform)
|
||||
{
|
||||
LinkedList<Entry<Material, Byte>> matchList = new LinkedList<Entry<Material, Byte>>();
|
||||
|
||||
for (Material cur : Material.values())
|
||||
{
|
||||
//By Name
|
||||
if (cur.toString().equalsIgnoreCase(args))
|
||||
return new AbstractMap.SimpleEntry<Material, Byte>(cur, (byte)0);
|
||||
|
||||
if (cur.toString().toLowerCase().contains(args.toLowerCase()))
|
||||
matchList.add(new AbstractMap.SimpleEntry<Material, Byte>(cur, (byte)0));
|
||||
|
||||
//By ID:Data
|
||||
String[] arg = args.split(":");
|
||||
|
||||
//ID
|
||||
int id = 0;
|
||||
try
|
||||
{
|
||||
if (arg.length > 0)
|
||||
id = Integer.parseInt(arg[0]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (id != cur.getId())
|
||||
continue;
|
||||
|
||||
//Data
|
||||
byte data = 0;
|
||||
try
|
||||
{
|
||||
if (arg.length > 1)
|
||||
data = Byte.parseByte(arg[1]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return new AbstractMap.SimpleEntry<Material, Byte>(cur, data);
|
||||
}
|
||||
|
||||
//No / Non-Unique
|
||||
if (matchList.size() != 1)
|
||||
{
|
||||
if (!inform)
|
||||
return null;
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(caller, F.main("Item Search", "" +
|
||||
C.mCount + matchList.size() +
|
||||
C.mBody + " matches for [" +
|
||||
C.mElem + args +
|
||||
C.mBody + "]."));
|
||||
|
||||
if (matchList.size() > 0)
|
||||
{
|
||||
String matchString = "";
|
||||
for (Entry<Material, Byte> cur : matchList)
|
||||
matchString += F.elem(cur.getKey().toString()) + ", ";
|
||||
if (matchString.length() > 1)
|
||||
matchString = matchString.substring(0 , matchString.length() - 2);
|
||||
|
||||
UtilPlayer.message(caller, F.main("Item Search", "" +
|
||||
C.mBody + "Matches [" +
|
||||
C.mElem + matchString +
|
||||
C.mBody + "]."));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return matchList.get(0);
|
||||
}
|
||||
|
||||
public static String itemToStr(ItemStack item)
|
||||
{
|
||||
String data = "0";
|
||||
if (item.getData() != null)
|
||||
data = item.getData().getData() + "";
|
||||
|
||||
return item.getType() + ":" + item.getAmount() + ":" + item.getDurability() + ":" + data;
|
||||
}
|
||||
}
|
@ -125,7 +125,7 @@ public class UtilPlayer
|
||||
for (Entity entity : p.getNearbyEntities(range, range, range))
|
||||
{
|
||||
|
||||
if (entity == p || (entity instanceof Player && ((Player) entity).getGameMode() == GameMode.CREATIVE))
|
||||
if (entity == p || UtilPlayer.isSpectator(entity))
|
||||
continue;
|
||||
|
||||
double theirDist = p.getEyeLocation().distance(entity.getLocation());
|
||||
@ -166,7 +166,7 @@ public class UtilPlayer
|
||||
|
||||
for (Entity entity : player.getNearbyEntities(rangeToScan, rangeToScan, rangeToScan))
|
||||
{
|
||||
if (entity == player || (entity instanceof Player && ((Player) entity).getGameMode() == GameMode.CREATIVE))
|
||||
if (entity == player || UtilPlayer.isSpectator(entity))
|
||||
continue;
|
||||
|
||||
if (avoidNonLiving && !(entity instanceof LivingEntity))
|
||||
@ -395,7 +395,7 @@ public class UtilPlayer
|
||||
|
||||
for (Player cur : loc.getWorld().getPlayers())
|
||||
{
|
||||
if (cur.getGameMode() == GameMode.CREATIVE)
|
||||
if (UtilPlayer.isSpectator(cur))
|
||||
continue;
|
||||
|
||||
if (cur.isDead())
|
||||
@ -429,7 +429,7 @@ public class UtilPlayer
|
||||
|
||||
for (Player cur : loc.getWorld().getPlayers())
|
||||
{
|
||||
if (cur.getGameMode() == GameMode.CREATIVE)
|
||||
if (UtilPlayer.isSpectator(cur))
|
||||
continue;
|
||||
|
||||
if (cur.isDead())
|
||||
@ -457,7 +457,7 @@ public class UtilPlayer
|
||||
|
||||
for (Player cur : loc.getWorld().getPlayers())
|
||||
{
|
||||
if (cur.getGameMode() == GameMode.CREATIVE)
|
||||
if (UtilPlayer.isSpectator(cur))
|
||||
continue;
|
||||
|
||||
if (cur.isDead())
|
||||
@ -502,7 +502,7 @@ public class UtilPlayer
|
||||
|
||||
for (Player cur : loc.getWorld().getPlayers())
|
||||
{
|
||||
if (cur.getGameMode() == GameMode.CREATIVE)
|
||||
if (UtilPlayer.isSpectator(cur))
|
||||
continue;
|
||||
|
||||
double offset = UtilMath.offset(loc, cur.getLocation());
|
||||
@ -582,6 +582,13 @@ public class UtilPlayer
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSpectator(Entity player)
|
||||
{
|
||||
if (player instanceof Player)
|
||||
return ((CraftPlayer) player).getHandle().spectating;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
public void setListName(Player player, CoreClient client)
|
||||
{
|
||||
|
@ -0,0 +1,23 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class UtilText
|
||||
{
|
||||
public static <T> String listToString(Collection<T> inputList, boolean comma)
|
||||
{
|
||||
String out = "";
|
||||
|
||||
for (T cur : inputList)
|
||||
{
|
||||
out += cur.toString() + (comma ? ", " : " ");
|
||||
}
|
||||
|
||||
if (out.length() > 0)
|
||||
{
|
||||
out = out.substring(0, out.length()-(comma ? 2 : 1));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
@ -54,6 +54,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
|
||||
|
||||
private NautHashMap<UUID, Long> _exemptTimeMap = new NautHashMap<UUID, Long>();
|
||||
private NautHashMap<UUID, NautHashMap<CheckType, Long>> _doubleStrike = new NautHashMap<UUID, NautHashMap<CheckType, Long>>();
|
||||
|
||||
private Field _destroyId;
|
||||
|
||||
@ -76,6 +77,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
|
||||
NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
|
||||
NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
|
||||
NCPHookManager.addHook(CheckType.ALL, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -138,6 +140,24 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
for (Iterator<Entry<UUID, NautHashMap<CheckType, Long>>> iterator = _doubleStrike.entrySet().iterator(); iterator.hasNext();)
|
||||
{
|
||||
Entry<UUID, NautHashMap<CheckType, Long>> entry = iterator.next();
|
||||
|
||||
for (Iterator<Entry<CheckType, Long>> innerIterator = entry.getValue().entrySet().iterator(); innerIterator.hasNext();)
|
||||
{
|
||||
final Entry<CheckType, Long> entry2 = innerIterator.next();
|
||||
|
||||
if (System.currentTimeMillis() > entry2.getValue())
|
||||
{
|
||||
innerIterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.getValue() == null || entry.getValue().size() == 0)
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -557,10 +577,27 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
|
||||
@Override
|
||||
public boolean onCheckFailure(CheckType checkType, Player player, IViolationInfo violationInfo)
|
||||
{
|
||||
boolean failure = _exemptTimeMap.containsKey(player.getUniqueId());
|
||||
boolean failure = false;
|
||||
|
||||
if (checkType == CheckType.MOVING_SURVIVALFLY || checkType == CheckType.MOVING_PASSABLE)
|
||||
{
|
||||
failure = _exemptTimeMap.containsKey(player.getUniqueId());
|
||||
|
||||
if (failure)
|
||||
MovingData.getData(player).clearFlyData();
|
||||
}
|
||||
|
||||
// This is the second strike system.
|
||||
if (!failure)
|
||||
{
|
||||
if (!_doubleStrike.containsKey(player.getUniqueId()) || !_doubleStrike.get(player.getUniqueId()).containsKey(checkType.getParent()))
|
||||
failure = true;
|
||||
|
||||
if (!_doubleStrike.containsKey(player.getUniqueId()))
|
||||
_doubleStrike.put(player.getUniqueId(), new NautHashMap<CheckType, Long>());
|
||||
|
||||
_doubleStrike.get(player.getUniqueId()).put(checkType.getParent(), System.currentTimeMillis() + 5000);
|
||||
}
|
||||
|
||||
return failure;
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveRank(final String name, Rank rank, boolean perm)
|
||||
public void SaveRank(final String name, final UUID uuid, Rank rank, boolean perm)
|
||||
{
|
||||
_repository.saveRank(new Callback<Rank>()
|
||||
{
|
||||
@ -350,7 +350,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
client.SetRank(newRank);
|
||||
}
|
||||
}
|
||||
}, name, rank, perm);
|
||||
}, name, uuid, rank, perm);
|
||||
}
|
||||
|
||||
public void checkPlayerNameExact(final Callback<Boolean> callback, final String playerName)
|
||||
|
@ -2,6 +2,7 @@ package mineplex.core.account.command;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,6 +12,7 @@ import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class UpdateRank extends CommandBase<CoreClientManager>
|
||||
@ -86,13 +88,18 @@ public class UpdateRank extends CommandBase<CoreClientManager>
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = Plugin.loadUUIDFromDB(playerName);
|
||||
|
||||
if (uuid == null)
|
||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
|
||||
Plugin.getRepository().saveRank(new Callback<Rank>()
|
||||
{
|
||||
public void run(Rank rank)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), target + "'s rank has been updated to " + rank.Name + "!"));
|
||||
}
|
||||
}, target, rank, true);
|
||||
}, target, uuid, rank, true);
|
||||
|
||||
}
|
||||
}, caller, playerName, true);
|
||||
|
@ -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)
|
||||
@ -217,7 +166,7 @@ public class AccountRepository extends RepositoryBase
|
||||
return uuids.size() == 1 ? uuids.get(0) : null;
|
||||
}
|
||||
|
||||
public void saveRank(final Callback<Rank> callback, final String name, final Rank rank, final boolean perm)
|
||||
public void saveRank(final Callback<Rank> callback, final String name, final UUID uuid, final Rank rank, final boolean perm)
|
||||
{
|
||||
final RankUpdateToken token = new RankUpdateToken();
|
||||
token.Name = name;
|
||||
@ -231,16 +180,16 @@ public class AccountRepository extends RepositoryBase
|
||||
if (rank == Rank.ULTRA || rank == Rank.HERO || rank == Rank.LEGEND)
|
||||
{
|
||||
if (perm)
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
else
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("donorRank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (perm)
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK_PERM, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
else
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||
|
@ -192,7 +192,7 @@ public class AntiHack extends MiniPlugin
|
||||
if (player.equals(other))
|
||||
continue;
|
||||
|
||||
if (other.getGameMode() != GameMode.SURVIVAL)
|
||||
if (other.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player))
|
||||
continue;
|
||||
|
||||
if (other.getVehicle() != null)
|
||||
@ -202,7 +202,7 @@ public class AntiHack extends MiniPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player.isFlying() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL)
|
||||
if (player.isFlying() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.antihack.Detector;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -44,7 +45,7 @@ public class Reach extends MiniPlugin implements Detector
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if (player.getGameMode() != GameMode.SURVIVAL)
|
||||
if (player.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player))
|
||||
continue;
|
||||
|
||||
if (!_history.containsKey(player))
|
||||
|
@ -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,15 +16,14 @@ public final class DBPool
|
||||
{
|
||||
BasicDataSource source = new BasicDataSource();
|
||||
source.addConnectionProperty("autoReconnect", "true");
|
||||
source.setDefaultAutoCommit(true);
|
||||
source.setEnableAutoCommitOnReturn(true);
|
||||
source.setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
|
||||
source.addConnectionProperty("allowMultiQueries", "true");
|
||||
source.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
|
||||
source.setDriverClassName("com.mysql.jdbc.Driver");
|
||||
source.setUrl(url);
|
||||
source.setUsername(username);
|
||||
source.setPassword(password);
|
||||
source.setMaxTotal(10);
|
||||
source.setMaxIdle(3);
|
||||
source.setMaxTotal(4);
|
||||
source.setMaxIdle(4);
|
||||
source.setTimeBetweenEvictionRunsMillis(180 * 1000);
|
||||
source.setSoftMinEvictableIdleTimeMillis(180 * 1000);
|
||||
|
||||
|
@ -1,13 +1,14 @@
|
||||
package mineplex.core.database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.column.Column;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -20,38 +21,30 @@ 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;
|
||||
private DataSource _dataSource; // Connection pool
|
||||
protected JavaPlugin Plugin; // Plugin responsible for this repository
|
||||
|
||||
protected JavaPlugin Plugin;
|
||||
|
||||
public RepositoryBase(JavaPlugin plugin, String connectionString, String username, String password)
|
||||
/**
|
||||
* 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;
|
||||
|
||||
_connectionString = connectionString;
|
||||
_userName = username;
|
||||
_password = password;
|
||||
_dataSource = dataSource;
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
initialize();
|
||||
update();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
@ -61,29 +54,39 @@ public abstract class RepositoryBase implements Listener
|
||||
|
||||
protected abstract void update();
|
||||
|
||||
protected Connection getConnection()
|
||||
/**
|
||||
* @return the {@link DataSource} used by the repository for connection pooling.
|
||||
*/
|
||||
protected DataSource getConnectionPool()
|
||||
{
|
||||
return getConnection(false);
|
||||
return _dataSource;
|
||||
}
|
||||
|
||||
protected Connection getConnection(boolean validate)
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
/**
|
||||
* 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()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_connection == null || (validate && !_connection.isValid(2)))
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
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);
|
||||
@ -91,17 +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)
|
||||
)
|
||||
{
|
||||
if (_connection == null)
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
for (int i=0; i < columns.length; i++)
|
||||
{
|
||||
columns[i].setValue(preparedStatement, i+1);
|
||||
@ -110,49 +110,24 @@ public abstract class RepositoryBase implements Listener
|
||||
affectedRows = preparedStatement.executeUpdate();
|
||||
|
||||
if (callable != null)
|
||||
{
|
||||
callable.processResultSet(preparedStatement.getGeneratedKeys());
|
||||
}
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_connection.isValid(5))
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
executeInsert(query, callable, columns);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.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++)
|
||||
@ -160,127 +135,39 @@ public abstract class RepositoryBase implements Listener
|
||||
columns[i].setValue(statement, i+1);
|
||||
}
|
||||
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
try (ResultSet resultSet = statement.executeQuery())
|
||||
{
|
||||
callable.processResultSet(resultSet);
|
||||
}
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_connection.isValid(5))
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
executeQuery(statement, callable, columns);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.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)
|
||||
)
|
||||
{
|
||||
if (_connection == null)
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(query);
|
||||
|
||||
executeQuery(preparedStatement, callable, columns);
|
||||
}
|
||||
catch (SQLException exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_connection.isValid(5))
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
executeQuery(query, callable, columns);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.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)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_connection.isValid(5))
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
executeUpdate(preparedStatement, columns);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return affectedRows;
|
||||
}
|
||||
|
||||
protected void handleDatabaseCall(final DatabaseRunnable databaseRunnable, final String errorMessage)
|
||||
@ -325,32 +212,6 @@ public abstract class RepositoryBase implements Listener
|
||||
processFailedQueue();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void validateConnection(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.MIN_02)
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_connection == null || !_connection.isValid(5))
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.sql.SQLException;
|
||||
|
||||
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;
|
||||
@ -16,7 +17,7 @@ public class EloRepository extends RepositoryBase
|
||||
|
||||
public EloRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
if (event.getType() != UpdateType.SLOW || Bukkit.getOnlinePlayers().size() == 0)
|
||||
return;
|
||||
|
||||
/*
|
||||
final Player[] onlinePlayers = UtilServer.getPlayers();
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
|
||||
@ -108,10 +109,13 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
public void addFriend(final Player caller, final String name)
|
||||
{
|
||||
caller.sendMessage(F.main(getName(), ChatColor.RED + "Friend is currently disabled."));
|
||||
/*
|
||||
if (caller.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
caller.sendMessage(F.main(getName(), ChatColor.GRAY + "You cannot add yourself as a friend"));
|
||||
@ -214,10 +218,13 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
public void removeFriend(final Player caller, final String name)
|
||||
{
|
||||
caller.sendMessage(F.main(getName(), ChatColor.RED + "Friend is currently disabled."));
|
||||
/*
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
@ -247,10 +254,13 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
});
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
public void showFriends(Player caller)
|
||||
{
|
||||
caller.sendMessage(F.main(getName(), ChatColor.RED + "Friend is currently disabled."));
|
||||
/*
|
||||
boolean isStaff = ClientManager.Get(caller).GetRank().Has(Rank.HELPER);
|
||||
boolean gotAFriend = false;
|
||||
List<FriendStatus> friendStatuses = Get(caller).getFriends();
|
||||
@ -383,6 +393,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
message.add(C.cAqua + C.Strike + "======================");
|
||||
|
||||
message.sendToPlayer(caller);
|
||||
*/
|
||||
}
|
||||
|
||||
public boolean isFriends(Player player, String friend)
|
||||
@ -409,7 +420,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
|
||||
@Override
|
||||
public String getQuery(String uuid, String name)
|
||||
{
|
||||
return "SELECT tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = '"
|
||||
return "SELECT tA.Name, status, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource = '"
|
||||
+ uuid + "';";
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class AddFriend extends CommandBase<FriendManager>
|
||||
@Override
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
if (args == null || args.length < 1)
|
||||
{
|
||||
if (Plugin.getPreferenceManager().Get(caller).friendDisplayInventoryUI)
|
||||
{
|
||||
|
@ -2,27 +2,45 @@ package mineplex.core.friend.data;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
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;
|
||||
import mineplex.core.friend.FriendStatusType;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.data.PlayerStatus;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
public class FriendRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));";
|
||||
private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, serverName, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN ";
|
||||
private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, tA.lastLogin, now() FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget WHERE uuidSource IN ";
|
||||
private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status, created) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, ?, now() FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;";
|
||||
private static String UPDATE_MUTUAL_RECORD = "UPDATE accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid SET aF.status = ? WHERE tA.name = ? AND fA.name = ?;";
|
||||
private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts as fA ON aF.uuidSource = fA.uuid INNER JOIN accounts AS tA ON aF.uuidTarget = tA.uuid WHERE fA.name = ? AND tA.name = ?;";
|
||||
|
||||
// Repository holding active PlayerStatus data.
|
||||
private DataRepository<PlayerStatus> _repository;
|
||||
|
||||
public FriendRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
|
||||
_repository = new RedisDataRepository<PlayerStatus>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||
Region.currentRegion(), PlayerStatus.class, "playerStatus");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,6 +98,7 @@ public class FriendRepository extends RepositoryBase
|
||||
{
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
Set<FriendData> friendDatas = new HashSet<FriendData>();
|
||||
while (resultSet.next())
|
||||
{
|
||||
FriendStatus friend = new FriendStatus();
|
||||
@ -87,15 +106,20 @@ public class FriendRepository extends RepositoryBase
|
||||
String uuidSource = resultSet.getString(1);
|
||||
friend.Name = resultSet.getString(2);
|
||||
friend.Status = Enum.valueOf(FriendStatusType.class, resultSet.getString(3));
|
||||
friend.ServerName = resultSet.getString(4);
|
||||
friend.Online = !(friend.ServerName == null || friend.ServerName.isEmpty());
|
||||
|
||||
friend.LastSeenOnline = resultSet.getTimestamp(6).getTime() - resultSet.getTimestamp(5).getTime();
|
||||
friend.LastSeenOnline = resultSet.getTimestamp(5).getTime() - resultSet.getTimestamp(4).getTime();
|
||||
|
||||
if (!friends.containsKey(uuidSource))
|
||||
friends.put(uuidSource, new FriendData());
|
||||
|
||||
friends.get(uuidSource).getFriends().add(friend);
|
||||
|
||||
friendDatas.add(friends.get(uuidSource));
|
||||
}
|
||||
|
||||
// Load the server status of friends for all sources.
|
||||
for(FriendData friendData : friendDatas)
|
||||
{
|
||||
loadFriendStatuses(friendData);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -113,12 +137,59 @@ public class FriendRepository extends RepositoryBase
|
||||
|
||||
friend.Name = resultSet.getString(1);
|
||||
friend.Status = Enum.valueOf(FriendStatusType.class, resultSet.getString(2));
|
||||
friend.ServerName = resultSet.getString(3);
|
||||
friend.LastSeenOnline = resultSet.getTimestamp(5).getTime() - resultSet.getTimestamp(4).getTime();
|
||||
|
||||
friend.LastSeenOnline = resultSet.getTimestamp(4).getTime() - resultSet.getTimestamp(3).getTime();
|
||||
friend.ServerName = null;
|
||||
friend.Online = (friend.ServerName != null);
|
||||
friendData.getFriends().add(friend);
|
||||
}
|
||||
|
||||
loadFriendStatuses(friendData);
|
||||
|
||||
return friendData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the server status information for a list of {@link FriendStatus}.
|
||||
* @param friendData - the {@link FriendStatus} object friends server status' are to be updated
|
||||
* @param statuses - the fetched {@link PlayerStatus} associated with all online {@code friends}.
|
||||
*/
|
||||
public void loadFriendStatuses(FriendData friendData)
|
||||
{
|
||||
// Generate a set of all friend names
|
||||
Set<String> friendNames = new HashSet<String>();
|
||||
for(FriendStatus status : friendData.getFriends())
|
||||
{
|
||||
friendNames.add(status.Name);
|
||||
}
|
||||
|
||||
// Load PlayerStatus' for friends
|
||||
Collection<PlayerStatus> statuses = _repository.getElements(friendNames);
|
||||
|
||||
// Load player statuses into a mapping
|
||||
Map<String, PlayerStatus> playerStatuses = new HashMap<String, PlayerStatus>();
|
||||
for(PlayerStatus status : statuses)
|
||||
{
|
||||
playerStatuses.put(status.getName(), status);
|
||||
}
|
||||
|
||||
// Load status information into friend data.
|
||||
for (FriendStatus friend : friendData.getFriends())
|
||||
{
|
||||
PlayerStatus status = playerStatuses.get(friend.Name);
|
||||
friend.Online = (status != null);
|
||||
friend.ServerName = (friend.Online) ? status.getServer() : null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playerName - the name of the player whose current server status is being fetched
|
||||
* @return the {@link MinecraftServer} name that the player matching {@code playerName}
|
||||
* is currently online on, if they are online, null otherwise.
|
||||
*/
|
||||
public String fetchPlayerServer(String playerName)
|
||||
{
|
||||
PlayerStatus status = _repository.getElement(playerName);
|
||||
|
||||
return (status == null) ? null : status.getServer();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.disguises.DisguiseSkeleton;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
|
||||
public class MorphPumpkinKing extends MorphGadget
|
||||
{
|
||||
@ -43,17 +44,8 @@ public class MorphPumpkinKing extends MorphGadget
|
||||
|
||||
player.getInventory().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
|
||||
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
other.hidePlayer(player);
|
||||
other.showPlayer(player);
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers());
|
||||
VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -160,7 +160,7 @@ public class MorphWither extends MorphGadget
|
||||
|
||||
for (Player player : GetActive())
|
||||
{
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
continue;
|
||||
|
||||
player.setAllowFlight(true);
|
||||
|
@ -63,7 +63,7 @@ public class ParticleHeart extends ParticleGadget
{
|
||||
if (other.equals(player))
|
||||
continue;
|
||||
|
||||
if (other.getGameMode() != GameMode.SURVIVAL)
|
||||
if (!UtilPlayer.isSpectator(other))
|
||||
continue;
|
||||
|
||||
if (_target.get(player).containsKey(other))
|
||||
|
@ -5,6 +5,7 @@ import java.util.HashSet;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
@ -69,7 +70,7 @@ public abstract class Gadget extends SalesPackageBase implements Listener
|
||||
|
||||
if (gadgetEvent.isCancelled())
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Inventory", "You cannot use Inventory Items."));
|
||||
UtilPlayer.message(player, F.main("Inventory", GetName() + " is not enabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -77,6 +78,12 @@ public abstract class Gadget extends SalesPackageBase implements Listener
|
||||
Manager.setActive(player, this);
|
||||
}
|
||||
|
||||
public void DisableForAll()
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
Disable(player);
|
||||
}
|
||||
|
||||
public void Disable(Player player)
|
||||
{
|
||||
if (IsActive(player))
|
||||
@ -93,4 +100,6 @@ public abstract class Gadget extends SalesPackageBase implements Listener
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class MusicGadget extends Gadget
|
||||
|
||||
if (gadgetEvent.isCancelled())
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Inventory", "You cannot use Inventory Items here."));
|
||||
UtilPlayer.message(player, F.main("Inventory", GetName() + " is not enabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public abstract class ParticleGadget extends Gadget
|
||||
|
||||
public boolean shouldDisplay(Player player)
|
||||
{
|
||||
if (player.getGameMode() != GameMode.SURVIVAL)
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
return false;
|
||||
|
||||
if (Manager.hideParticles())
|
||||
|
133
Plugins/Mineplex.Core/src/mineplex/core/give/Give.java
Normal file
133
Plugins/Mineplex.Core/src/mineplex/core/give/Give.java
Normal file
@ -0,0 +1,133 @@
|
||||
package mineplex.core.give;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.give.commands.GiveCommand;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
|
||||
public class Give extends MiniPlugin
|
||||
{
|
||||
public static Give Instance;
|
||||
|
||||
protected Give(JavaPlugin plugin)
|
||||
{
|
||||
super("Give Factory", plugin);
|
||||
}
|
||||
|
||||
public static void Initialize(JavaPlugin plugin)
|
||||
{
|
||||
Instance = new Give(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new GiveCommand(this));
|
||||
}
|
||||
|
||||
public void parseInput(Player player, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
help(player);
|
||||
|
||||
else if (args.length == 1)
|
||||
give(player, player.getName(), args[0], "1");
|
||||
|
||||
else if (args.length == 2)
|
||||
give(player, args[0], args[1], "1");
|
||||
|
||||
else
|
||||
give(player, args[0], args[1], args[2]);
|
||||
}
|
||||
|
||||
public void help(Player player)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Give", "Commands List;"));
|
||||
}
|
||||
|
||||
public void give(Player player, String target, String itemNames, String amount)
|
||||
{
|
||||
//Item
|
||||
LinkedList<Entry<Material, Byte>> itemList = new LinkedList<Entry<Material, Byte>>();
|
||||
itemList = UtilItem.matchItem(player, itemNames, true);
|
||||
if (itemList.isEmpty())
|
||||
return;
|
||||
|
||||
//Player
|
||||
LinkedList<Player> giveList = new LinkedList<Player>();
|
||||
|
||||
if (target.equalsIgnoreCase("all"))
|
||||
{
|
||||
for (Player cur : UtilServer.getPlayers())
|
||||
giveList.add(cur);
|
||||
}
|
||||
else
|
||||
{
|
||||
giveList = UtilPlayer.matchOnline(player, target, true);
|
||||
if (giveList.isEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Amount
|
||||
int count = 1;
|
||||
try
|
||||
{
|
||||
count = Integer.parseInt(amount);
|
||||
|
||||
if (count < 1)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Give", "Invalid Amount [" + amount + "]. Defaulting to [1]."));
|
||||
count = 1;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Give", "Invalid Amount [" + amount + "]. Defaulting to [1]."));
|
||||
}
|
||||
|
||||
//Create
|
||||
String givenList = "";
|
||||
for (Player cur : giveList)
|
||||
givenList += cur.getName() + " ";
|
||||
if (givenList.length() > 0)
|
||||
givenList = givenList.substring(0, givenList.length()-1);
|
||||
|
||||
for (Entry<Material, Byte> curItem : itemList)
|
||||
{
|
||||
for (Player cur : giveList)
|
||||
{
|
||||
ItemStack stack = ItemStackFactory.Instance.CreateStack(curItem.getKey(), curItem.getValue(), count);
|
||||
|
||||
//Give
|
||||
if (UtilInv.insert(cur, stack))
|
||||
{
|
||||
//Inform
|
||||
if (!cur.equals(player))
|
||||
UtilPlayer.message(cur, F.main("Give", "You received " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " from " + F.elem(player.getName()) + "."));
|
||||
}
|
||||
}
|
||||
|
||||
if (target.equalsIgnoreCase("all"))
|
||||
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem("ALL")) + ".");
|
||||
|
||||
else if (giveList.size() > 1)
|
||||
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem(givenList) + "."));
|
||||
|
||||
else
|
||||
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem(giveList.getFirst().getName()) + "."));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package mineplex.core.give.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.give.Give;
|
||||
|
||||
public class GiveCommand extends CommandBase<Give>
|
||||
{
|
||||
public GiveCommand(Give plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "give", "g", "item", "i");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
{
|
||||
Plugin.parseInput(caller, args);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package mineplex.core.ignore.data;
|
||||
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,8 +17,7 @@ public class IgnoreRepository extends RepositoryBase
|
||||
|
||||
public IgnoreRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10",
|
||||
"root", "tAbechAk3wR7tuTh");
|
||||
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.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
|
||||
|
@ -5,6 +5,7 @@ import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.spawn.command.SpawnCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -58,9 +59,19 @@ public class LeaderboardManager extends MiniPlugin
|
||||
* @param value - the counter value used to increment the statistic
|
||||
* @return true, if the stat event was successfully triggered and logged, false otherwise.
|
||||
*/
|
||||
public boolean onStatEvent(Player player, StatType type, int gamemode, int value)
|
||||
public boolean onStatEvent(final Player player, final StatType type, final int gamemode, final int value)
|
||||
{
|
||||
/*
|
||||
// Asynchronously make DB call to insert stat event.
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_statEvents.insertStatEvent(player.getName(), gamemode, _serverGroup, type.getTypeId(), value);
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -35,8 +35,8 @@ import mineplex.core.punish.Punish;
|
||||
import mineplex.core.punish.PunishClient;
|
||||
import mineplex.core.punish.Punishment;
|
||||
import mineplex.core.punish.PunishmentSentence;
|
||||
import mineplex.serverdata.ServerCommandManager;
|
||||
import mineplex.serverdata.transfers.AnnouncementCommand;
|
||||
import mineplex.serverdata.commands.AnnouncementCommand;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
{
|
||||
@ -113,7 +113,6 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
|
||||
public String canReceiverMessageThem(String sender, Player target)
|
||||
{
|
||||
|
||||
// If the receiver has turned off private messaging and the sender isn't a mod
|
||||
if (!_preferences.Get(target).PrivateMessaging)
|
||||
{
|
||||
@ -311,7 +310,6 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
||||
|
||||
public void receiveMessage(Player to, RedisMessage globalMessage)
|
||||
{
|
||||
|
||||
if (globalMessage.isStaffMessage())
|
||||
{
|
||||
// Message the receiver
|
||||
|
@ -7,7 +7,7 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.serverdata.transfers.AnnouncementCommand;
|
||||
import mineplex.serverdata.commands.AnnouncementCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -5,7 +5,7 @@ import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.serverdata.transfers.AnnouncementCommand;
|
||||
import mineplex.serverdata.commands.AnnouncementCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -4,9 +4,9 @@ import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.serverdata.CommandCallback;
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.transfers.AnnouncementCommand;
|
||||
import mineplex.serverdata.commands.AnnouncementCommand;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -4,8 +4,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.serverdata.CommandCallback;
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class MessageHandler implements CommandCallback
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ package mineplex.core.message.redis;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
/**
|
||||
* Used to send a admin or normal message between servers
|
||||
|
@ -2,7 +2,7 @@ package mineplex.core.message.redis;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
/**
|
||||
* Used as a response in return to a admin or normal message between servers.
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import mineplex.core.common.CurrencyType;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.mount.event.MountActivateEvent;
|
||||
import mineplex.core.shop.item.SalesPackageBase;
|
||||
|
||||
@ -46,7 +47,7 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
|
||||
|
||||
if (gadgetEvent.isCancelled())
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Inventory", "You cannot use Inventory Items."));
|
||||
UtilPlayer.message(player, F.main("Inventory", GetName() + " is not enabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -56,6 +57,12 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
|
||||
public abstract void EnableCustom(Player player);
|
||||
public abstract void Disable(Player player);
|
||||
|
||||
public void DisableForAll()
|
||||
{
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
Disable(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ public class RefreshCommand extends CommandBase<NpcManager>
|
||||
{
|
||||
public RefreshCommand(NpcManager plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "refresh");
|
||||
super(plugin, Rank.SNR_MODERATOR, "refresh");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,10 +16,10 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.party.redis.RedisPartyData;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerGroup;
|
||||
import mineplex.serverdata.ServerManager;
|
||||
import mineplex.serverdata.transfers.ServerTransfer;
|
||||
import mineplex.serverdata.transfers.TransferCommand;
|
||||
import mineplex.serverdata.commands.ServerTransfer;
|
||||
import mineplex.serverdata.commands.TransferCommand;
|
||||
import mineplex.serverdata.data.ServerGroup;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -5,6 +5,7 @@ import java.util.Iterator;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.party.commands.PartyCommand;
|
||||
import mineplex.core.party.redis.RedisPartyData;
|
||||
import mineplex.core.party.redis.RedisPartyHandler;
|
||||
@ -13,7 +14,7 @@ import mineplex.core.portal.ServerTransferEvent;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.serverdata.ServerCommandManager;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -29,7 +30,7 @@ public class PartyManager extends MiniPlugin
|
||||
private Portal _portal;
|
||||
private String _serverName;
|
||||
|
||||
public HashSet<Party> _parties = new HashSet<Party>();
|
||||
public NautHashMap<String, Party> _partyLeaderMap = new NautHashMap<String, Party>();
|
||||
|
||||
public PartyManager(JavaPlugin plugin, Portal portal, CoreClientManager clientManager, PreferencesManager preferenceManager)
|
||||
{
|
||||
@ -64,7 +65,7 @@ public class PartyManager extends MiniPlugin
|
||||
{
|
||||
Party party = new Party(this);
|
||||
party.JoinParty(player);
|
||||
_parties.add(party);
|
||||
_partyLeaderMap.put(player.getName(), party);
|
||||
|
||||
return party;
|
||||
}
|
||||
@ -76,41 +77,25 @@ public class PartyManager extends MiniPlugin
|
||||
|
||||
public void addParty(Party party)
|
||||
{
|
||||
for (Party parties : _parties)
|
||||
{
|
||||
if (parties.GetLeader().equalsIgnoreCase(party.GetLeader()))
|
||||
{
|
||||
parties.resetWaitingTime();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_parties.add(party);
|
||||
if (_partyLeaderMap.containsKey(party.GetLeader()))
|
||||
_partyLeaderMap.get(party.GetLeader()).resetWaitingTime();
|
||||
else
|
||||
_partyLeaderMap.put(party.GetLeader(), party);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverTransfer(ServerTransferEvent event)
|
||||
{
|
||||
for (Party party : _parties)
|
||||
{
|
||||
if (party.GetLeader().equals(event.getPlayer().getName()))
|
||||
Party party = _partyLeaderMap.get(event.getPlayer().getName());
|
||||
|
||||
if (party != null)
|
||||
{
|
||||
party.switchedServer();
|
||||
|
||||
boolean destLobby = event.getServer().equalsIgnoreCase("lobby");
|
||||
|
||||
RedisPartyData data = new RedisPartyData(party, destLobby ? _serverName : null);
|
||||
|
||||
if (!destLobby)
|
||||
{
|
||||
RedisPartyData data = new RedisPartyData(party, _serverName);
|
||||
data.setTargetServers(event.getServer());
|
||||
}
|
||||
|
||||
data.publish();
|
||||
|
||||
if (!destLobby)
|
||||
{
|
||||
for (Player player : party.GetPlayersOnline())
|
||||
{
|
||||
if (player != event.getPlayer())
|
||||
@ -119,10 +104,6 @@ public class PartyManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@ -130,7 +111,7 @@ public class PartyManager extends MiniPlugin
|
||||
{
|
||||
try
|
||||
{
|
||||
for (Party party : _parties)
|
||||
for (Party party : _partyLeaderMap.values())
|
||||
{
|
||||
party.PlayerJoin(event.getPlayer());
|
||||
}
|
||||
@ -144,7 +125,7 @@ public class PartyManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void PlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
for (Party party : _parties)
|
||||
for (Party party : _partyLeaderMap.values())
|
||||
{
|
||||
party.PlayerQuit(event.getPlayer());
|
||||
}
|
||||
@ -158,7 +139,7 @@ public class PartyManager extends MiniPlugin
|
||||
|
||||
ExpireParties();
|
||||
|
||||
for (Party party : _parties)
|
||||
for (Party party : _partyLeaderMap.values())
|
||||
{
|
||||
party.ExpireInvitees();
|
||||
party.UpdateScoreboard();
|
||||
@ -167,7 +148,7 @@ public class PartyManager extends MiniPlugin
|
||||
|
||||
public void ExpireParties()
|
||||
{
|
||||
Iterator<Party> partyIterator = _parties.iterator();
|
||||
Iterator<Party> partyIterator = _partyLeaderMap.values().iterator();
|
||||
|
||||
while (partyIterator.hasNext())
|
||||
{
|
||||
@ -184,7 +165,7 @@ public class PartyManager extends MiniPlugin
|
||||
|
||||
public Party GetParty(Player player)
|
||||
{
|
||||
for (Party party : _parties)
|
||||
for (Party party : _partyLeaderMap.values())
|
||||
{
|
||||
if (party.GetPlayers().contains(player.getName()))
|
||||
{
|
||||
|
@ -1,11 +1,10 @@
|
||||
package mineplex.core.party.redis;
|
||||
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class RedisPartyData extends ServerCommand
|
||||
{
|
||||
|
||||
private String[] _players;
|
||||
private String _leader;
|
||||
private String _previousServer;
|
||||
|
@ -2,8 +2,8 @@ package mineplex.core.party.redis;
|
||||
|
||||
import mineplex.core.party.Party;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.serverdata.CommandCallback;
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class RedisPartyHandler implements CommandCallback
|
||||
{
|
||||
@ -17,9 +17,14 @@ public class RedisPartyHandler implements CommandCallback
|
||||
@Override
|
||||
public void run(ServerCommand command)
|
||||
{
|
||||
RedisPartyData data = (RedisPartyData) command;
|
||||
final RedisPartyData data = (RedisPartyData) command;
|
||||
|
||||
_partyManager.getPlugin().getServer().getScheduler().runTask(_partyManager.getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_partyManager.addParty(new Party(_partyManager, data));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package mineplex.core.personalServer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
public class HostEventServerCommand extends CommandBase<PersonalServerManager>
|
||||
{
|
||||
public HostEventServerCommand(PersonalServerManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "hostevent");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (!Recharge.Instance.use(caller, "Host Event", 30000, false, false))
|
||||
return;
|
||||
|
||||
Plugin.hostServer(caller, caller.getName(), true);
|
||||
}
|
||||
}
|
@ -19,6 +19,6 @@ public class HostServerCommand extends CommandBase<PersonalServerManager>
|
||||
if (!Recharge.Instance.use(caller, "Host Server", 30000, false, false))
|
||||
return;
|
||||
|
||||
Plugin.hostServer(caller, caller.getName());
|
||||
Plugin.hostServer(caller, caller.getName(), false);
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerGroup;
|
||||
import mineplex.serverdata.ServerManager;
|
||||
import mineplex.serverdata.ServerRepository;
|
||||
import mineplex.serverdata.data.ServerGroup;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ServerRepository;
|
||||
|
||||
public class PersonalServerManager extends MiniPlugin
|
||||
{
|
||||
@ -100,6 +100,7 @@ public class PersonalServerManager extends MiniPlugin
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new HostServerCommand(this));
|
||||
addCommand(new HostEventServerCommand(this));
|
||||
}
|
||||
|
||||
private void setupConfigValues()
|
||||
@ -117,23 +118,26 @@ public class PersonalServerManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void hostServer(Player player, String serverName)
|
||||
public void hostServer(Player player, String serverName, boolean eventServer)
|
||||
{
|
||||
int ram = 1024;
|
||||
int cpu = 1;
|
||||
|
||||
Rank rank = _clientManager.Get(player).GetRank();
|
||||
|
||||
if (rank.Has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE)
|
||||
if (eventServer || rank.Has(Rank.SNR_MODERATOR) || rank == Rank.YOUTUBE)
|
||||
{
|
||||
ram = 2048;
|
||||
cpu = 3;
|
||||
cpu = 4;
|
||||
}
|
||||
|
||||
createGroup(player, serverName, ram, cpu, 12, 24, "Smash");
|
||||
if (eventServer)
|
||||
createGroup(player, "EVENT", ram, cpu, 40, 80, "Event", eventServer);
|
||||
else
|
||||
createGroup(player, serverName, ram, cpu, 40, 80, "Smash", eventServer);
|
||||
}
|
||||
|
||||
private void createGroup(final Player host, final String serverName, final int ram, final int cpu, final int minPlayers, final int maxPlayers, final String games)
|
||||
private void createGroup(final Player host, final String serverName, final int ram, final int cpu, final int minPlayers, final int maxPlayers, final String games, final boolean event)
|
||||
{
|
||||
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
@ -144,7 +148,7 @@ public class PersonalServerManager extends MiniPlugin
|
||||
if (existingServerGroup.getPrefix().equalsIgnoreCase(serverName) || existingServerGroup.getName().equalsIgnoreCase(serverName))
|
||||
{
|
||||
if (host.getName().equalsIgnoreCase(existingServerGroup.getHost()))
|
||||
host.sendMessage(F.main(getName(), "Your server is still being created. If you haven't been connected in 20 seconds, type /server " + serverName + "-1."));
|
||||
host.sendMessage(F.main(getName(), "Your server is still being created or already exists. If you haven't been connected in 20 seconds, type /server " + serverName + "-1."));
|
||||
else
|
||||
host.sendMessage(C.cRed + "Sorry, but you're not allowed to create a MPS server because you have chosen a name to glitch the system :)");
|
||||
|
||||
@ -153,7 +157,7 @@ public class PersonalServerManager extends MiniPlugin
|
||||
}
|
||||
|
||||
final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), ram, cpu, 1, 0, UtilMath.random.nextInt(250) + 19999, true, "arcade.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers,
|
||||
true, false, false, games, "Player", true, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU);
|
||||
true, false, false, games, "Player", true, event, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU);
|
||||
|
||||
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
|
@ -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()
|
||||
|
@ -23,13 +23,13 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTabTitle;
|
||||
import mineplex.core.portal.Commands.SendCommand;
|
||||
import mineplex.core.portal.Commands.ServerCommand;
|
||||
import mineplex.serverdata.MinecraftServer;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerCommandManager;
|
||||
import mineplex.serverdata.ServerManager;
|
||||
import mineplex.serverdata.ServerRepository;
|
||||
import mineplex.serverdata.transfers.ServerTransfer;
|
||||
import mineplex.serverdata.transfers.TransferCommand;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
import mineplex.serverdata.commands.ServerTransfer;
|
||||
import mineplex.serverdata.commands.TransferCommand;
|
||||
import mineplex.serverdata.data.MinecraftServer;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ServerRepository;
|
||||
|
||||
public class Portal extends MiniPlugin
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
package mineplex.core.portal;
|
||||
|
||||
import mineplex.serverdata.CommandCallback;
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.transfers.ServerTransfer;
|
||||
import mineplex.serverdata.transfers.TransferCommand;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
import mineplex.serverdata.commands.ServerTransfer;
|
||||
import mineplex.serverdata.commands.TransferCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -36,28 +36,12 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
|
||||
{
|
||||
super("Preferences", plugin, clientManager);
|
||||
|
||||
setupConfigValues();
|
||||
|
||||
_repository = new PreferencesRepository(plugin, plugin.getConfig().getString("preferences.connectionurl"));
|
||||
_repository = new PreferencesRepository(plugin);
|
||||
_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,5 +1,6 @@
|
||||
package mineplex.core.preferences;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -8,18 +9,19 @@ import java.util.Map.Entry;
|
||||
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.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=?;";
|
||||
|
||||
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
||||
public PreferencesRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, connectionString, "root", "tAbechAk3wR7tuTh");
|
||||
super(plugin, DBPool.ACCOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -35,12 +37,12 @@ public class PreferencesRepository extends RepositoryBase
|
||||
|
||||
public void saveUserPreferences(NautHashMap<String, UserPreferences> preferences)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
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);
|
||||
@ -92,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
|
||||
|
@ -4,6 +4,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguiseSquid;
|
||||
@ -133,8 +134,9 @@ public class ProjectileUser
|
||||
if (ent.equals(_thrower))
|
||||
continue;
|
||||
|
||||
//Creative or Spec
|
||||
if (ent instanceof Player)
|
||||
if (((Player)ent).getGameMode() == GameMode.CREATIVE)
|
||||
if (((Player)ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent))
|
||||
continue;
|
||||
|
||||
EntityType disguise = null;
|
||||
|
@ -16,7 +16,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.punish.Command.PunishCommand;
|
||||
import mineplex.core.punish.Tokens.PunishClientToken;
|
||||
import mineplex.core.punish.Tokens.PunishmentToken;
|
||||
import mineplex.serverdata.ServerCommandManager;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
@ -44,7 +44,7 @@ public class Punish extends MiniPlugin
|
||||
_clientManager = clientManager;
|
||||
_repository = new PunishRepository(webServerAddress);
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("PunishCommand", mineplex.serverdata.transfers.PunishCommand.class, new PunishmentHandler(this));
|
||||
ServerCommandManager.getInstance().registerCommandType("PunishCommand", mineplex.serverdata.commands.PunishCommand.class, new PunishmentHandler(this));
|
||||
}
|
||||
|
||||
public PunishRepository GetRepository()
|
||||
@ -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.commands.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.commands.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>()
|
||||
{
|
||||
|
@ -3,9 +3,9 @@ package mineplex.core.punish;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.punish.Tokens.PunishClientToken;
|
||||
import mineplex.serverdata.CommandCallback;
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.transfers.PunishCommand;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.PunishCommand;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -3,7 +3,7 @@ package mineplex.core.report;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.serverdata.Data;
|
||||
import mineplex.serverdata.data.Data;
|
||||
|
||||
public class Report implements Data
|
||||
{
|
||||
|
@ -9,9 +9,10 @@ import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.report.command.ReportNotification;
|
||||
import mineplex.serverdata.DataRepository;
|
||||
import mineplex.serverdata.RedisDataRepository;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.Utility;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -189,7 +190,7 @@ public class ReportManager {
|
||||
*/
|
||||
public int generateReportId()
|
||||
{
|
||||
JedisPool pool = ((RedisDataRepository<Report>) reportRepository).getJedisPool();
|
||||
JedisPool pool = Utility.getPool(true);
|
||||
Jedis jedis = pool.getResource();
|
||||
long uniqueReportId = -1;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package mineplex.core.report;
|
||||
|
||||
import mineplex.serverdata.Data;
|
||||
import mineplex.serverdata.data.Data;
|
||||
|
||||
public class ReportProfile implements Data
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -4,7 +4,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class ReportNotification extends ServerCommand
|
||||
{
|
||||
|
@ -76,31 +76,31 @@ public class RewardManager
|
||||
// Gadgets
|
||||
addReward(new InventoryReward(inventoryManager, "Paintballs", "Paintball Gun",
|
||||
(int)(100*(minValue/500)), (int)(100*(maxValue/500)),
|
||||
new ItemStack(Material.GOLD_BARDING), rarity, 1));
|
||||
new ItemStack(Material.GOLD_BARDING), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Fireworks", "Fireworks",
|
||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||
new ItemStack(Material.FIREWORK), rarity, 1));
|
||||
new ItemStack(Material.FIREWORK), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Melons", "Melon Launcher",
|
||||
(int)(50*(minValue/500)), (int)(50*(maxValue/500)),
|
||||
new ItemStack(Material.MELON_BLOCK), rarity, 1));
|
||||
new ItemStack(Material.MELON_BLOCK), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Flesh Hooks", "Flesh Hook",
|
||||
(int)(40*(minValue/500)), (int)(40*(maxValue/500)),
|
||||
new ItemStack(Material.getMaterial(131)), rarity, 1));
|
||||
new ItemStack(Material.getMaterial(131)), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Pearls", "Ethereal Pearl",
|
||||
(int)(30*(minValue/500)), (int)(30*(maxValue/500)),
|
||||
new ItemStack(Material.ENDER_PEARL), rarity, 1));
|
||||
new ItemStack(Material.ENDER_PEARL), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "Bat Swarms", "Bat Blaster",
|
||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||
new ItemStack(Material.IRON_BARDING), rarity, 1));
|
||||
new ItemStack(Material.IRON_BARDING), rarity, 10));
|
||||
|
||||
addReward(new InventoryReward(inventoryManager, "TNT", "TNT",
|
||||
(int)(20*(minValue/500)), (int)(20*(maxValue/500)),
|
||||
new ItemStack(Material.TNT), rarity, 1));
|
||||
new ItemStack(Material.TNT), rarity, 10));
|
||||
}
|
||||
|
||||
public void addUncommon(DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, double minValue, double maxValue)
|
||||
|
@ -1,11 +1,14 @@
|
||||
package mineplex.core.reward.rewards;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.reward.Reward;
|
||||
import mineplex.core.reward.RewardData;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
@ -21,7 +24,6 @@ public class RankReward extends Reward
|
||||
_clientManager = clientManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RewardData giveRewardCustom(Player player)
|
||||
{
|
||||
@ -34,7 +36,7 @@ public class RankReward extends Reward
|
||||
return new RewardData(getRarity().getColor() + "Rank Upgrade Error", new ItemStack(Material.PAPER));
|
||||
|
||||
_clientManager.Get(player).SetRank(rank);
|
||||
_clientManager.getRepository().saveRank(null, player.getName(), rank, true);
|
||||
_clientManager.getRepository().saveRank(null, player.getName(), player.getUniqueId(), rank, true);
|
||||
|
||||
return new RewardData(getRarity().getColor() + rank.Name + " Rank", new ItemStack(Material.NETHER_STAR));
|
||||
}
|
||||
|
@ -5,22 +5,30 @@ import java.lang.reflect.Field;
|
||||
import net.minecraft.server.v1_7_R4.PlayerList;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerGroup;
|
||||
import mineplex.serverdata.ServerManager;
|
||||
import mineplex.serverdata.data.ServerGroup;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
public class ServerConfiguration extends MiniPlugin
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
private Field _playerListMaxPlayers;
|
||||
private ServerGroup _serverGroup;
|
||||
|
||||
public ServerConfiguration(JavaPlugin plugin)
|
||||
public ServerConfiguration(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
{
|
||||
super("Server Configuration", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
Region region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
|
||||
String groupName = plugin.getConfig().getString("serverstatus.group");
|
||||
|
||||
@ -45,6 +53,13 @@ public class ServerConfiguration extends MiniPlugin
|
||||
((CraftServer)_plugin.getServer()).getServer().setTexturePack(_serverGroup.getResourcePack());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
{
|
||||
if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.HELPER, false))
|
||||
event.disallow(Result.KICK_OTHER, "This is a staff only server.");
|
||||
}
|
||||
|
||||
public ServerGroup getServerGroup()
|
||||
{
|
||||
return _serverGroup;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class StatsManager extends MiniDbClientPlugin<PlayerStats>
|
||||
_statUploadQueue.get(player).put(statName, 0);
|
||||
}
|
||||
|
||||
_statUploadQueue.get(player).put(statName, value);
|
||||
_statUploadQueue.get(player).put(statName, _statUploadQueue.get(player).get(statName) + value);
|
||||
}
|
||||
|
||||
protected void saveStats()
|
||||
|
@ -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)
|
||||
|
@ -14,19 +14,19 @@ import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.monitor.LagMeter;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.serverdata.MinecraftServer;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerCommandManager;
|
||||
import mineplex.serverdata.ServerGroup;
|
||||
import mineplex.serverdata.ServerManager;
|
||||
import mineplex.serverdata.ServerRepository;
|
||||
import mineplex.serverdata.Utility;
|
||||
import mineplex.serverdata.transfers.SuicideCommand;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
import mineplex.serverdata.commands.SuicideCommand;
|
||||
import mineplex.serverdata.data.MinecraftServer;
|
||||
import mineplex.serverdata.data.ServerGroup;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
import mineplex.serverdata.servers.ServerRepository;
|
||||
|
||||
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;
|
||||
|
@ -2,10 +2,10 @@ package mineplex.core.status;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.serverdata.CommandCallback;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.transfers.SuicideCommand;
|
||||
import mineplex.serverdata.commands.CommandCallback;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
import mineplex.serverdata.commands.SuicideCommand;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -23,7 +23,7 @@ import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.serverdata.ServerCommandManager;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
@ -2,7 +2,7 @@ package mineplex.core.teleport.redis;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.serverdata.ServerCommand;
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class RedisLocate extends ServerCommand
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user