Merge branch 'master' of https://github.com/Mineplex-LLC/Minecraft-PC into Dual_1.9
This commit is contained in:
commit
2a9d49ccd9
@ -30,7 +30,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kencochrane.raven</groupId>
|
||||
<artifactId>raven-log4j2</artifactId>
|
||||
<artifactId>raven</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
|
@ -7,21 +7,27 @@ import mineplex.bungee.motd.MotdManager;
|
||||
import mineplex.bungee.playerCount.PlayerCount;
|
||||
import mineplex.bungee.playerStats.PlayerStats;
|
||||
import mineplex.bungee.playerTracker.PlayerTracker;
|
||||
import mineplex.bungee.status.InternetStatus;
|
||||
import net.kencochrane.raven.RavenFactory;
|
||||
import net.kencochrane.raven.DefaultRavenFactory;
|
||||
import net.kencochrane.raven.dsn.Dsn;
|
||||
import net.kencochrane.raven.jul.SentryHandler;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
public class Mineplexer extends Plugin
|
||||
{
|
||||
{
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
// Sentry setup
|
||||
Handler sentry = new SentryHandler(RavenFactory.ravenInstance("https://470f12378af3453ba089e0c0a0c9aae6:292516b722594784807aebb06db8ec38@app.getsentry.com/66323"));
|
||||
sentry.setLevel(Level.WARNING);
|
||||
getProxy().getLogger().addHandler(sentry);
|
||||
|
||||
public void onEnable() {
|
||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Sentry setup
|
||||
Handler sentry = new SentryHandler(new DefaultRavenFactory().createRavenInstance(
|
||||
new Dsn("https://470f12378af3453ba089e0c0a0c9aae6:292516b722594784807aebb06db8ec38@app.getsentry.com/66323"
|
||||
)));
|
||||
sentry.setLevel(Level.SEVERE);
|
||||
getProxy().getLogger().addHandler(sentry);
|
||||
}
|
||||
});
|
||||
|
||||
new MotdManager(this);
|
||||
new LobbyBalancer(this);
|
||||
PlayerCount playerCount = new PlayerCount(this);
|
||||
|
@ -10,14 +10,13 @@ import java.util.UUID;
|
||||
|
||||
import mineplex.bungee.playerStats.data.IpInfo;
|
||||
import mineplex.cache.player.PlayerInfo;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
|
||||
public class PlayerStatsRepository
|
||||
import javax.sql.DataSource;
|
||||
|
||||
public class PlayerStatsRepository extends RepositoryBase
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/PlayerStats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String INSERT_PLAYERINFO = "INSERT INTO playerInfo (uuid, name, version) VALUES (?, ?, ?);";
|
||||
private static String SELECT_PLAYERINFO = "SELECT id, name, version FROM playerInfo WHERE uuid = ?;";
|
||||
private static String UPDATE_PLAYERINFO = "UPDATE playerInfo SET name = ?, version = ? WHERE id = ?;";
|
||||
@ -30,34 +29,33 @@ public class PlayerStatsRepository
|
||||
+ "INSERT IGNORE INTO playerLoginSessions (playerInfoId, loginTime) values(?, now());";
|
||||
|
||||
private static String UPDATE_LOGINSESSION = "UPDATE playerLoginSessions SET timeInGame = TIME_TO_SEC(TIMEDIFF(now(), loginTime)) / 60 WHERE id = ?;";
|
||||
|
||||
|
||||
public PlayerStatsRepository()
|
||||
{
|
||||
super(DBPool.getPlayerStats());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Initialized PlayerStats.");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PlayerInfo getPlayer(UUID uuid, String name, int version)
|
||||
{
|
||||
PlayerInfo playerInfo = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
try
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(SELECT_PLAYERINFO);
|
||||
preparedStatement = connection.prepareStatement(SELECT_PLAYERINFO);
|
||||
|
||||
preparedStatement.setString(1, uuid.toString());
|
||||
|
||||
@ -73,7 +71,7 @@ public class PlayerStatsRepository
|
||||
|
||||
if (playerInfo == null)
|
||||
{
|
||||
preparedStatement = _connection.prepareStatement(INSERT_PLAYERINFO, Statement.RETURN_GENERATED_KEYS);
|
||||
preparedStatement = connection.prepareStatement(INSERT_PLAYERINFO, Statement.RETURN_GENERATED_KEYS);
|
||||
preparedStatement.setString(1, uuid.toString());
|
||||
preparedStatement.setString(2, name);
|
||||
preparedStatement.setInt(3, version);
|
||||
@ -96,7 +94,7 @@ public class PlayerStatsRepository
|
||||
}
|
||||
else if (!playerInfo.getName().equalsIgnoreCase(name) || playerInfo.getVersion() != version)
|
||||
{
|
||||
preparedStatement = _connection.prepareStatement(UPDATE_PLAYERINFO);
|
||||
preparedStatement = connection.prepareStatement(UPDATE_PLAYERINFO);
|
||||
preparedStatement.setString(1, name);
|
||||
preparedStatement.setInt(2, version);
|
||||
preparedStatement.setInt(3, playerInfo.getId());
|
||||
@ -145,12 +143,9 @@ public class PlayerStatsRepository
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
try
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(SELECT_IPINFO);
|
||||
preparedStatement = connection.prepareStatement(SELECT_IPINFO);
|
||||
preparedStatement.setString(1, ipAddress);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
@ -167,7 +162,7 @@ public class PlayerStatsRepository
|
||||
|
||||
if (ipInfo == null)
|
||||
{
|
||||
preparedStatement = _connection.prepareStatement(INSERT_IPINFO, Statement.RETURN_GENERATED_KEYS);
|
||||
preparedStatement = connection.prepareStatement(INSERT_IPINFO, Statement.RETURN_GENERATED_KEYS);
|
||||
preparedStatement.setString(1, ipAddress);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
@ -228,12 +223,9 @@ public class PlayerStatsRepository
|
||||
Statement statement = null;
|
||||
ResultSet resultSet= null;
|
||||
|
||||
try
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
statement = _connection.createStatement();
|
||||
statement = connection.createStatement();
|
||||
|
||||
String queryString = UPDATE_PLAYERSTATS;
|
||||
queryString = queryString.replaceFirst("\\?", playerId + "");
|
||||
@ -286,12 +278,9 @@ public class PlayerStatsRepository
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(UPDATE_LOGINSESSION);
|
||||
preparedStatement = connection.prepareStatement(UPDATE_LOGINSESSION);
|
||||
preparedStatement.setInt(1, loginSessionId);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
|
@ -1,50 +1,43 @@
|
||||
package mineplex.bungee;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerStatsRepository
|
||||
public class PlayerStatsRepository extends RepositoryBase
|
||||
{
|
||||
private Connection _connection = null;
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/PlayerStats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&allowMultiQueries=true";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String SELECT_IPINFO = "SELECT id, ipAddress FROM ipInfo WHERE regionName IS NULL LIMIT 1000;";
|
||||
private static String UPDATE_IPINFO = "UPDATE ipInfo SET countryCode = ?, countryName = ?, regionCode = ?, regionName = ?, city = ?, zipCode = ?, timeZone = ?, latitude = ?, longitude = ?, metroCode = ? WHERE id = ?;";
|
||||
|
||||
public void initialize()
|
||||
|
||||
public PlayerStatsRepository()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Initialized PlayerStats.");
|
||||
super(DBPool.getPlayerStats());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<IpInfo> getIpAddresses()
|
||||
{
|
||||
List<IpInfo> ipinfos = new ArrayList<IpInfo>(1000);
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet resultSet = null;
|
||||
|
||||
try
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(SELECT_IPINFO);
|
||||
preparedStatement = connection.prepareStatement(SELECT_IPINFO);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
@ -98,12 +91,9 @@ public class PlayerStatsRepository
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(UPDATE_IPINFO);
|
||||
preparedStatement = connection.prepareStatement(UPDATE_IPINFO);
|
||||
|
||||
for (IpInfo ipInfo : ips)
|
||||
{
|
||||
|
@ -47,7 +47,16 @@ public class PlayerCache
|
||||
{
|
||||
try
|
||||
{
|
||||
return _repository.getElement(uuid.toString());
|
||||
System.out.println("Getting PlayerCache for " + uuid.toString());
|
||||
PlayerInfo playerInfo = _repository.getElement(uuid.toString());
|
||||
System.out.println("Got playerINfo: " + playerInfo);
|
||||
if (playerInfo != null)
|
||||
{
|
||||
System.out.println("account id: " + playerInfo.getAccountId());
|
||||
System.out.println("name: " + playerInfo.getName());
|
||||
}
|
||||
|
||||
return playerInfo;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -464,6 +464,11 @@ public class UtilBlock
|
||||
return getHighest(world, x, z, null);
|
||||
}
|
||||
|
||||
public static Block getHighest(World world, Location location)
|
||||
{
|
||||
return getHighest(world, location.getBlockX(), location.getBlockZ(), null);
|
||||
}
|
||||
|
||||
public static Block getHighest(World world, int x, int z, HashSet<Material> ignore)
|
||||
{
|
||||
Block block = world.getHighestBlockAt(x, z);
|
||||
|
@ -1,15 +1,19 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class UtilWorld
|
||||
{
|
||||
public static World getWorld(String world)
|
||||
@ -194,4 +198,15 @@ public class UtilWorld
|
||||
|
||||
return vec.toLocation(world);
|
||||
}
|
||||
|
||||
private static List<Block> branch(Location origin)
|
||||
{
|
||||
return Lists.newArrayList(origin.getBlock(),
|
||||
origin.getBlock().getRelative(BlockFace.DOWN),
|
||||
origin.getBlock().getRelative(BlockFace.UP),
|
||||
origin.getBlock().getRelative(BlockFace.NORTH),
|
||||
origin.getBlock().getRelative(BlockFace.EAST),
|
||||
origin.getBlock().getRelative(BlockFace.SOUTH),
|
||||
origin.getBlock().getRelative(BlockFace.WEST));
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -21,16 +22,16 @@ import mineplex.core.account.repository.token.RankUpdateToken;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.DatabaseRunnable;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnBoolean;
|
||||
import mineplex.core.database.column.ColumnTimestamp;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.DatabaseRunnable;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnBoolean;
|
||||
import mineplex.serverdata.database.column.ColumnTimestamp;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import mineplex.core.server.remotecall.JsonWebCall;
|
||||
|
||||
public class AccountRepository extends RepositoryBase
|
||||
public class AccountRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));";
|
||||
private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now());";
|
||||
@ -234,7 +235,7 @@ public class AccountRepository extends RepositoryBase
|
||||
executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, rank.toString()), new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@ -4,7 +4,7 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -33,7 +33,7 @@ public class AntiHackRepository
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try (Connection connection = DBPool.getStats().getConnection())
|
||||
try (Connection connection = DBPool.getMineplexStats().getConnection())
|
||||
{
|
||||
preparedStatement = connection.prepareStatement(UPDATE_PLAYER_OFFENSES);
|
||||
|
||||
|
@ -3,14 +3,15 @@ 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.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BenefitManagerRepository extends RepositoryBase
|
||||
public class BenefitManagerRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, accountId INT, benefit VARCHAR(100), PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||
|
||||
|
@ -27,7 +27,7 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.donation.GiveDonorData;
|
||||
import mineplex.core.facebook.FacebookManager;
|
||||
@ -67,7 +67,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -10,9 +10,10 @@ import java.sql.Types;
|
||||
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.database.Tables;
|
||||
@ -28,7 +29,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BonusRepository extends RepositoryBase
|
||||
public class BonusRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_BONUS_TABLE = "CREATE TABLE IF NOT EXISTS bonus (accountId INT NOT NULL AUTO_INCREMENT, dailytime TIMESTAMP NULL DEFAULT NULL, ranktime DATE NULL DEFAULT NULL, PRIMARY KEY (accountId), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||
private BonusManager _manager;
|
||||
|
@ -4,16 +4,17 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.core.botspam.SpamText;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class BotSpamRepository extends RepositoryBase
|
||||
public class BotSpamRepository extends MinecraftRepository
|
||||
{
|
||||
private static final String GET_SPAM_TEXT = "SELECT * FROM botSpam";
|
||||
private static final String ADD_SPAM_TEXT = "INSERT INTO botSpam (text, createdBy, enabledBy) VALUES (?, ?, ?)";
|
||||
|
@ -5,24 +5,24 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.customdata.CustomData;
|
||||
import mineplex.core.customdata.CustomDataManager;
|
||||
import mineplex.core.customdata.PlayerCustomData;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 16/12/15
|
||||
*/
|
||||
public class CustomDataRepository extends RepositoryBase
|
||||
public class CustomDataRepository extends MinecraftRepository
|
||||
{
|
||||
private static final String SELECT_KEYS = "SELECT id, name FROM customData;";
|
||||
private static final String INSERT_KEY = "INSERT INTO customData (name) VALUES (?);";
|
||||
|
@ -0,0 +1,112 @@
|
||||
package mineplex.core.database;
|
||||
|
||||
import java.sql.Connection;
|
||||
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.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.DatabaseRunnable;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.Column;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class MinecraftRepository extends RepositoryBase implements Listener
|
||||
{
|
||||
// Queue for failed processes
|
||||
private static Object _queueLock = new Object();
|
||||
private NautHashMap<DatabaseRunnable, String> _failedQueue = new NautHashMap<DatabaseRunnable, String>();
|
||||
|
||||
protected JavaPlugin _plugin; // Plugin responsible for this repository
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param plugin - the {@link JavaPlugin} module responsible for this repository.
|
||||
* @param dataSource - the {@link DataSource} responsible for providing the connection pool to this repository.
|
||||
*/
|
||||
public MinecraftRepository(JavaPlugin plugin, DataSource dataSource)
|
||||
{
|
||||
super(dataSource);
|
||||
|
||||
_plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
protected DSLContext jooq()
|
||||
{
|
||||
return DSL.using(DBPool.getAccount(), SQLDialect.MYSQL);
|
||||
}
|
||||
|
||||
protected void handleDatabaseCall(final DatabaseRunnable databaseRunnable, final String errorMessage)
|
||||
{
|
||||
Thread asyncThread = new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
databaseRunnable.run();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
processFailedDatabaseCall(databaseRunnable, exception.getMessage(), errorMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
asyncThread.start();
|
||||
}
|
||||
|
||||
protected void processFailedDatabaseCall(DatabaseRunnable databaseRunnable, String errorPreMessage, String runnableMessage)
|
||||
{
|
||||
if (databaseRunnable.getFailedCounts() < 4)
|
||||
{
|
||||
databaseRunnable.incrementFailCount();
|
||||
|
||||
synchronized (_queueLock)
|
||||
{
|
||||
_failedQueue.put(databaseRunnable, runnableMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void processDatabaseQueue(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.MIN_01)
|
||||
return;
|
||||
|
||||
processFailedQueue();
|
||||
}
|
||||
|
||||
private void processFailedQueue()
|
||||
{
|
||||
synchronized (_queueLock)
|
||||
{
|
||||
for (Iterator<DatabaseRunnable> runnablesIterator = _failedQueue.keySet().iterator(); runnablesIterator.hasNext();)
|
||||
{
|
||||
DatabaseRunnable databaseRunnable = runnablesIterator.next();
|
||||
handleDatabaseCall(databaseRunnable, _failedQueue.get(databaseRunnable));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JavaPlugin getPlugin()
|
||||
{
|
||||
return _plugin;
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package mineplex.core.database;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.column.Column;
|
||||
|
||||
public class Row
|
||||
{
|
||||
public NautHashMap<String, Column<?>> Columns = new NautHashMap<String, Column<?>>();
|
||||
}
|
@ -1,21 +1,18 @@
|
||||
package mineplex.core.donation.repository;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.CurrencyType;
|
||||
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;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.DatabaseRunnable;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.core.donation.Donor;
|
||||
import mineplex.core.donation.repository.token.GemRewardToken;
|
||||
import mineplex.core.donation.repository.token.PurchaseToken;
|
||||
@ -24,7 +21,7 @@ import mineplex.core.server.remotecall.AsyncJsonWebCall;
|
||||
import mineplex.core.server.remotecall.JsonWebCall;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
|
||||
public class DonationRepository extends RepositoryBase
|
||||
public class DonationRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_COIN_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountCoinTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), coins INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accountId INT, reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));";
|
||||
@ -54,7 +51,7 @@ public class DonationRepository extends RepositoryBase
|
||||
{
|
||||
public void run(final TransactionResponse response)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@ -100,7 +97,7 @@ public class DonationRepository extends RepositoryBase
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@ -131,7 +128,7 @@ public class DonationRepository extends RepositoryBase
|
||||
{
|
||||
public void run(final Boolean response)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@ -168,7 +165,7 @@ public class DonationRepository extends RepositoryBase
|
||||
//executeUpdate(INSERT_COIN_TRANSACTION, new ColumnInt("id", accountId), new ColumnVarChar("reason", 100, "Rewarded by " + giver), new ColumnInt("coins", coins));
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(Plugin, new Runnable()
|
||||
Bukkit.getServer().getScheduler().runTask(getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@ -3,14 +3,15 @@ package mineplex.core.elo;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class EloRepository extends RepositoryBase
|
||||
public class EloRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_ELO_TABLE = "CREATE TABLE IF NOT EXISTS eloRating (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), gameType VARCHAR(256), elo INT, PRIMARY KEY (id), UNIQUE INDEX uuid_gameType_index (uuid, gameType));";
|
||||
private static String INSERT_ELO = "INSERT INTO eloRating (uuid, gameType, elo) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE elo=VALUES(elo);";
|
||||
|
@ -3,16 +3,17 @@ package mineplex.core.facebook;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class FacebookRepository extends RepositoryBase
|
||||
public class FacebookRepository extends MinecraftRepository
|
||||
{
|
||||
private static final String GET_CODE = "SELECT code, activated FROM facebook WHERE code = ?";
|
||||
private static final String ACTIVATE_CODE = "UPDATE facebook SET activated = 1, accountId = ?, activationTime = NOW() WHERE code = ?";
|
||||
|
@ -5,18 +5,18 @@ 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 mineplex.core.database.MinecraftRepository;
|
||||
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.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import mineplex.core.friend.FriendStatusType;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
@ -24,7 +24,7 @@ import mineplex.serverdata.data.PlayerStatus;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
public class FriendRepository extends RepositoryBase
|
||||
public class FriendRepository extends MinecraftRepository
|
||||
{
|
||||
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, 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 ";
|
||||
|
@ -8,17 +8,17 @@ import java.sql.Types;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.Region;
|
||||
|
||||
public class GiveawayRepository extends RepositoryBase
|
||||
public class GiveawayRepository extends MinecraftRepository
|
||||
{
|
||||
private static final String INSERT_GIVEAWAY = "INSERT INTO Account.accountGiveaway (giveawayId, accountId, cooldownId, region, serverName, time, uuid) VALUES (?, ?, ?, ?, ?, now(), ?)";
|
||||
private static final String LOAD_GIVEAWAY = "SELECT id, name, prettyName, header, message, max, notifyNetwork, notifyCooldown, canWinTwice FROM Account.giveaway WHERE enabled = TRUE";
|
||||
|
@ -3,14 +3,15 @@ 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;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class IgnoreRepository extends RepositoryBase
|
||||
public class IgnoreRepository extends MinecraftRepository
|
||||
{
|
||||
private static String ADD_IGNORE_RECORD = "INSERT INTO accountIgnore (uuidIgnorer, uuidIgnored) SELECT fA.uuid AS uuidIgnorer, tA.uuid AS uuidIgnored FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;";
|
||||
private static String DELETE_IGNORE_RECORD = "DELETE aF FROM accountIgnore AS aF INNER JOIN accounts as fA ON aF.uuidIgnorer = fA.uuid INNER JOIN accounts AS tA ON aF.uuidIgnored = tA.uuid WHERE fA.name = ? AND tA.name = ?;";
|
||||
|
@ -5,18 +5,19 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import mineplex.core.inventory.ClientInventory;
|
||||
import mineplex.core.inventory.ClientItem;
|
||||
|
||||
public class InventoryRepository extends RepositoryBase
|
||||
public class InventoryRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_INVENTORY_TABLE = "CREATE TABLE IF NOT EXISTS items (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), rarity INT, PRIMARY KEY (id), INDEX mameIndex (name));";
|
||||
private static String CREATE_INVENTORY_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountInventory (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, itemId INT NOT NULL, count INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (itemId) REFERENCES items(id), UNIQUE INDEX accountItemIndex (accountId, itemId));";
|
||||
|
@ -1,9 +1,10 @@
|
||||
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;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -15,7 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
* @author MrTwiggy
|
||||
*
|
||||
*/
|
||||
public class StatEventsRepository extends RepositoryBase
|
||||
public class StatEventsRepository extends MinecraftRepository
|
||||
{
|
||||
|
||||
// Insert or update stat events query
|
||||
|
@ -38,7 +38,7 @@ import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.creature.event.CreatureKillEntitiesEvent;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.core.npc.command.NpcCommand;
|
||||
import mineplex.core.npc.event.NpcDamageByEntityEvent;
|
||||
import mineplex.core.npc.event.NpcInteractEntityEvent;
|
||||
|
@ -2,21 +2,21 @@ package mineplex.core.pet.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import mineplex.core.pet.repository.token.PetChangeToken;
|
||||
import mineplex.core.pet.repository.token.PetExtraToken;
|
||||
import mineplex.core.pet.repository.token.PetSalesToken;
|
||||
import mineplex.core.server.remotecall.AsyncJsonWebCall;
|
||||
import mineplex.core.server.remotecall.JsonWebCall;
|
||||
|
||||
public class PetRepository extends RepositoryBase
|
||||
public class PetRepository extends MinecraftRepository
|
||||
{
|
||||
private String _webAddress;
|
||||
|
||||
@ -31,7 +31,7 @@ public class PetRepository extends RepositoryBase
|
||||
{
|
||||
new AsyncJsonWebCall(_webAddress + "Pets/AddPet").Execute(token);
|
||||
|
||||
Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable()
|
||||
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
@ -49,7 +49,7 @@ public class PetRepository extends RepositoryBase
|
||||
{
|
||||
new AsyncJsonWebCall(_webAddress + "Pets/RemovePet").Execute(token);
|
||||
|
||||
Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable()
|
||||
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
@ -72,7 +72,7 @@ public class PetRepository extends RepositoryBase
|
||||
{
|
||||
new AsyncJsonWebCall(_webAddress + "Pets/UpdatePet").Execute(token);
|
||||
|
||||
Plugin.getServer().getScheduler().runTaskAsynchronously(Plugin, new Runnable()
|
||||
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
|
@ -6,18 +6,19 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/16/2014.
|
||||
*/
|
||||
public class PollRepository extends RepositoryBase
|
||||
public class PollRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_POLL_TABLE = "CREATE TABLE IF NOT EXISTS polls (id INT NOT NULL AUTO_INCREMENT, enabled BIT(1), question VARCHAR(256) NOT NULL, answerA VARCHAR(256) NOT NULL, answerB VARCHAR(256), answerC VARCHAR(256), answerD VARCHAR(256), coinReward INT NOT NULL, displayType INT DEFAULT 0 NOT NULL, PRIMARY KEY (id));";
|
||||
private static String CREATE_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountPolls (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, pollId INT NOT NULL, value TINYINT(1) NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (pollId) REFERENCES polls(id), UNIQUE INDEX accountPollIndex (accountId, pollId));";
|
||||
|
@ -6,14 +6,15 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class PreferencesRepository extends RepositoryBase
|
||||
public class PreferencesRepository extends MinecraftRepository
|
||||
{
|
||||
// private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS
|
||||
// accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256),
|
||||
|
@ -1,22 +1,14 @@
|
||||
package mineplex.core.report;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
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;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.core.preferences.UserPreferences;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ReportRepository extends RepositoryBase
|
||||
public class ReportRepository extends MinecraftRepository
|
||||
{
|
||||
/*
|
||||
* *ReportTicket
|
||||
|
@ -1,87 +0,0 @@
|
||||
package mineplex.core.simpleStats;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class SimpleStats extends MiniPlugin
|
||||
{
|
||||
private static Object _transferLock = new Object();
|
||||
|
||||
private SimpleStatsRepository _repository = new SimpleStatsRepository();
|
||||
private NautHashMap<String, String> _entries = new NautHashMap<String, String>();
|
||||
|
||||
public SimpleStats(JavaPlugin plugin)
|
||||
{
|
||||
super("SimpleStats", plugin);
|
||||
|
||||
_repository.initialize();
|
||||
}
|
||||
|
||||
/*
|
||||
public NautHashMap<String, String> getEntries()
|
||||
{
|
||||
synchronized (_transferLock)
|
||||
{
|
||||
return _entries;
|
||||
}
|
||||
}*/
|
||||
|
||||
@EventHandler
|
||||
public void storeStatsUpdate(final UpdateEvent updateEvent)
|
||||
{
|
||||
if (updateEvent.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_transferLock)
|
||||
{
|
||||
_entries = (_repository.retrieveStatRecords());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void store(String statName, String statValue)
|
||||
{
|
||||
final String statNameFinal = statName;
|
||||
final String statValueFinal = statValue;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_transferLock)
|
||||
{
|
||||
_repository.storeStatValue(statNameFinal, statValueFinal);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public NautHashMap<String, String> getStat(String statName)
|
||||
{
|
||||
final String statNameFinal = statName;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_transferLock)
|
||||
{
|
||||
_entries = _repository.retrieveStat(statNameFinal);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return _entries;
|
||||
}
|
||||
}
|
@ -1,220 +0,0 @@
|
||||
package mineplex.core.simpleStats;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
|
||||
public class SimpleStatsRepository
|
||||
{
|
||||
private static Object _connectionLock = new Object();
|
||||
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh"; //try to obfuscate this in the future!
|
||||
|
||||
private static String CREATE_STATS_TABLE = "CREATE TABLE IF NOT EXISTS simpleStats (id INT NOT NULL AUTO_INCREMENT, statName VARCHAR(64), statValue VARCHAR(64), PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_STATS_RECORDS = "SELECT simpleStats.statName, simpleStats.statValue FROM simpleStats;";
|
||||
private static String STORE_STATS_RECORD = "INSERT INTO simpleStats (statName,statValue) VALUES(?,?);";
|
||||
private static String RETRIEVE_STAT_RECORD = "SELECT simpleStats.statName, simpleStats.statValue FROM simpleStats WHERE statName = '?';";
|
||||
|
||||
private Connection _connection = null;
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
/*
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_STATS_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public NautHashMap<String, String> retrieveStatRecords()
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
NautHashMap<String, String> statRecords = new NautHashMap<String, String>();
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_STATS_RECORDS);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
statRecords.put(resultSet.getString(1), resultSet.getString(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
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 statRecords;
|
||||
}
|
||||
|
||||
public void storeStatValue(String statName, String statValue)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(STORE_STATS_RECORD);
|
||||
preparedStatement.setString(1, statName);
|
||||
preparedStatement.setString(2, statValue);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NautHashMap<String, String> retrieveStat(String statName)
|
||||
{
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
NautHashMap<String, String> statRecords = new NautHashMap<String, String>();
|
||||
|
||||
try
|
||||
{
|
||||
synchronized (_connectionLock)
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(RETRIEVE_STAT_RECORD);
|
||||
preparedStatement.setString(1, statName);
|
||||
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
statRecords.put(resultSet.getString(1), resultSet.getString(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
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 statRecords;
|
||||
}
|
||||
}
|
@ -5,14 +5,15 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class SpawnRepository extends RepositoryBase
|
||||
public class SpawnRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_SPAWN_TABLE = "CREATE TABLE IF NOT EXISTS spawns (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(100), location VARCHAR(100), PRIMARY KEY (id), INDEX serverNameIndex (serverName));";
|
||||
private static String RETRIEVE_SPAWNS = "SELECT location FROM spawns WHERE serverName = ?;";
|
||||
|
@ -7,10 +7,11 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import mineplex.database.Tables;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -23,7 +24,7 @@ import org.jooq.Update;
|
||||
import org.jooq.impl.DSL;
|
||||
import org.jooq.types.ULong;
|
||||
|
||||
public class StatsRepository extends RepositoryBase
|
||||
public class StatsRepository extends MinecraftRepository
|
||||
{
|
||||
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
|
||||
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";
|
||||
|
@ -5,17 +5,18 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import mineplex.core.task.Task;
|
||||
import mineplex.core.task.TaskClient;
|
||||
|
||||
public class TaskRepository extends RepositoryBase
|
||||
public class TaskRepository extends MinecraftRepository
|
||||
{
|
||||
private static String ADD_ACCOUNT_TASK = "INSERT INTO accountTasks (accountId, taskId) VALUES (?, ?);";
|
||||
|
||||
|
@ -4,15 +4,16 @@ import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Types;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.Region;
|
||||
|
||||
public class TitanGiveawayRepository extends RepositoryBase
|
||||
public class TitanGiveawayRepository extends MinecraftRepository
|
||||
{
|
||||
private static final String ADD_TITAN = "INSERT INTO titanGiveaway (accountId, region, serverName) VALUES (?, ?, ?)";
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
package mineplex.core.valentines;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ValentinesGiftRepository extends RepositoryBase
|
||||
public class ValentinesGiftRepository extends MinecraftRepository
|
||||
{
|
||||
private String GIVE_GIFT = "INSERT INTO accountValentinesGift (senderId, targetId) VALUES (?, ?);";
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class DnsMadeEasyRepository
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean switchToDDOSProt()
|
||||
{
|
||||
Connection connection = null;
|
||||
|
@ -1,13 +1,14 @@
|
||||
package mineplex.enjinTranslator;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class TempRepository extends RepositoryBase
|
||||
public class TempRepository extends MinecraftRepository
|
||||
{
|
||||
private static String INSERT_CLIENT_INVENTORY = "INSERT INTO accountInventory (accountId, itemId, count) SELECT accounts.id, 5, ? FROM accounts WHERE accounts.name = ? ON DUPLICATE KEY UPDATE count=count + VALUES(count);";
|
||||
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.enjinTranslator.purchase.data.PurchaseRepository;
|
||||
import mineplex.enjinTranslator.purchase.data.Package;
|
||||
|
||||
|
@ -5,16 +5,17 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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.ColumnBoolean;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnBoolean;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class PurchaseRepository extends RepositoryBase
|
||||
public class PurchaseRepository extends MinecraftRepository
|
||||
{
|
||||
private static String INSERT_ACCOUNT_PURCHASE = "INSERT INTO accountPurchases (accountId, packageId, amount, date, success) VALUES (?, ?, ?, now(), ?);";
|
||||
|
||||
|
@ -11,14 +11,15 @@ import java.util.UUID;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
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.Column;
|
||||
import mineplex.core.database.column.ColumnBoolean;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnTimestamp;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.Column;
|
||||
import mineplex.serverdata.database.column.ColumnBoolean;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnTimestamp;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import mineplex.database.tables.records.ClansRecord;
|
||||
import mineplex.game.clans.core.repository.tokens.ClanAllianceToken;
|
||||
import mineplex.game.clans.core.repository.tokens.ClanMemberToken;
|
||||
@ -36,7 +37,7 @@ import org.jooq.DSLContext;
|
||||
import static mineplex.database.Tables.*;
|
||||
import static org.jooq.impl.DSL.*;
|
||||
|
||||
public class ClanRepository extends RepositoryBase
|
||||
public class ClanRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS clans (id INT NOT NULL AUTO_INCREMENT, serverId INT NOT NULL, name VARCHAR(100), description VARCHAR(140), home VARCHAR(140), admin BIT(1), dateCreated DATETIME, lastOnline DATETIME, energy INT, PRIMARY KEY (id), INDEX clanName (name));";
|
||||
private static String CREATE_ACCOUNT_CLAN_TABLE = "CREATE TABLE IF NOT EXISTS accountClan (id INT NOT NULL AUTO_INCREMENT, accountId INT, clanId INT, clanRole VARCHAR(140), PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (clanId) REFERENCES clans(id), INDEX clanIdIndex (clanId));";
|
||||
|
@ -53,7 +53,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
public class Clans extends JavaPlugin
|
||||
{
|
||||
public static final String VERSION = "0.19";
|
||||
public static final String VERSION = "1.0";
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
// Modules
|
||||
|
@ -67,6 +67,7 @@ public class ClanInfo
|
||||
private HashMap<String, ClanWarData> _warOut = new HashMap<String, ClanWarData>();
|
||||
|
||||
// Temporary
|
||||
private NautHashMap<String, Long> _recentlyLeft = new NautHashMap<>();
|
||||
private NautHashMap<String, Long> _inviteeMap = new NautHashMap<String, Long>();
|
||||
private NautHashMap<String, String> _inviterMap = new NautHashMap<String, String>();
|
||||
private List<UUID> _onlinePlayers = new ArrayList<UUID>();
|
||||
@ -76,6 +77,7 @@ public class ClanInfo
|
||||
public ClansManager Clans;
|
||||
|
||||
private BedStatus _bedStatus = null;
|
||||
|
||||
|
||||
public ClanInfo(ClansManager clans, ClanToken token)
|
||||
{
|
||||
@ -478,7 +480,7 @@ public class ClanInfo
|
||||
|
||||
public boolean isOnline()
|
||||
{
|
||||
return isOnlineNow();// || System.currentTimeMillis() - _lastOnline.getTime() < Clans.getOnlineTime();
|
||||
return isOnlineNow();
|
||||
}
|
||||
|
||||
public String getProtected()
|
||||
@ -487,7 +489,7 @@ public class ClanInfo
|
||||
if (cur.isOnline())
|
||||
return C.cRed + "No - Clan Members are Online";
|
||||
|
||||
if (System.currentTimeMillis() - _lastOnline.getTime() > Clans.getOnlineTime())
|
||||
if (UtilTime.elapsed(_lastOnline.getTime(), Clans.getOnlineTime()))
|
||||
return C.cGreen + "Yes - Clan Members are Offline";
|
||||
|
||||
return C.cGold
|
||||
@ -496,6 +498,10 @@ public class ClanInfo
|
||||
TimeUnit.FIT) + " to Protection";
|
||||
}
|
||||
|
||||
public boolean isProtected() {
|
||||
return getProtected().startsWith(C.cGreen + "Yes");
|
||||
}
|
||||
|
||||
public TntGenerator getGenerator()
|
||||
{
|
||||
return _generator;
|
||||
@ -800,4 +806,9 @@ public class ClanInfo
|
||||
{
|
||||
return _bedStatus == BedStatus.DESTROYED ? C.cRed + "Destroyed" : (_bedStatus == BedStatus.DOESNT_EXIST ? C.cWhite + "None" : (_bedStatus == BedStatus.EXISTS_AND_OBSTRUCTED ? C.cRed + "Obstructed" : (_bedStatus == BedStatus.EXISTS_AND_UNOBSTRUCTED ? C.cGreen + UtilWorld.locToStrClean(_home) : "N/A")));
|
||||
}
|
||||
|
||||
public void left(String name)
|
||||
{
|
||||
_recentlyLeft.put(name, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,9 @@ public class ClansAdmin
|
||||
else if (args[1].equalsIgnoreCase("wp"))
|
||||
wp(caller, args);
|
||||
|
||||
else if (args[1].equalsIgnoreCase("timer"))
|
||||
resetTime(caller, args);
|
||||
|
||||
else
|
||||
help(caller);
|
||||
}
|
||||
@ -111,8 +114,26 @@ public class ClansAdmin
|
||||
UtilPlayer.message(caller, F.help("/c x unclaim (all)", "Unclaim Territory for Mimic", Rank.CMOD));
|
||||
UtilPlayer.message(caller, F.help("/c x delete", "Delete Mimic Clan", Rank.CMOD));
|
||||
UtilPlayer.message(caller, F.help("/c x autoclaim", "AutoClaim for Mimic Clan", Rank.CMOD));
|
||||
UtilPlayer.message(caller, F.help("/c x timer <player>", "Reset Clan Create Timer", Rank.CMOD));
|
||||
UtilPlayer.message(caller, F.main("Mimic Clan", Clans.Get(caller).getMimic()));
|
||||
}
|
||||
|
||||
private void resetTime(Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 3)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans Admin", "You did not enter a player name"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = UtilPlayer.searchOnline(caller, args[2], true);
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
Clans.resetLeftTimer(player.getUniqueId());
|
||||
UtilPlayer.message(caller, F.main("Clans Admin", "Reset Clan create timer for " + F.name(player.getName())));
|
||||
}
|
||||
}
|
||||
|
||||
private void autoclaim(Player caller)
|
||||
{
|
||||
|
@ -297,6 +297,8 @@ public class ClansDataAccessLayer
|
||||
clan.getMembers().remove(clansPlayer.getUuid());
|
||||
_manager.getClanMemberUuidMap().remove(clansPlayer.getUuid());
|
||||
clan.playerOffline(clansPlayer.getPlayerName());
|
||||
|
||||
_manager.justLeft(clansPlayer.getUuid(), clan);
|
||||
// Log
|
||||
_manager.log("Removed [" + clansPlayer.getPlayerName() + "] from [" + clan.getName() + "].");
|
||||
}
|
||||
@ -603,7 +605,7 @@ public class ClansDataAccessLayer
|
||||
{
|
||||
UtilBlock.deleteBed(clan.getHome());
|
||||
clan.setHome(null);
|
||||
clan.inform("Clan has lost it's Home because of a Territory loss.", null);
|
||||
clan.inform("Clan has lost its Home because of a Territory loss.", null);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -750,6 +752,8 @@ public class ClansDataAccessLayer
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run(ran);
|
||||
} else {
|
||||
if(!ran) System.out.println("Tnt Gen didn't save!");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -263,7 +263,7 @@ public class ClansGame extends MiniPlugin
|
||||
{
|
||||
// Cancel
|
||||
event.SetCancelled("Clans Ally");
|
||||
|
||||
|
||||
// Inform
|
||||
if (damager != null)
|
||||
{
|
||||
@ -520,8 +520,9 @@ public class ClansGame extends MiniPlugin
|
||||
{
|
||||
ClanInfo clan = _clans.getClanUtility().getClanByPlayer(event.getPlayer());
|
||||
if (clan == null) return;
|
||||
|
||||
clan.setLastOnline(new Timestamp(System.currentTimeMillis()));
|
||||
|
||||
if(!clan.isOnline()) clan.setLastOnline(new Timestamp(System.currentTimeMillis())); //Noone else on
|
||||
else clan.setLastOnline(new Timestamp(0));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -538,14 +539,14 @@ public class ClansGame extends MiniPlugin
|
||||
|
||||
ClanInfo clan = _clans.getClanUtility().getOwner(event.getEntity().getLocation());
|
||||
if (clan == null) return;
|
||||
|
||||
|
||||
if (_clans.getWarManager().isBeingInvaded(clan))
|
||||
{
|
||||
// Allow because of invasion
|
||||
return;
|
||||
}
|
||||
|
||||
if (!clan.isOnline())
|
||||
if (!clan.isProtected())
|
||||
event.setCancelled(true);
|
||||
else
|
||||
clan.inform(C.cRed + "Your Territory is under attack!", null);
|
||||
|
@ -39,7 +39,7 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.chat.MessageData;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -75,10 +75,8 @@ import mineplex.game.clans.clans.commands.ClanManagementCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansLoginManager;
|
||||
import mineplex.game.clans.clans.commands.KillCommand;
|
||||
import mineplex.game.clans.clans.commands.MapCommand;
|
||||
import mineplex.game.clans.clans.commands.Meow;
|
||||
import mineplex.game.clans.clans.commands.RegionsCommand;
|
||||
import mineplex.game.clans.clans.data.PlayerClan;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
|
||||
@ -86,7 +84,6 @@ import mineplex.game.clans.clans.gui.ClanShop;
|
||||
import mineplex.game.clans.clans.loot.LootManager;
|
||||
import mineplex.game.clans.clans.map.ItemMapManager;
|
||||
import mineplex.game.clans.clans.observer.ObserverManager;
|
||||
import mineplex.game.clans.clans.outpost.OutpostManager;
|
||||
import mineplex.game.clans.clans.playtime.Playtime;
|
||||
import mineplex.game.clans.clans.potato.PotatoManager;
|
||||
import mineplex.game.clans.clans.pvptimer.PvpTimer;
|
||||
@ -98,6 +95,7 @@ import mineplex.game.clans.clans.stuck.StuckManager;
|
||||
import mineplex.game.clans.clans.supplyDrop.SupplyDropManager;
|
||||
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
|
||||
import mineplex.game.clans.clans.war.WarManager;
|
||||
import mineplex.game.clans.clans.warpoints.WarPointEvasion;
|
||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||
import mineplex.game.clans.core.ClanDeleteCommand;
|
||||
import mineplex.game.clans.core.ClanLoadCommand;
|
||||
@ -183,7 +181,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
private NpcManager _npcManager;
|
||||
private Explosion _explosion;
|
||||
private GoldManager _goldManager;
|
||||
|
||||
private WarPointEvasion _warPointEvasion;
|
||||
private ObserverManager _observerManager;
|
||||
private Punish _punish;
|
||||
|
||||
private int _inviteExpire = 2;
|
||||
@ -200,6 +199,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
// private NautHashMap<String, ClanInfo> _clanMemberNameMap = new
|
||||
// NautHashMap<String, ClanInfo>();
|
||||
private NautHashMap<UUID, ClanInfo> _clanMemberUuidMap = new NautHashMap<UUID, ClanInfo>();
|
||||
private NautHashMap<UUID, Pair<ClanInfo, Long>> _clanMemberLeftMap = new NautHashMap<>();
|
||||
private NautHashMap<String, ClanTerritory> _claimMap = new NautHashMap<String, ClanTerritory>();
|
||||
private NautHashMap<String, Long> _unclaimMap = new NautHashMap<String, Long>();
|
||||
|
||||
@ -213,11 +213,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
||||
if (serverName.equals("GarboClans-1"))
|
||||
{
|
||||
addCommand(new Meow(new OutpostManager(this)));
|
||||
}
|
||||
|
||||
_instance = this;
|
||||
|
||||
_punish = punish;
|
||||
@ -259,9 +254,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
_itemMapManager = new ItemMapManager(this, _worldEvent);
|
||||
new TntGeneratorManager(plugin, this);
|
||||
new SupplyDropManager(plugin, this);
|
||||
|
||||
_explosion = new Explosion(plugin, blockRestore);
|
||||
|
||||
_warPointEvasion = new WarPointEvasion(plugin);
|
||||
|
||||
// new ClansLoginManager(getPlugin(), clientManager, _serverName);
|
||||
|
||||
_clanShop = new ClanShop(this, clientManager, donationManager);
|
||||
@ -276,7 +271,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
new Spawn(plugin, this);
|
||||
new NPCManager(this, _hologramManager);
|
||||
new SafeLog(plugin, this);
|
||||
new ObserverManager(plugin, _condition, this);
|
||||
_observerManager = new ObserverManager(plugin, _condition, this);
|
||||
|
||||
new ClanEnergyTracker(plugin, this);
|
||||
new StuckManager(this);
|
||||
@ -608,6 +603,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
player.setOp(true);
|
||||
}
|
||||
if(player.getInventory().getHelmet() != null) { //Reset helmet to fix 1 damage bug
|
||||
ItemStack helmet = player.getInventory().getHelmet().clone();
|
||||
player.getInventory().setHelmet(null);
|
||||
runSyncLater(() -> {
|
||||
player.getInventory().setHelmet(helmet);
|
||||
}, 20L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -743,23 +745,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void handlePlayerChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
event.setCancelled(false);
|
||||
|
||||
_chat.HandleChat(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
// PunishClient punishclient = _punish.GetClient(event.getPlayer().getName());
|
||||
//
|
||||
// if (punishclient != null && punishclient.IsMuted())
|
||||
@ -808,7 +796,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
handleRegularChat(event, clan, rank);
|
||||
}
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
System.out.println((clan == null ? "" : clan.getName()) + " " + _clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + event.getMessage());
|
||||
}
|
||||
|
||||
@ -1160,4 +1150,32 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
ClansPlayerDeathEvent clansPlayerDeathEvent = new ClansPlayerDeathEvent(event, playerClan, killerClan);
|
||||
Bukkit.getServer().getPluginManager().callEvent(clansPlayerDeathEvent);
|
||||
}
|
||||
|
||||
public void justLeft(UUID uniqueId, ClanInfo clan)
|
||||
{
|
||||
_clanMemberLeftMap.put(uniqueId, Pair.create(clan, System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
public void resetLeftTimer(UUID uuid)
|
||||
{
|
||||
_clanMemberLeftMap.remove(uuid);
|
||||
_warPointEvasion.resetCooldown(uuid);
|
||||
|
||||
}
|
||||
|
||||
public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time)
|
||||
{
|
||||
if (_clanMemberLeftMap.containsKey(uniqueId) && (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()) <= time)
|
||||
{
|
||||
return Pair.create(_clanMemberLeftMap.get(uniqueId).getLeft(), time - (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ObserverManager getObserverManager()
|
||||
{
|
||||
return _observerManager;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -632,6 +632,8 @@ public class ClansUtility
|
||||
// Inform
|
||||
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
|
||||
clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
|
||||
|
||||
clan.left(caller.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -677,8 +679,8 @@ public class ClansUtility
|
||||
if (!data)
|
||||
{
|
||||
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request. Try again later"));
|
||||
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You disbanded your Clan."));
|
||||
}
|
||||
|
@ -6,20 +6,21 @@ import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NonFinalInteger;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnBoolean;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnTimestamp;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnBoolean;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnTimestamp;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class ClansBanRepository extends RepositoryBase
|
||||
public class ClansBanRepository extends MinecraftRepository
|
||||
{
|
||||
private ClansBanManager _manager;
|
||||
|
||||
|
@ -1,10 +1,17 @@
|
||||
package mineplex.game.clans.clans.commands;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
@ -13,6 +20,7 @@ import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilInput;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
@ -30,6 +38,7 @@ import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ClientClan;
|
||||
import mineplex.game.clans.clans.event.ClanJoinEvent;
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import net.minecraft.server.v1_8_R3.EnumDirection;
|
||||
|
||||
public class ClansCommand extends CommandBase<ClansManager>
|
||||
@ -105,6 +114,8 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
else if (args[0].equalsIgnoreCase("sethome"))
|
||||
homeSet(caller);
|
||||
else if (args[0].equalsIgnoreCase("stuck"))
|
||||
stuck(caller);
|
||||
|
||||
/*
|
||||
* else if (args[0].equalsIgnoreCase("enemy") || args[0].equals("e"))
|
||||
@ -211,6 +222,8 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c map <toggle>", "View Clan Map", Rank.ALL));
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL));
|
||||
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c stuck", "Teleports you to the nearest Wilderness location", Rank.ALL));
|
||||
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c promote <player>", "Promote Player in Clan", Rank.MODERATOR));
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c demote <player>", "Demote Player in Clan", Rank.MODERATOR));
|
||||
|
||||
@ -242,6 +255,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
return;
|
||||
}
|
||||
|
||||
if (Plugin.leftRecently(caller.getUniqueId(), 5 * 60 * 1000) != null)
|
||||
{
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot create a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + "."));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO if (!client.canJoin()) { _manager.getTutorials().sendTutorialMsg(caller,
|
||||
* F.main("Clans", "You cannot join a Clan for " + C.mTime +
|
||||
@ -344,6 +363,83 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
Plugin.getClanUtility().invite(caller, clan, target);
|
||||
}
|
||||
|
||||
public void stuck(final Player caller)
|
||||
{
|
||||
ClanTerritory territory = Plugin.getClanUtility().getClaim(caller.getLocation());
|
||||
|
||||
String clanName = Plugin.getClanUtility().getClanByPlayer(caller) == null ? null : Plugin.getClanUtility().getClanByPlayer(caller).getName();
|
||||
|
||||
if (territory == null || territory.Safe || territory.Owner.equals(clanName))
|
||||
{
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must be in another Clan's territory to use this."));
|
||||
return;
|
||||
}
|
||||
|
||||
DelayedTask.Instance.doDelay(caller, "Wilderness Teleport", new Callback<DelayedTaskClient>() {
|
||||
public void run(DelayedTaskClient player)
|
||||
{
|
||||
// Do
|
||||
|
||||
Location loc = getWildLoc(player.getPlayer().getLocation());
|
||||
|
||||
if (loc == null)
|
||||
{
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error whilst finding location to teleport to."));
|
||||
return;
|
||||
}
|
||||
|
||||
player.getPlayer().teleport(loc);
|
||||
|
||||
// Inform
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have been teleported to the Wilderness."));
|
||||
}
|
||||
}, new Callback<DelayedTaskClient>() {
|
||||
public void run(DelayedTaskClient client)
|
||||
{
|
||||
UtilTextMiddle.display("", "Teleporting to Wilderness in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Wilderness Teleport")))), 0, 5, 0, client.getPlayer());
|
||||
}
|
||||
}, new Callback<DelayedTaskClient>() {
|
||||
public void run(DelayedTaskClient client)
|
||||
{
|
||||
UtilPlayer.message(client.getPlayer(), F.main("Clans", "Teleport has been cancelled due to movement."));
|
||||
}
|
||||
}, 2 * 60 * 1000, false);
|
||||
|
||||
}
|
||||
|
||||
public Location getWildLoc(Location origin)
|
||||
{
|
||||
Chunk wildLoc = origin.getChunk();
|
||||
|
||||
List<Chunk> worldChunks = Lists.newArrayList(origin.getWorld().getLoadedChunks());
|
||||
|
||||
Collections.sort(
|
||||
worldChunks,
|
||||
(c1, c2) ->
|
||||
(int) ((int)
|
||||
origin.distance(
|
||||
UtilBlock.getHighest(origin.getWorld(),
|
||||
c1.getBlock(7, origin.getBlockY(), 7).getLocation()
|
||||
).getLocation())
|
||||
-
|
||||
origin.distance(
|
||||
UtilBlock.getHighest(origin.getWorld(),
|
||||
c2.getBlock(7, origin.getBlockY(), 7).getLocation()
|
||||
).getLocation())
|
||||
)
|
||||
);
|
||||
|
||||
for (Chunk chunk : worldChunks)
|
||||
{
|
||||
if (Plugin.getClanUtility().getClaim(chunk) == null)
|
||||
{
|
||||
return chunk.getBlock(6, UtilBlock.getHighest(origin.getWorld(), chunk.getBlock(6, 0, 6).getLocation()).getY(), 6).getLocation();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void join(final Player caller, String[] args)
|
||||
{
|
||||
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
|
||||
@ -352,6 +448,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
return;
|
||||
}
|
||||
|
||||
if (Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000) != null)
|
||||
{
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + "."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Plugin.Get(caller).canJoin())
|
||||
{
|
||||
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + "."));
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -106,6 +107,17 @@ public class ObserverManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent event)
|
||||
{
|
||||
ObserverData data = _observerMap.get(event.getPlayer());
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
if (!data.getSettings().contains(ObserverSettings.CAN_BREAK_BLOCKS))
|
||||
event.setCancelled(true);
|
||||
} }
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ public enum ObserverSettings
|
||||
public static EnumSet<ObserverSettings> getSettings(Rank rank)
|
||||
{
|
||||
if (rank.has(Rank.DEVELOPER))
|
||||
return EnumSet.of(CAN_OPEN_CHESTS);
|
||||
return EnumSet.of(CAN_OPEN_CHESTS, CAN_BREAK_BLOCKS);
|
||||
|
||||
return EnumSet.noneOf(ObserverSettings.class);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
@ -167,42 +168,60 @@ public class TntGeneratorManager extends MiniPlugin
|
||||
ClanInfo clan = getGenerator(event.getClickedBlock());
|
||||
if (clan != null)
|
||||
{
|
||||
final TntGenerator generator = clan.getGenerator();
|
||||
final int stock = generator.getStock();
|
||||
|
||||
if (stock > 0)
|
||||
{
|
||||
generator.setStock(stock - 1);
|
||||
_clansManager.getClanDataAccess().updateGenerator(clan, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
updateBrewingStand(generator);
|
||||
dropItem(event.getClickedBlock(), new ItemStack(Material.TNT));
|
||||
}
|
||||
else
|
||||
{
|
||||
// failed
|
||||
generator.setStock(stock);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
int secondLeft = SECONDS_PER_TNT - generator.getTicks();
|
||||
int msLeft = secondLeft * 1000;
|
||||
UtilTextMiddle.display("", C.cRed + "Next TNT in " + C.cGold + UtilTime.convertString(msLeft, 1, UtilTime.TimeUnit.FIT), event.getPlayer());
|
||||
}
|
||||
interact(clan, event.getPlayer());
|
||||
}else { //fix tnt gen issues
|
||||
//Can only place one of these in a clan location. so it must be a generator
|
||||
ClanInfo owner = _clansManager.getClanUtility().getOwner(event.getClickedBlock().getLocation());
|
||||
if(owner == null) return; //Wilderness
|
||||
TntGenerator generator = owner.getGenerator();
|
||||
System.out.println("Unable to find generator");
|
||||
//Create generator if not exist
|
||||
if(generator == null || !generator.getBlock().equals(event.getClickedBlock())) {
|
||||
generator = new TntGenerator(event.getClickedBlock());
|
||||
generator.setStock(2);
|
||||
clan.setGenerator(generator);
|
||||
_clansManager.getClanDataAccess().updateGenerator(clan, null);
|
||||
}
|
||||
interact(owner, event.getPlayer());
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void interact(ClanInfo clan, Player player) {
|
||||
final TntGenerator generator = clan.getGenerator();
|
||||
final int stock = generator.getStock();
|
||||
|
||||
if (stock > 0)
|
||||
{
|
||||
generator.setStock(stock - 1);
|
||||
_clansManager.getClanDataAccess().updateGenerator(clan, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
updateBrewingStand(generator);
|
||||
dropItem(generator.getBlock(), new ItemStack(Material.TNT));
|
||||
}
|
||||
else
|
||||
{
|
||||
// failed
|
||||
generator.setStock(stock);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
int secondLeft = SECONDS_PER_TNT - generator.getTicks();
|
||||
int msLeft = secondLeft * 1000;
|
||||
UtilTextMiddle.display("", C.cRed + "Next TNT in " + C.cGold + UtilTime.convertString(msLeft, 1, UtilTime.TimeUnit.FIT), player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDelete(ClanDeleteEvent event)
|
||||
{
|
||||
|
@ -25,9 +25,9 @@ import mineplex.core.scoreboard.elements.ScoreboardElement;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ClansUtility;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
|
||||
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
|
||||
import mineplex.game.clans.clans.war.command.WarPointsCommand;
|
||||
@ -38,7 +38,7 @@ import mineplex.game.clans.core.war.ClanWarData;
|
||||
public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||
{
|
||||
public static final int WAR_START_POINTS = 0;
|
||||
public static final int WAR_FINISH_POINTS = 20;
|
||||
public static final int WAR_FINISH_POINTS = 25;
|
||||
public static final long INVADE_LENGTH = 60000L * 30; // 30 Minutes
|
||||
public static final long WAR_COOLDOWN = 60000L * 30; // 30 Minutes
|
||||
|
||||
@ -117,11 +117,18 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
|
||||
@EventHandler
|
||||
public void handleDeath(final ClansPlayerDeathEvent event)
|
||||
{
|
||||
if (event.getPlayer() != null && event.getPlayer().getClan() != null)
|
||||
ClanInfo deathClan = event.getPlayer().getClan();
|
||||
|
||||
if (deathClan == null)
|
||||
{
|
||||
deathClan = _clansManager.leftRecently(event.getPlayer().getPlayer().getUniqueId(), 60000) == null ? deathClan : _clansManager.leftRecently(event.getPlayer().getPlayer().getUniqueId(), 60000).getLeft();
|
||||
}
|
||||
|
||||
if (event.getPlayer() != null && deathClan != null)
|
||||
{
|
||||
if (event.getKiller() != null && event.getKiller().getClan() != null)
|
||||
{
|
||||
final ClanInfo clan = event.getPlayer().getClan();
|
||||
final ClanInfo clan = deathClan;
|
||||
final ClanInfo killerClan = event.getKiller().getClan();
|
||||
|
||||
ClanWarData war = clan.getWarData(killerClan);
|
||||
|
@ -0,0 +1,93 @@
|
||||
package mineplex.game.clans.clans.warpoints;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class WarPointEvasion extends MiniPlugin{
|
||||
private HashMap<Chunk, Long> _chunkCooldown;
|
||||
private HashMap<UUID, Long> _playerCooldown;
|
||||
|
||||
private final long COOLDOWN_TIME = 1000 * 60 * 10;
|
||||
|
||||
public WarPointEvasion(JavaPlugin plugin) {
|
||||
super("WP Evasion", plugin);
|
||||
_chunkCooldown = Maps.newHashMap();
|
||||
_playerCooldown = Maps.newHashMap();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateCooldown(UpdateEvent event) {
|
||||
if(!event.getType().equals(UpdateType.SEC)) return;
|
||||
|
||||
_chunkCooldown.keySet().stream().filter(chunk -> UtilTime.elapsed(_chunkCooldown.get(chunk), COOLDOWN_TIME)).forEach(chunk -> _chunkCooldown.remove(chunk));
|
||||
|
||||
_playerCooldown.keySet().stream().filter(player -> UtilTime.elapsed(_playerCooldown.get(player), COOLDOWN_TIME)).forEach(player -> {
|
||||
_playerCooldown.remove(player);
|
||||
if(Bukkit.getOfflinePlayer(player).isOnline()) {
|
||||
if(ClansManager.getInstance().getClan(Bukkit.getPlayer(player)) == null) {
|
||||
Bukkit.getPlayer(player).sendMessage(F.main("Clans", "You can now create a clan."));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClaim(PlayerPreClaimTerritoryEvent event) {
|
||||
Chunk chunk = event.getClaimedChunk();
|
||||
if(_chunkCooldown.containsKey(chunk)) {
|
||||
event.setCancelled(true);
|
||||
event.getClaimer().sendMessage(F.main("Clans", "You cannot claim this chunk for another " + UtilTime.convertString(COOLDOWN_TIME - (System.currentTimeMillis() - _chunkCooldown.get(chunk)), 1, UtilTime.TimeUnit.MINUTES)));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onunClaim(PlayerUnClaimTerritoryEvent event) {
|
||||
Chunk chunk = event.getUnClaimedChunk();
|
||||
_chunkCooldown.put(chunk, System.currentTimeMillis());
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClanDisband(ClanDisbandedEvent event) {
|
||||
_playerCooldown.put(event.getDisbander().getUniqueId(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClanLeave(ClanLeaveEvent event) {
|
||||
_playerCooldown.put(event.getPlayer().getUuid(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onClanCreate(ClanCreatedEvent event) {
|
||||
if (event.getFounder() == null)
|
||||
return;
|
||||
|
||||
if (_playerCooldown.containsKey(event.getFounder().getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
event.getFounder().sendMessage(F.main("Clans", "You cannot create a clan for another " + UtilTime.convertString(COOLDOWN_TIME - (System.currentTimeMillis() - _playerCooldown.get(event.getFounder().getUniqueId())), 1, UtilTime.TimeUnit.MINUTES)));
|
||||
}
|
||||
}
|
||||
|
||||
public void resetCooldown(UUID uuid)
|
||||
{
|
||||
_playerCooldown.remove(uuid);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -474,6 +475,7 @@ public class UndeadCamp extends WorldEvent
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onChestOpen(PlayerInteractEvent event)
|
||||
{
|
||||
if(ClansManager.getInstance().getObserverManager().isObserver(event.getPlayer())) return;;
|
||||
Block block = event.getClickedBlock();
|
||||
if (_containers.contains(block))
|
||||
{
|
||||
|
@ -5,17 +5,18 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnByte;
|
||||
import mineplex.core.database.column.ColumnDouble;
|
||||
import mineplex.core.database.column.ColumnInt;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnByte;
|
||||
import mineplex.serverdata.database.column.ColumnDouble;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class FieldRepository extends RepositoryBase
|
||||
public class FieldRepository extends MinecraftRepository
|
||||
{
|
||||
private static String ALL_STRING = "ALL";
|
||||
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -40,6 +41,7 @@ import org.bukkit.event.player.PlayerFishEvent.State;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.Dye;
|
||||
@ -253,7 +255,7 @@ public class Gameplay extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void RedstoneCancel(BlockPlaceEvent event)
|
||||
{
|
||||
@ -263,7 +265,25 @@ public class Gameplay extends MiniPlugin
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void MaxHeight(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.getBlock().getLocation().getBlockY() > 100)
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place blocks this high."));
|
||||
event.setCancelled(true);
|
||||
} else if(event.getBlock().getLocation().getBlockY() == 99 && event.getBlock().getType().name().contains("DOOR") && !event.getBlock().getType().equals(Material.TRAP_DOOR)) {
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place blocks this high."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void GrowTree(StructureGrowEvent event) {
|
||||
event.getBlocks().stream().filter(blockState -> blockState.getLocation().getBlockY() > 100).forEach(blockState -> blockState.setType(Material.AIR) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable all Piston related events in Clans
|
||||
*
|
||||
@ -449,6 +469,7 @@ public class Gameplay extends MiniPlugin
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void disableSaplings(BlockPlaceEvent event)
|
||||
{
|
||||
if(event.isCancelled()) return; //Can't place this block
|
||||
if (!event.getItemInHand().getType().equals(Material.SAPLING))
|
||||
{
|
||||
return;
|
||||
|
@ -130,7 +130,10 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
|
||||
// TODO: Introduce configurable non-hardcoded values for generation
|
||||
// weights?
|
||||
_attributeWeights = new WeightSet<Integer>(new Weight<Integer>(3, 3), new Weight<Integer>(20, 2), new Weight<Integer>(77, 1));
|
||||
_typeWeights = new WeightSet<ItemType>(new Weight<ItemType>(10, ItemType.LEGENDARY), new Weight<ItemType>(45, ItemType.ARMOR), new Weight<ItemType>(23, ItemType.WEAPON), new Weight<ItemType>(22, ItemType.BOW));
|
||||
_typeWeights = new WeightSet<ItemType>(new Weight<ItemType>(6, ItemType.LEGENDARY),
|
||||
new Weight<ItemType>(46, ItemType.ARMOR),
|
||||
new Weight<ItemType>(25, ItemType.WEAPON),
|
||||
new Weight<ItemType>(23, ItemType.BOW));
|
||||
|
||||
// Weapon-based attributes
|
||||
_weaponAttributes = new WeightSet<Class<? extends ItemAttribute>>(FrostedAttribute.class, SharpAttribute.class, JaggedAttribute.class, HasteAttribute.class, FlamingAttribute.class, ConqueringAttribute.class);
|
||||
|
@ -30,6 +30,7 @@ public abstract class AttackAttribute extends ItemAttribute
|
||||
@Override
|
||||
public void onAttack(CustomDamageEvent event)
|
||||
{
|
||||
if(event.IsCancelled() || event.isCancelled()) return;
|
||||
_attackCount++;
|
||||
System.out.println("Attack count " + _attackCount + " - " + _attackLimit);
|
||||
if (_attackCount >= _attackLimit)
|
||||
|
@ -1,10 +1,14 @@
|
||||
package mineplex.game.clans.items.attributes.weapon;
|
||||
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.gui.page.ClanMainPage;
|
||||
import mineplex.game.clans.items.attributes.AttackAttribute;
|
||||
import mineplex.game.clans.items.attributes.AttributeType;
|
||||
import mineplex.game.clans.items.generation.ValueDistribution;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class FlamingAttribute extends AttackAttribute
|
||||
{
|
||||
@ -34,6 +38,9 @@ public class FlamingAttribute extends AttackAttribute
|
||||
@Override
|
||||
public void triggerAttack(Entity attacker, Entity defender)
|
||||
{
|
||||
if(attacker instanceof Player && ClansManager.getInstance().isSafe((Player) attacker)) return;
|
||||
if(defender instanceof Player && ClansManager.getInstance().isSafe((Player) defender)) return;
|
||||
if(attacker instanceof Player && ((Player)attacker).getGameMode().equals(GameMode.CREATIVE)) return;
|
||||
defender.setFireTicks(_fireDuration);
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,9 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class GiantsBroadsword extends LegendaryItem
|
||||
{
|
||||
public static final int SLOW_AMPLIFIER = 4;
|
||||
public static final int REGEN_AMPLIFIER = 1;
|
||||
public static final int EFFECT_DURATION = 10; // Duration of potion effect
|
||||
// (in ticks)
|
||||
|
||||
public static final int SLOW_AMPLIFIER = 43;
|
||||
public static final int REGEN_AMPLIFIER = 3;
|
||||
|
||||
public GiantsBroadsword()
|
||||
{
|
||||
super("Giants Broadsword", new String[]{
|
||||
@ -34,15 +32,14 @@ public class GiantsBroadsword extends LegendaryItem
|
||||
@Override
|
||||
public void update(Player wielder)
|
||||
{
|
||||
if (isHoldingRightClick())
|
||||
{
|
||||
if (isHoldingRightClick()) {
|
||||
buffPlayer(wielder);
|
||||
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.HEART, wielder.getEyeLocation().add(0, 0.25, 0), -.5f + (float) Math.random(), -.5f + (float) Math.random(), -.5f + (float) Math.random(), .2f, 1, ViewDist.NORMAL);
|
||||
wielder.playSound(wielder.getLocation(), Sound.LAVA_POP, 1f, 2f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
UtilParticle.PlayParticle(ParticleType.MAGIC_CRIT, wielder.getLocation().add(0, 1, 0), 0, 0, 0, .2f, 3, ViewDist.NORMAL);
|
||||
}
|
||||
|
||||
@ -62,7 +59,7 @@ public class GiantsBroadsword extends LegendaryItem
|
||||
|
||||
private void buffPlayer(Player player)
|
||||
{
|
||||
grantPotionEffect(player, PotionEffectType.SLOW, 40, 43);
|
||||
grantPotionEffect(player, PotionEffectType.REGENERATION, 2, 43);
|
||||
grantPotionEffect(player, PotionEffectType.SLOW, 40, SLOW_AMPLIFIER);
|
||||
grantPotionEffect(player, PotionEffectType.REGENERATION, 40, REGEN_AMPLIFIER); //Regen
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ public class LegendaryItem extends CustomItem
|
||||
*/
|
||||
public static void grantPotionEffect(Player player, PotionEffectType type, int tickDuration, int amplifier)
|
||||
{
|
||||
player.removePotionEffect(type);
|
||||
player.addPotionEffect(new PotionEffect(type, amplifier, tickDuration));
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,12 @@
|
||||
package mineplex.hub;
|
||||
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.database.DBPool;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
|
||||
public class HubRepository
|
||||
{
|
||||
|
@ -4,10 +4,11 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.database.Tables;
|
||||
import mineplex.database.tables.records.MailRecord;
|
||||
|
||||
@ -15,7 +16,7 @@ import org.jooq.DSLContext;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
public class MailRepository extends RepositoryBase
|
||||
public class MailRepository extends MinecraftRepository
|
||||
{
|
||||
private MailManager _manager;
|
||||
|
||||
|
@ -1,14 +1,12 @@
|
||||
package mineplex.hub.queue;
|
||||
|
||||
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 mineplex.core.common.util.C;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
|
||||
public class QueueRepository
|
||||
{
|
||||
|
@ -16,6 +16,14 @@
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-dbcp2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database;
|
||||
package mineplex.serverdata.database;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@ -6,21 +6,18 @@ import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
||||
import mineplex.serverdata.redis.RedisConfig;
|
||||
import mineplex.serverdata.servers.ConnectionData;
|
||||
import mineplex.serverdata.servers.ConnectionData.ConnectionType;
|
||||
|
||||
public final class DBPool
|
||||
{
|
||||
private static DataSource ACCOUNT;
|
||||
private static DataSource QUEUE;
|
||||
private static DataSource MINEPLEX;
|
||||
private static DataSource STATS_MINEPLEX;
|
||||
private static DataSource MINEPLEX_STATS;
|
||||
private static DataSource PLAYER_STATS;
|
||||
private static DataSource SERVER_STATS;
|
||||
|
||||
private static DataSource openDataSource(String url, String username, String password)
|
||||
{
|
||||
@ -64,12 +61,25 @@ public final class DBPool
|
||||
return MINEPLEX;
|
||||
}
|
||||
|
||||
public static DataSource getStats()
|
||||
public static DataSource getMineplexStats()
|
||||
{
|
||||
if (STATS_MINEPLEX == null)
|
||||
if (MINEPLEX_STATS == null)
|
||||
loadDataSources();
|
||||
|
||||
return STATS_MINEPLEX;
|
||||
return MINEPLEX_STATS;
|
||||
}
|
||||
|
||||
public static DataSource getPlayerStats()
|
||||
{
|
||||
if (PLAYER_STATS == null)
|
||||
loadDataSources();
|
||||
|
||||
return PLAYER_STATS;
|
||||
}
|
||||
|
||||
public static DataSource getServerStats()
|
||||
{
|
||||
return SERVER_STATS;
|
||||
}
|
||||
|
||||
private static void loadDataSources()
|
||||
@ -110,7 +120,7 @@ public final class DBPool
|
||||
String userName = args[2];
|
||||
String password = args[3];
|
||||
|
||||
System.out.println(dbSource + " " + dbHost + " " + userName + " " + password);
|
||||
// System.out.println(dbSource + " " + dbHost + " " + userName + " " + password);
|
||||
|
||||
if (dbSource.toUpperCase().equalsIgnoreCase("ACCOUNT"))
|
||||
ACCOUNT = openDataSource("jdbc:mysql://" + dbHost, userName, password);
|
||||
@ -118,8 +128,12 @@ public final class DBPool
|
||||
QUEUE = openDataSource("jdbc:mysql://" + dbHost, userName, password);
|
||||
else if (dbSource.toUpperCase().equalsIgnoreCase("MINEPLEX"))
|
||||
MINEPLEX = openDataSource("jdbc:mysql://" + dbHost, userName, password);
|
||||
else if (dbSource.toUpperCase().equalsIgnoreCase("STATS"))
|
||||
STATS_MINEPLEX = openDataSource("jdbc:mysql://" + dbHost, userName, password);
|
||||
else if (dbSource.toUpperCase().equalsIgnoreCase("MINEPLEX_STATS"))
|
||||
MINEPLEX_STATS = openDataSource("jdbc:mysql://" + dbHost, userName, password);
|
||||
else if (dbSource.toUpperCase().equalsIgnoreCase("PLAYER_STATS"))
|
||||
PLAYER_STATS = openDataSource("jdbc:mysql://" + dbHost, userName, password);
|
||||
else if (dbSource.toUpperCase().equalsIgnoreCase("SERVER_STATS"))
|
||||
SERVER_STATS = openDataSource("jdbc:mysql://" + dbHost, userName, password);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database;
|
||||
package mineplex.serverdata.database;
|
||||
|
||||
public class DatabaseRunnable
|
||||
{
|
@ -1,57 +1,42 @@
|
||||
package mineplex.core.database;
|
||||
package mineplex.serverdata.database;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
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;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.impl.DSL;
|
||||
import mineplex.serverdata.database.column.Column;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class RepositoryBase implements Listener
|
||||
public abstract class RepositoryBase
|
||||
{
|
||||
// Queue for failed processes
|
||||
private static Object _queueLock = new Object();
|
||||
private NautHashMap<DatabaseRunnable, String> _failedQueue = new NautHashMap<DatabaseRunnable, String>();
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private DataSource _dataSource; // Connection pool
|
||||
protected JavaPlugin Plugin; // Plugin responsible for this repository
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param plugin - the {@link JavaPlugin} module responsible for this repository.
|
||||
* @param dataSource - the {@link DataSource} responsible for providing the connection pool to this repository.
|
||||
*/
|
||||
public RepositoryBase(JavaPlugin plugin, DataSource dataSource)
|
||||
public RepositoryBase(DataSource dataSource)
|
||||
{
|
||||
Plugin = plugin;
|
||||
_dataSource = dataSource;
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
initialize();
|
||||
update();
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
new Thread(() -> {
|
||||
initialize();
|
||||
update();
|
||||
}).start();
|
||||
}
|
||||
|
||||
protected abstract void initialize();
|
||||
@ -66,11 +51,6 @@ public abstract class RepositoryBase implements Listener
|
||||
return _dataSource;
|
||||
}
|
||||
|
||||
protected DSLContext jooq()
|
||||
{
|
||||
return DSL.using(DBPool.getAccount(), SQLDialect.MYSQL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requirements: {@link Connection}s must be closed after usage so they may be returned to the pool!
|
||||
* @see Connection#close()
|
||||
@ -178,58 +158,4 @@ public abstract class RepositoryBase implements Listener
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleDatabaseCall(final DatabaseRunnable databaseRunnable, final String errorMessage)
|
||||
{
|
||||
Thread asyncThread = new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
databaseRunnable.run();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
processFailedDatabaseCall(databaseRunnable, exception.getMessage(), errorMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
asyncThread.start();
|
||||
}
|
||||
|
||||
protected void processFailedDatabaseCall(DatabaseRunnable databaseRunnable, String errorPreMessage, String runnableMessage)
|
||||
{
|
||||
if (databaseRunnable.getFailedCounts() < 4)
|
||||
{
|
||||
databaseRunnable.incrementFailCount();
|
||||
|
||||
synchronized (_queueLock)
|
||||
{
|
||||
_failedQueue.put(databaseRunnable, runnableMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void processDatabaseQueue(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.MIN_01)
|
||||
return;
|
||||
|
||||
processFailedQueue();
|
||||
}
|
||||
|
||||
private void processFailedQueue()
|
||||
{
|
||||
synchronized (_queueLock)
|
||||
{
|
||||
for (Iterator<DatabaseRunnable> runnablesIterator = _failedQueue.keySet().iterator(); runnablesIterator.hasNext();)
|
||||
{
|
||||
DatabaseRunnable databaseRunnable = runnablesIterator.next();
|
||||
handleDatabaseCall(databaseRunnable, _failedQueue.get(databaseRunnable));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database;
|
||||
package mineplex.serverdata.database;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database.column;
|
||||
package mineplex.serverdata.database.column;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database.column;
|
||||
package mineplex.serverdata.database.column;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database.column;
|
||||
package mineplex.serverdata.database.column;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database.column;
|
||||
package mineplex.serverdata.database.column;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database.column;
|
||||
package mineplex.serverdata.database.column;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database.column;
|
||||
package mineplex.serverdata.database.column;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database.column;
|
||||
package mineplex.serverdata.database.column;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.database.column;
|
||||
package mineplex.serverdata.database.column;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
@ -1,7 +1,6 @@
|
||||
package mineplex.servermonitor;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@ -14,15 +13,13 @@ import mineplex.serverdata.data.BungeeServer;
|
||||
import mineplex.serverdata.data.DataRepository;
|
||||
import mineplex.serverdata.data.DedicatedServer;
|
||||
import mineplex.serverdata.data.ServerGroup;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.redis.RedisDataRepository;
|
||||
import mineplex.serverdata.servers.ServerManager;
|
||||
|
||||
public class StatusHistoryRepository
|
||||
public class StatusHistoryRepository extends RepositoryBase
|
||||
{
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/ServerStats";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_GROUP_TABLE = "CREATE TABLE IF NOT EXISTS ServerGroupStats (id INT NOT NULL AUTO_INCREMENT, serverGroup VARCHAR(100), updated LONG, players INT, maxPlayers INT, totalNetworkCpuUsage DOUBLE(4,2), totalNetworkRamUsage DOUBLE(4,2), totalCpu MEDIUMINT, totalRam MEDIUMINT, US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));";
|
||||
private static String CREATE_DEDICATED_TABLE = "CREATE TABLE IF NOT EXISTS DedicatedServerStats (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(100), address VARCHAR(25), updated LONG, cpu TINYINT, ram MEDIUMINT, usedCpuPercent DOUBLE(4,2), usedRamPercent DOUBLE(4,2), US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));";
|
||||
private static String CREATE_BUNGEE_TABLE = "CREATE TABLE IF NOT EXISTS BungeeStats (id INT NOT NULL AUTO_INCREMENT, address VARCHAR(25), updated LONG, players INT, maxPlayers INT, alive BOOLEAN NOT NULL, online BOOLEAN NOT NULL, US BOOLEAN NOT NULL DEFAULT '1', PRIMARY KEY (id));";
|
||||
@ -33,38 +30,33 @@ public class StatusHistoryRepository
|
||||
private static String INSERT_BUNGEE_STATS = "INSERT INTO BungeeStats (address, updated, players, maxPlayers, alive, online, US) VALUES (?, now(), ?, ?, ?, ?, ?);";
|
||||
private static String INSERT_NETWORK_STATS = "INSERT INTO NetworkStats (updated, players, totalNetworkCpuUsage, totalNetworkRamUsage, totalCpu, totalRam, US) VALUES (now(), ?, ?, ?, ?, ?, ?);";
|
||||
|
||||
private static Connection _connection;
|
||||
|
||||
private static DataRepository<BungeeServer> _repository;
|
||||
|
||||
public StatusHistoryRepository()
|
||||
{
|
||||
super(DBPool.getServerStats());
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_GROUP_TABLE);
|
||||
preparedStatement = connection.prepareStatement(CREATE_GROUP_TABLE);
|
||||
preparedStatement.execute();
|
||||
preparedStatement.close();
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_DEDICATED_TABLE);
|
||||
preparedStatement = connection.prepareStatement(CREATE_DEDICATED_TABLE);
|
||||
preparedStatement.execute();
|
||||
preparedStatement.close();
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_BUNGEE_TABLE);
|
||||
preparedStatement = connection.prepareStatement(CREATE_BUNGEE_TABLE);
|
||||
preparedStatement.execute();
|
||||
preparedStatement.close();
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_NETWORKSTATS_TABLE);
|
||||
preparedStatement = connection.prepareStatement(CREATE_NETWORKSTATS_TABLE);
|
||||
preparedStatement.execute();
|
||||
preparedStatement.close();
|
||||
|
||||
@ -95,12 +87,9 @@ public class StatusHistoryRepository
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_SERVERGROUP_STATS);
|
||||
preparedStatement = connection.prepareStatement(INSERT_SERVERGROUP_STATS);
|
||||
|
||||
for (ServerGroup serverGroup : collection)
|
||||
{
|
||||
@ -144,12 +133,9 @@ public class StatusHistoryRepository
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_DEDICATEDSERVER_STATS);
|
||||
preparedStatement = connection.prepareStatement(INSERT_DEDICATEDSERVER_STATS);
|
||||
|
||||
for (DedicatedServer dedicatedServer : dedicatedServers)
|
||||
{
|
||||
@ -204,12 +190,9 @@ public class StatusHistoryRepository
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_BUNGEE_STATS);
|
||||
preparedStatement = connection.prepareStatement(INSERT_BUNGEE_STATS);
|
||||
|
||||
for (BungeeServer bungeeStatusData : bungeeServers)
|
||||
{
|
||||
@ -246,12 +229,9 @@ public class StatusHistoryRepository
|
||||
|
||||
preparedStatement = null;
|
||||
|
||||
try
|
||||
try(Connection connection = getConnection())
|
||||
{
|
||||
if (_connection == null || _connection.isClosed())
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_NETWORK_STATS);
|
||||
preparedStatement = connection.prepareStatement(INSERT_NETWORK_STATS);
|
||||
preparedStatement.setInt(1, totalPlayers);
|
||||
preparedStatement.setDouble(2, usedCpuPercent);
|
||||
preparedStatement.setDouble(3, usedRamPercent);
|
||||
@ -280,4 +260,16 @@ public class StatusHistoryRepository
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,15 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
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;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class PasswordRepository extends RepositoryBase
|
||||
public class PasswordRepository extends MinecraftRepository
|
||||
{
|
||||
private static String CREATE_SERVER_PASSWORD_TABLE = "CREATE TABLE IF NOT EXISTS serverPassword (id INT NOT NULL AUTO_INCREMENT, server VARCHAR(100), password VARCHAR(100), PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_SERVER_PASSWORD = "SELECT password FROM serverPassword WHERE server = ?;";
|
||||
|
@ -11,12 +11,11 @@ import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.bonuses.BonusAmount;
|
||||
import mineplex.core.bonuses.BonusClientData;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.bonuses.redis.VotifierCommand;
|
||||
import mineplex.database.Tables;
|
||||
|
@ -4,12 +4,13 @@ import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Types;
|
||||
|
||||
import mineplex.core.database.DBPool;
|
||||
import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.RepositoryBase;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class TitanGiveawayRepository extends RepositoryBase
|
||||
public class TitanGiveawayRepository extends MinecraftRepository
|
||||
{
|
||||
private int _titanGiveawayCount;
|
||||
|
||||
|
@ -77,6 +77,18 @@
|
||||
<version>1.4.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.14</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kencochrane.raven</groupId>
|
||||
<artifactId>raven</artifactId>
|
||||
<version>6.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kencochrane.raven</groupId>
|
||||
<artifactId>raven-log4j2</artifactId>
|
||||
|
Loading…
Reference in New Issue
Block a user