Merge branch '4.0.0-BungeeCord-Support' of https://github.com/Rsl1122/Plan-PlayerAnalytics

This commit is contained in:
Fuzzlemann 2017-09-03 01:40:46 +02:00
commit ec4e3cce91
35 changed files with 1018 additions and 317 deletions

View File

@ -144,7 +144,6 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
saveConfig(); saveConfig();
Benchmark.stop("Enable", "Copy default config"); Benchmark.stop("Enable", "Copy default config");
processingQueue = new ProcessingQueue();
Benchmark.start("Init Database"); Benchmark.start("Init Database");
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString()); Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
@ -159,6 +158,8 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
Log.error("WebServer was not successfully initialized."); Log.error("WebServer was not successfully initialized.");
} }
processingQueue = new ProcessingQueue();
serverInfoManager = new ServerInfoManager(this); serverInfoManager = new ServerInfoManager(this);
infoManager = new InformationManager(this); infoManager = new InformationManager(this);
webServer.setInfoManager(infoManager); webServer.setInfoManager(infoManager);

View File

@ -5,6 +5,7 @@ import com.djrapitops.plugin.command.ISender;
import com.djrapitops.plugin.command.SubCommand; import com.djrapitops.plugin.command.SubCommand;
import com.djrapitops.plugin.task.AbsRunnable; import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
@ -12,6 +13,8 @@ import main.java.com.djrapitops.plan.locale.Locale;
import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.locale.Msg;
import main.java.com.djrapitops.plan.utilities.Check; import main.java.com.djrapitops.plan.utilities.Check;
import java.sql.SQLException;
/** /**
* This manage subcommand is used to clear a database of all data. * This manage subcommand is used to clear a database of all data.
* *
@ -80,12 +83,12 @@ public class ManageClearCommand extends SubCommand {
try { try {
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse()); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
if (database.removeAllData()) { database.removeAllData();
// TODO Clear active session of all users & start new ones // TODO Clear active session of all users & start new ones
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_CLEAR_SUCCESS).toString()); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_CLEAR_SUCCESS).toString());
} else { } catch (SQLException e) {
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString()); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
} Log.toLog(this.getClass().getSimpleName() + "/" + this.getTaskName(), e);
} finally { } finally {
this.cancel(); this.cancel();
} }

View File

@ -85,11 +85,8 @@ public class ManageRemoveCommand extends SubCommand {
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse()); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
try { try {
// TODO Clear active session of user & start new one // TODO Clear active session of user & start new one
if (plugin.getDB().removeAccount(uuid)) { plugin.getDB().removeAccount(uuid);
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName())); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName()));
} else {
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
}
} catch (SQLException e) { } catch (SQLException e) {
Log.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString()); sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());

View File

@ -49,7 +49,7 @@ public class AnalysisData extends RawData {
joinInfoPart = new JoinInfoPart(); joinInfoPart = new JoinInfoPart();
playerCountPart = new PlayerCountPart(); playerCountPart = new PlayerCountPart();
playtimePart = new PlaytimePart(); playtimePart = new PlaytimePart();
killPart = new KillPart(); killPart = new KillPart(joinInfoPart);
tpsPart = new TPSPart(); tpsPart = new TPSPart();
activityPart = new ActivityPart(joinInfoPart, tpsPart); activityPart = new ActivityPart(joinInfoPart, tpsPart);
worldPart = new WorldPart(); worldPart = new WorldPart();

View File

@ -30,7 +30,7 @@ import java.util.stream.Collectors;
* ${playersNewAverageDay} - (Number) * ${playersNewAverageDay} - (Number)
* ${playersNewAverageWeek} - (Number) * ${playersNewAverageWeek} - (Number)
* ${playersNewAverageMonth} - (Number) * ${playersNewAverageMonth} - (Number)
* //TODO ${tableBodySessions}, ${sessionCount}, ${lastPeakTime}, ${playersLastPeak}, ${bestPeakTime}, ${playersBestPeak} * //TODO ${tableBodySessions}
* *
* @author Rsl1122 * @author Rsl1122
* @since 3.5.2 * @since 3.5.2

View File

@ -1,5 +1,13 @@
package main.java.com.djrapitops.plan.data.analysis; package main.java.com.djrapitops.plan.data.analysis;
import main.java.com.djrapitops.plan.data.PlayerKill;
import main.java.com.djrapitops.plan.data.Session;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/** /**
* Part responsible for all Death related analysis. * Part responsible for all Death related analysis.
* <p> * <p>
@ -15,43 +23,32 @@ package main.java.com.djrapitops.plan.data.analysis;
*/ */
public class KillPart extends RawData { public class KillPart extends RawData {
private final JoinInfoPart joinInfoPart;
private long playerKills; private long playerKills;
private long mobKills; private long mobKills;
private long deaths; private long deaths;
public KillPart() { public KillPart(JoinInfoPart joinInfoPart) {
this.joinInfoPart = joinInfoPart;
playerKills = 0; playerKills = 0;
mobKills = 0; mobKills = 0;
deaths = 0; deaths = 0;
} }
// TODO JoinInfo Part, sessions for kills.
@Override @Override
public void analyse() { public void analyse() {
addValue("deathCount", deaths); List<Session> sessions = joinInfoPart.getAllSessions();
deaths += sessions.stream().mapToLong(Session::getDeaths).sum();
mobKills += sessions.stream().mapToLong(Session::getMobKills).sum();
playerKills += sessions.stream().map(Session::getPlayerKills).mapToLong(Collection::size).sum();
addValue("deathCount", this.deaths);
addValue("mobKillCount", mobKills); addValue("mobKillCount", mobKills);
addValue("killCount", playerKills); addValue("killCount", playerKills);
} }
/**
* Adds kills to the dataset.
*
* @param amount amount of kills
* @throws IllegalArgumentException if kills is null
*/
public void addKills(long amount) {
playerKills += amount;
}
public void addMobKills(long amount) {
mobKills += amount;
}
public void addDeaths(long amount) {
deaths += amount;
}
public long getPlayerKills() { public long getPlayerKills() {
return playerKills; return playerKills;
} }
@ -63,4 +60,8 @@ public class KillPart extends RawData {
public long getDeaths() { public long getDeaths() {
return deaths; return deaths;
} }
public void addKills(Map<UUID, List<PlayerKill>> playerKills) {
this.playerKills += playerKills.values().stream().mapToLong(Collection::size).sum();
}
} }

View File

@ -13,8 +13,7 @@ import java.util.UUID;
* Placeholder values can be retrieved using the get method. * Placeholder values can be retrieved using the get method.
* <p> * <p>
* Contains following placeholders after analyzed: * Contains following placeholders after analyzed:
* ${playersTotal} * ${playersTotal}, ${ops}
* //TODO ${playersOnline}, ${playersMax}
* *
* @author Rsl1122 * @author Rsl1122
* @since 3.5.2 * @since 3.5.2
@ -31,6 +30,7 @@ public class PlayerCountPart extends RawData {
@Override @Override
public void analyse() { public void analyse() {
addValue("ops", ops.size());
addValue("playersTotal", uuids.size()); addValue("playersTotal", uuids.size());
} }

View File

@ -185,19 +185,18 @@ public abstract class Database {
* Removes all data related to an account from the database. * Removes all data related to an account from the database.
* *
* @param uuid UUID of the account. * @param uuid UUID of the account.
* @return Success of the removal.
* @throws SQLException If a database error occurs. * @throws SQLException If a database error occurs.
*/ */
public abstract boolean removeAccount(UUID uuid) throws SQLException; public abstract void removeAccount(UUID uuid) throws SQLException;
/** /**
* Used to clear all data from the database. * Used to clear all data from the database.
* <p> * <p>
* Uses DELETE * FROM table. * Uses DELETE * FROM table.
* *
* @return Success of removal. * @throws SQLException if remove fails.
*/ */
public abstract boolean removeAllData(); public abstract void removeAllData() throws SQLException;
/** /**
* Used to fetch the saved UUIDs in the users table. * Used to fetch the saved UUIDs in the users table.

View File

@ -1,5 +1,7 @@
package main.java.com.djrapitops.plan.database.databases; package main.java.com.djrapitops.plan.database.databases;
import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.task.AbsRunnable;
import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.api.IPlan; import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException; import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
@ -65,13 +67,28 @@ public abstract class SQLDB extends Database {
try { try {
setupDataSource(); setupDataSource();
setupDatabase(); setupDatabase();
clean(); scheduleClean(10L);
} finally { } finally {
Benchmark.stop("Database", benchName); Benchmark.stop("Database", benchName);
Log.logDebug("Database"); Log.logDebug("Database");
} }
} }
public void scheduleClean(long secondsDelay) {
plugin.getRunnableFactory().createNew(new AbsRunnable("DB Clean Task") {
@Override
public void run() {
try {
clean();
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);
} finally {
cancel();
}
}
}).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * secondsDelay);
}
/** /**
* Ensures connection functions correctly and all tables exist. * Ensures connection functions correctly and all tables exist.
* <p> * <p>
@ -200,9 +217,9 @@ public abstract class SQLDB extends Database {
} }
} }
public boolean removeAccount(UUID uuid) throws SQLException { public void removeAccount(UUID uuid) throws SQLException {
if (uuid == null) { if (uuid == null) {
return false; return;
} }
try { try {
@ -215,45 +232,30 @@ public abstract class SQLDB extends Database {
} }
UserIDTable table = (UserIDTable) t; UserIDTable table = (UserIDTable) t;
if (!table.removeUser(uuid)) { table.removeUser(uuid);
throw new IllegalStateException("Removal Failed");
} }
}
return true;
} catch (Exception e) {
Log.toLog(this.getClass().getName(), e);
return false;
} finally { } finally {
Benchmark.stop("Database", "Remove Account"); Benchmark.stop("Database", "Remove Account");
setAvailable(); setAvailable();
} }
} }
private void clean() throws DatabaseInitException { private void clean() throws SQLException {
Log.info("Cleaning the database."); Log.info("Cleaning the database.");
try {
tpsTable.clean(); tpsTable.clean();
Log.info("Clean complete."); Log.info("Clean complete.");
} catch (SQLException e) {
throw new DatabaseInitException("Database Clean failed", e);
}
} }
/** /**
* @return * @return
*/ */
@Override @Override
public boolean removeAllData() { public void removeAllData() throws SQLException {
setStatus("Clearing all data"); setStatus("Clearing all data");
try { try {
for (Table table : getAllTablesInRemoveOrder()) { for (Table table : getAllTablesInRemoveOrder()) {
if (!table.removeAllData()) { table.removeAllData();
return false;
} }
}
return true;
} finally { } finally {
setAvailable(); setAvailable();
} }

View File

@ -4,6 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.database.tables; package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.data.Action; import main.java.com.djrapitops.plan.data.Action;
@ -15,9 +16,7 @@ import main.java.com.djrapitops.plan.database.sql.TableSqlParser;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.UUID;
/** /**
* Table that is in charge of storing actions. * Table that is in charge of storing actions.
@ -41,10 +40,21 @@ public class ActionsTable extends UserIDTable {
private final String columnAdditionalInfo = "additional_info"; private final String columnAdditionalInfo = "additional_info";
private final ServerTable serverTable; private final ServerTable serverTable;
private String insertStatement;
public ActionsTable(SQLDB db, boolean usingMySQL) { public ActionsTable(SQLDB db, boolean usingMySQL) {
super("plan_actions", db, usingMySQL); super("plan_actions", db, usingMySQL);
serverTable = db.getServerTable(); serverTable = db.getServerTable();
insertStatement = "INSERT INTO " + tableName + " ("
+ columnUserID + ", "
+ columnServerID + ", "
+ columnActionID + ", "
+ columnDate + ", "
+ columnAdditionalInfo
+ ") VALUES ("
+ usersTable.statementSelectID + ", "
+ serverTable.statementSelectServerID + ", "
+ "?, ?, ?)";
} }
@Override @Override
@ -64,17 +74,8 @@ public class ActionsTable extends UserIDTable {
public void insertAction(UUID uuid, Action action) throws SQLException { public void insertAction(UUID uuid, Action action) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = prepareStatement("INSERT INTO " + tableName + " ("
+ columnUserID + ", " statement = prepareStatement(insertStatement);
+ columnServerID + ", "
+ columnActionID + ", "
+ columnDate + ", "
+ columnAdditionalInfo
+ ") VALUES ("
+ usersTable.statementSelectID + ", "
+ serverTable.statementSelectServerID + ", "
+ "?, ?, ?)"
);
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
statement.setString(2, Plan.getServerUUID().toString()); statement.setString(2, Plan.getServerUUID().toString());
statement.setInt(3, action.getDoneAction().getId()); statement.setInt(3, action.getDoneAction().getId());
@ -103,6 +104,7 @@ public class ActionsTable extends UserIDTable {
statement = prepareStatement(Select.from(tableName, "*") statement = prepareStatement(Select.from(tableName, "*")
.where(columnUserID + "=" + usersTable.statementSelectID) .where(columnUserID + "=" + usersTable.statementSelectID)
.toString()); .toString());
statement.setFetchSize(5000);
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
set = statement.executeQuery(); set = statement.executeQuery();
while (set.next()) { while (set.next()) {
@ -118,4 +120,81 @@ public class ActionsTable extends UserIDTable {
close(set, statement); close(set, statement);
} }
} }
public Map<UUID, Map<UUID, List<Action>>> getAllActions() throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
try {
String usersIDColumn = usersTable + "." + usersTable.getColumnID();
String usersUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as uuid";
String serverIDColumn = serverTable + "." + serverTable.getColumnID();
String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid";
statement = prepareStatement("SELECT " +
columnActionID + ", " +
columnDate + ", " +
columnAdditionalInfo + ", " +
usersUUIDColumn + ", " +
serverUUIDColumn +
" FROM " + tableName +
" JOIN " + usersTable + " on " + usersIDColumn + "=" + columnUserID +
" JOIN " + serverTable + " on " + serverIDColumn + "=" + columnServerID
);
statement.setFetchSize(5000);
set = statement.executeQuery();
Map<UUID, Map<UUID, List<Action>>> map = new HashMap<>();
while (set.next()) {
UUID serverUUID = UUID.fromString(set.getString("s_uuid"));
UUID uuid = UUID.fromString(set.getString("uuid"));
Map<UUID, List<Action>> serverMap = map.getOrDefault(serverUUID, new HashMap<>());
List<Action> actions = serverMap.getOrDefault(uuid, new ArrayList<>());
long date = set.getLong(columnDate);
Actions doneAction = Actions.getById(set.getInt(columnActionID));
String additionalInfo = set.getString(columnAdditionalInfo);
actions.add(new Action(date, doneAction, additionalInfo, -1));
serverMap.put(uuid, actions);
map.put(serverUUID, serverMap);
}
return map;
} finally {
endTransaction(statement);
close(set, statement);
}
}
public void insertActions(Map<UUID, Map<UUID, List<Action>>> allActions) throws SQLException {
if (Verify.isEmpty(allActions)) {
return;
}
PreparedStatement statement = null;
try {
statement = prepareStatement(insertStatement);
// Every Server
for (UUID serverUUID : allActions.keySet()) {
// Every User
for (Map.Entry<UUID, List<Action>> entry : allActions.get(serverUUID).entrySet()) {
UUID uuid = entry.getKey();
// Every Action
List<Action> actions = entry.getValue();
for (Action action : actions) {
statement.setString(1, uuid.toString());
statement.setString(2, serverUUID.toString());
statement.setInt(3, action.getDoneAction().getId());
statement.setLong(4, action.getDate());
statement.setString(5, action.getAdditionalInfo());
statement.addBatch();
}
}
}
statement.executeBatch();
commit(statement.getConnection());
} finally {
close(statement);
}
}
} }

View File

@ -6,7 +6,6 @@ import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.sql.Select; import main.java.com.djrapitops.plan.database.sql.Select;
import main.java.com.djrapitops.plan.database.sql.Sql; import main.java.com.djrapitops.plan.database.sql.Sql;
import main.java.com.djrapitops.plan.database.sql.TableSqlParser; import main.java.com.djrapitops.plan.database.sql.TableSqlParser;
import main.java.com.djrapitops.plan.utilities.Benchmark;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -27,6 +26,7 @@ public class CommandUseTable extends Table {
private final String columnServerID = "server_id"; private final String columnServerID = "server_id";
private final ServerTable serverTable; private final ServerTable serverTable;
private String insertStatement;
/** /**
* @param db * @param db
@ -35,6 +35,11 @@ public class CommandUseTable extends Table {
public CommandUseTable(SQLDB db, boolean usingMySQL) { public CommandUseTable(SQLDB db, boolean usingMySQL) {
super("plan_commandusages", db, usingMySQL); super("plan_commandusages", db, usingMySQL);
serverTable = db.getServerTable(); serverTable = db.getServerTable();
insertStatement = "INSERT INTO " + tableName + " ("
+ columnCommand + ", "
+ columnTimesUsed + ", "
+ columnServerID
+ ") VALUES (?, ?, " + serverTable.statementSelectServerID + ")";
} }
/** /**
@ -72,7 +77,6 @@ public class CommandUseTable extends Table {
* @throws SQLException * @throws SQLException
*/ */
public Map<String, Integer> getCommandUse(UUID serverUUID) throws SQLException { public Map<String, Integer> getCommandUse(UUID serverUUID) throws SQLException {
Benchmark.start("Get CommandUse");
Map<String, Integer> commandUse = new HashMap<>(); Map<String, Integer> commandUse = new HashMap<>();
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
@ -96,7 +100,6 @@ public class CommandUseTable extends Table {
} finally { } finally {
endTransaction(statement); endTransaction(statement);
close(set, statement); close(set, statement);
Benchmark.stop("Database", "Get CommandUse");
} }
} }
@ -127,11 +130,6 @@ public class CommandUseTable extends Table {
private void insertCommand(String command) throws SQLException { private void insertCommand(String command) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
String insertStatement = "INSERT INTO " + tableName + " ("
+ columnCommand + ", "
+ columnTimesUsed + ", "
+ columnServerID
+ ") VALUES (?, ?, " + serverTable.statementSelectServerID + ")";
statement = prepareStatement(insertStatement); statement = prepareStatement(insertStatement);
statement.setString(1, command); statement.setString(1, command);
statement.setInt(2, 1); statement.setInt(2, 1);
@ -177,4 +175,67 @@ public class CommandUseTable extends Table {
close(set, statement); close(set, statement);
} }
} }
public Map<UUID, Map<String, Integer>> getAllCommandUsages() throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
try {
String serverIDColumn = serverTable + "." + serverTable.getColumnID();
String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid";
statement = prepareStatement("SELECT " +
columnCommand + ", " +
columnTimesUsed + ", " +
serverUUIDColumn + ", " +
" FROM " + tableName +
" JOIN " + serverTable + " on " + serverIDColumn + "=" + columnServerID
);
statement.setFetchSize(5000);
set = statement.executeQuery();
Map<UUID, Map<String, Integer>> map = new HashMap<>();
while (set.next()) {
UUID serverUUID = UUID.fromString(set.getString("s_uuid"));
Map<String, Integer> serverMap = map.getOrDefault(serverUUID, new HashMap<>());
String command = set.getString(columnCommand);
int timesUsed = set.getInt(columnTimesUsed);
serverMap.put(command, timesUsed);
map.put(serverUUID, serverMap);
}
return map;
} finally {
endTransaction(statement);
close(set, statement);
}
}
public void insertCommandUsage(Map<UUID, Map<String, Integer>> allCommandUsages) throws SQLException {
if (allCommandUsages.isEmpty()) {
return;
}
PreparedStatement statement = null;
try {
statement = prepareStatement(insertStatement);
// Every Server
for (UUID serverUUID : allCommandUsages.keySet()) {
// Every Command
for (Map.Entry<String, Integer> entry : allCommandUsages.get(serverUUID).entrySet()) {
String command = entry.getKey();
int timesUsed = entry.getValue();
statement.setString(1, command);
statement.setInt(2, timesUsed);
statement.setString(3, serverUUID.toString());
statement.addBatch();
}
}
statement.executeBatch();
commit(statement.getConnection());
} finally {
close(statement);
}
}
} }

View File

@ -1,5 +1,6 @@
package main.java.com.djrapitops.plan.database.tables; package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.sql.Select; import main.java.com.djrapitops.plan.database.sql.Select;
@ -18,6 +19,7 @@ public class IPsTable extends UserIDTable {
private final String columnIP = "ip"; private final String columnIP = "ip";
private final String columnGeolocation = "geolocation"; private final String columnGeolocation = "geolocation";
private String insertStatement;
/** /**
* @param db The database * @param db The database
@ -25,6 +27,13 @@ public class IPsTable extends UserIDTable {
*/ */
public IPsTable(SQLDB db, boolean usingMySQL) { public IPsTable(SQLDB db, boolean usingMySQL) {
super("plan_ips", db, usingMySQL); super("plan_ips", db, usingMySQL);
insertStatement = "INSERT INTO " + tableName + " ("
+ columnUserID + ", "
+ columnIP + ", "
+ columnGeolocation
+ ") VALUES ("
+ usersTable.statementSelectID + ", "
+ "?, ?)";
} }
/** /**
@ -89,13 +98,8 @@ public class IPsTable extends UserIDTable {
private void insertIp(UUID uuid, String ip, String geolocation) throws SQLException { private void insertIp(UUID uuid, String ip, String geolocation) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = prepareStatement("INSERT INTO " + tableName + " ("
+ columnUserID + ", " statement = prepareStatement(insertStatement);
+ columnIP + ", "
+ columnGeolocation
+ ") VALUES ("
+ usersTable.statementSelectID + ", "
+ "?, ?)");
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
statement.setString(2, ip); statement.setString(2, ip);
statement.setString(3, geolocation); statement.setString(3, geolocation);
@ -156,4 +160,69 @@ public class IPsTable extends UserIDTable {
close(set, statement); close(set, statement);
} }
} }
public Map<UUID, Map<String, String>> getAllIPsAndGeolocations() throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
try {
String usersIDColumn = usersTable + "." + usersTable.getColumnID();
String usersUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as uuid";
statement = prepareStatement("SELECT " +
columnGeolocation + ", " +
columnIP + ", " +
usersUUIDColumn +
" FROM " + tableName +
" JOIN " + usersTable + " on " + usersIDColumn + "=" + columnUserID
);
statement.setFetchSize(5000);
set = statement.executeQuery();
Map<UUID, Map<String, String>> map = new HashMap<>();
while (set.next()) {
UUID uuid = UUID.fromString(set.getString("uuid"));
Map<String, String> userMap = map.getOrDefault(uuid, new HashMap<>());
String geoLocation = set.getString(columnGeolocation);
String ip = set.getString(columnIP);
userMap.put(ip, geoLocation);
map.put(uuid, userMap);
}
return map;
} finally {
endTransaction(statement);
close(set, statement);
}
}
public void insertIPsAndGeolocations(Map<UUID, Map<String, String>> allIPsAndGeolocations) throws SQLException {
if (Verify.isEmpty(allIPsAndGeolocations)) {
return;
}
PreparedStatement statement = null;
try {
statement = prepareStatement(insertStatement);
// Every User
for (UUID uuid : allIPsAndGeolocations.keySet()) {
// Every IP & Geolocation
for (Map.Entry<String, String> entry : allIPsAndGeolocations.get(uuid).entrySet()) {
String ip = entry.getKey();
String geoLocation = entry.getValue();
statement.setString(1, uuid.toString());
statement.setString(2, ip);
statement.setString(3, geoLocation);
statement.addBatch();
}
}
statement.executeBatch();
commit(statement.getConnection());
} finally {
close(statement);
}
}
} }

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.database.tables; package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.data.PlayerKill; import main.java.com.djrapitops.plan.data.PlayerKill;
import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.Session;
@ -12,9 +12,7 @@ import main.java.com.djrapitops.plan.database.sql.TableSqlParser;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.UUID;
/** /**
* @author Rsl1122 * @author Rsl1122
@ -57,7 +55,7 @@ public class KillsTable extends UserIDTable {
} }
@Override @Override
public boolean removeUser(UUID uuid) { public void removeUser(UUID uuid) throws SQLException{
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = prepareStatement("DELETE FROM " + tableName + statement = prepareStatement("DELETE FROM " + tableName +
@ -68,10 +66,6 @@ public class KillsTable extends UserIDTable {
statement.execute(); statement.execute();
commit(statement.getConnection()); commit(statement.getConnection());
return true;
} catch (SQLException ex) {
Log.toLog(this.getClass().getName(), ex);
return false;
} finally { } finally {
close(statement); close(statement);
} }
@ -127,6 +121,7 @@ public class KillsTable extends UserIDTable {
" JOIN " + usersTable + " on " + usersIDColumn + "=" + columnVictimUserID + " JOIN " + usersTable + " on " + usersIDColumn + "=" + columnVictimUserID +
" WHERE " + columnKillerUserID + "=" + usersTable.statementSelectID); " WHERE " + columnKillerUserID + "=" + usersTable.statementSelectID);
statement.setFetchSize(10000);
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
set = statement.executeQuery(); set = statement.executeQuery();
@ -147,4 +142,44 @@ public class KillsTable extends UserIDTable {
close(set, statement); close(set, statement);
} }
} }
public Map<UUID, List<PlayerKill>> getPlayerKills() throws SQLException {
return getPlayerKills(Plan.getServerUUID());
}
public Map<UUID, List<PlayerKill>> getPlayerKills(UUID serverUUID) throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
try {
String usersVictimIDColumn = usersTable + "." + usersTable.getColumnID();
String usersKillerIDColumn = "a." + usersTable.getColumnID();
String usersVictimUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as victim_uuid";
String usersKillerUUIDColumn = "a." + usersTable.getColumnUUID() + " as killer_uuid";
statement = prepareStatement("SELECT " +
columnDate + ", " +
columnWeapon + ", " +
usersVictimUUIDColumn + ", " +
usersKillerUUIDColumn +
" FROM " + tableName +
" JOIN " + usersTable + " on " + usersVictimIDColumn + "=" + columnVictimUserID +
" JOIN " + usersTable + " a on " + usersKillerIDColumn + "=" + columnKillerUserID);
statement.setFetchSize(10000);
set = statement.executeQuery();
Map<UUID, List<PlayerKill>> allKills = new HashMap<>();
while (set.next()) {
UUID killer = UUID.fromString(set.getString("killer_uuid"));
UUID victim = UUID.fromString(set.getString("victim_uuid"));
long date = set.getLong(columnDate);
String weapon = set.getString(columnWeapon);
List<PlayerKill> kills = allKills.getOrDefault(killer, new ArrayList<>());
kills.add(new PlayerKill(victim, weapon, date));
allKills.put(killer, kills);
}
return allKills;
} finally {
close(set, statement);
}
}
} }

View File

@ -1,5 +1,6 @@
package main.java.com.djrapitops.plan.database.tables; package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;
@ -9,9 +10,7 @@ import main.java.com.djrapitops.plan.database.sql.TableSqlParser;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.UUID;
/** /**
* @author Rsl1122 * @author Rsl1122
@ -22,6 +21,7 @@ public class NicknamesTable extends UserIDTable {
private final String columnServerID = "server_id"; private final String columnServerID = "server_id";
private final ServerTable serverTable; private final ServerTable serverTable;
private String insertStatement;
/** /**
* @param db The database * @param db The database
@ -30,6 +30,14 @@ public class NicknamesTable extends UserIDTable {
public NicknamesTable(SQLDB db, boolean usingMySQL) { public NicknamesTable(SQLDB db, boolean usingMySQL) {
super("plan_nicknames", db, usingMySQL); super("plan_nicknames", db, usingMySQL);
serverTable = db.getServerTable(); serverTable = db.getServerTable();
insertStatement = "INSERT INTO " + tableName + " (" +
columnUserID + ", " +
columnServerID + ", " +
columnNick +
") VALUES (" +
usersTable.statementSelectID + ", " +
serverTable.statementSelectServerID + ", " +
"?)";
} }
/** /**
@ -142,14 +150,7 @@ public class NicknamesTable extends UserIDTable {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = prepareStatement("INSERT INTO " + tableName + " (" + statement = prepareStatement(insertStatement);
columnUserID + ", " +
columnServerID + ", " +
columnNick +
") VALUES (" +
usersTable.statementSelectID + ", " +
serverTable.statementSelectServerID + ", " +
"?)");
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
statement.setString(2, Plan.getServerUUID().toString()); statement.setString(2, Plan.getServerUUID().toString());
statement.setString(3, displayName); statement.setString(3, displayName);
@ -160,4 +161,77 @@ public class NicknamesTable extends UserIDTable {
close(statement); close(statement);
} }
} }
public Map<UUID, Map<UUID, List<String>>> getAllNicknames() throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
try {
String usersIDColumn = usersTable + "." + usersTable.getColumnID();
String usersUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as uuid";
String serverIDColumn = serverTable + "." + serverTable.getColumnID();
String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid";
statement = prepareStatement("SELECT " +
columnNick + ", " +
usersUUIDColumn + ", " +
serverUUIDColumn +
" FROM " + tableName +
" JOIN " + usersTable + " on " + usersIDColumn + "=" + columnUserID +
" JOIN " + serverTable + " on " + serverIDColumn + "=" + columnServerID
);
statement.setFetchSize(5000);
set = statement.executeQuery();
Map<UUID, Map<UUID, List<String>>> map = new HashMap<>();
while (set.next()) {
UUID serverUUID = UUID.fromString(set.getString("s_uuid"));
UUID uuid = UUID.fromString(set.getString("uuid"));
Map<UUID, List<String>> serverMap = map.getOrDefault(serverUUID, new HashMap<>());
List<String> nicknames = serverMap.getOrDefault(uuid, new ArrayList<>());
nicknames.add(set.getString(columnNick));
serverMap.put(uuid, nicknames);
map.put(serverUUID, serverMap);
}
return map;
} finally {
endTransaction(statement);
close(set, statement);
}
}
public void insertNicknames(Map<UUID, Map<UUID, List<String>>> allNicknames) throws SQLException {
if (Verify.isEmpty(allNicknames)) {
return;
}
PreparedStatement statement = null;
try {
statement = prepareStatement(insertStatement);
// Every Server
for (UUID serverUUID : allNicknames.keySet()) {
// Every User
for (Map.Entry<UUID, List<String>> entry : allNicknames.get(serverUUID).entrySet()) {
UUID uuid = entry.getKey();
// Every Nickname
List<String> nicknames = entry.getValue();
for (String nickname : nicknames) {
statement.setString(1, uuid.toString());
statement.setString(2, serverUUID.toString());
statement.setString(3, nickname);
statement.addBatch();
}
}
}
statement.executeBatch();
commit(statement.getConnection());
} finally {
close(statement);
}
}
public String getColumnNick() {
return columnNick;
}
} }

View File

@ -5,6 +5,7 @@
*/ */
package main.java.com.djrapitops.plan.database.tables; package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.data.WebUser; import main.java.com.djrapitops.plan.data.WebUser;
@ -28,9 +29,14 @@ public class SecurityTable extends Table {
private final String columnUser = "username"; private final String columnUser = "username";
private final String columnSaltedHash = "salted_pass_hash"; private final String columnSaltedHash = "salted_pass_hash";
private final String columnPermLevel = "permission_level"; private final String columnPermLevel = "permission_level";
private String insertStatement;
public SecurityTable(SQLDB db, boolean usingMySQL) { public SecurityTable(SQLDB db, boolean usingMySQL) {
super("plan_security", db, usingMySQL); super("plan_security", db, usingMySQL);
insertStatement = Insert.values(tableName,
columnUser,
columnSaltedHash,
columnPermLevel);
} }
@Override @Override
@ -67,10 +73,7 @@ public class SecurityTable extends Table {
public void addNewUser(String user, String saltPassHash, int permLevel) throws SQLException { public void addNewUser(String user, String saltPassHash, int permLevel) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = prepareStatement(Insert.values(tableName, statement = prepareStatement(insertStatement);
columnUser,
columnSaltedHash,
columnPermLevel));
statement.setString(1, user); statement.setString(1, user);
statement.setString(2, saltPassHash); statement.setString(2, saltPassHash);
statement.setInt(3, permLevel); statement.setInt(3, permLevel);
@ -110,6 +113,7 @@ public class SecurityTable extends Table {
ResultSet set = null; ResultSet set = null;
try { try {
statement = prepareStatement(Select.all(tableName).toString()); statement = prepareStatement(Select.all(tableName).toString());
statement.setFetchSize(5000);
set = statement.executeQuery(); set = statement.executeQuery();
List<WebUser> list = new ArrayList<>(); List<WebUser> list = new ArrayList<>();
while (set.next()) { while (set.next()) {
@ -125,4 +129,29 @@ public class SecurityTable extends Table {
close(set, statement); close(set, statement);
} }
} }
public void addUsers(List<WebUser> users) throws SQLException {
if (Verify.isEmpty(users)) {
return;
}
PreparedStatement statement = null;
try {
statement = prepareStatement(insertStatement);
for (WebUser user : users) {
String userName = user.getName();
String pass = user.getSaltedPassHash();
int permLvl = user.getPermLevel();
statement.setString(1, userName);
statement.setString(2, pass);
statement.setInt(3, permLvl);
statement.addBatch();
}
statement.executeBatch();
commit(statement.getConnection());
} finally {
close(statement);
}
}
} }

View File

@ -40,11 +40,18 @@ public class ServerTable extends Table {
private final String columnWebserverAddress = "web_address"; private final String columnWebserverAddress = "web_address";
private final String columnInstalled = "is_installed"; private final String columnInstalled = "is_installed";
private final String columnMaxPlayers = "max_players"; private final String columnMaxPlayers = "max_players";
private String insertStatement;
public ServerTable(SQLDB db, boolean usingMySQL) { public ServerTable(SQLDB db, boolean usingMySQL) {
super("plan_servers", db, usingMySQL); super("plan_servers", db, usingMySQL);
statementSelectServerID = "(" + Select.from(tableName, tableName + "." + columnServerID).where(columnServerUUID + "=?").toString() + ")"; statementSelectServerID = "(" + Select.from(tableName, tableName + "." + columnServerID).where(columnServerUUID + "=?").toString() + ")";
statementSelectServerNameID = "(" + Select.from(tableName, tableName + "." + columnServerName).where(columnServerID + "=?").toString() + ")"; statementSelectServerNameID = "(" + Select.from(tableName, tableName + "." + columnServerName).where(columnServerID + "=?").toString() + ")";
insertStatement = Insert.values(tableName,
columnServerUUID,
columnServerName,
columnWebserverAddress,
columnInstalled,
columnMaxPlayers);
} }
@Override @Override
@ -109,12 +116,7 @@ public class ServerTable extends Table {
Verify.nullCheck(uuid, name, webAddress); Verify.nullCheck(uuid, name, webAddress);
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = prepareStatement(Insert.values(tableName, statement = prepareStatement(insertStatement);
columnServerUUID,
columnServerName,
columnWebserverAddress,
columnInstalled,
columnMaxPlayers));
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
statement.setString(2, name); statement.setString(2, name);
@ -264,4 +266,40 @@ public class ServerTable extends Table {
public String getColumnID() { public String getColumnID() {
return columnServerID; return columnServerID;
} }
public String getColumnUUID() {
return columnServerUUID;
}
public void insertAllServers(List<ServerInfo> allServerInfo) throws SQLException {
if (Verify.isEmpty(allServerInfo)) {
return;
}
PreparedStatement statement = null;
try {
statement = prepareStatement(insertStatement);
for (ServerInfo info : allServerInfo) {
UUID uuid = info.getUuid();
String name = info.getName();
String webAddress = info.getWebAddress();
if (Verify.notNull(uuid, name, webAddress)) {
continue;
}
statement.setString(1, uuid.toString());
statement.setString(2, name);
statement.setString(3, webAddress);
statement.setBoolean(4, true);
statement.setInt(5, info.getMaxPlayers());
statement.addBatch();
}
statement.executeBatch();
commit(statement.getConnection());
} finally {
close(statement);
}
}
} }

View File

@ -450,7 +450,6 @@ public class SessionsTable extends UserIDTable {
return getSessionInfoOfServer(Plan.getServerUUID()); return getSessionInfoOfServer(Plan.getServerUUID());
} }
// TODO Write tests for this method
public Map<UUID, List<Session>> getSessionInfoOfServer(UUID serverUUID) throws SQLException { public Map<UUID, List<Session>> getSessionInfoOfServer(UUID serverUUID) throws SQLException {
Optional<Integer> id = serverTable.getServerID(serverUUID); Optional<Integer> id = serverTable.getServerID(serverUUID);
if (!id.isPresent()) { if (!id.isPresent()) {

View File

@ -1,6 +1,7 @@
package main.java.com.djrapitops.plan.database.tables; package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.api.TimeAmount;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.data.TPS; import main.java.com.djrapitops.plan.data.TPS;
@ -14,10 +15,7 @@ import main.java.com.djrapitops.plan.utilities.MiscUtils;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
/** /**
* Class representing database table plan_tps * Class representing database table plan_tps
@ -37,6 +35,7 @@ public class TPSTable extends Table {
private final String columnChunksLoaded = "chunks_loaded"; private final String columnChunksLoaded = "chunks_loaded";
private final ServerTable serverTable; private final ServerTable serverTable;
private String insertStatement;
/** /**
* @param db * @param db
@ -45,6 +44,18 @@ public class TPSTable extends Table {
public TPSTable(SQLDB db, boolean usingMySQL) { public TPSTable(SQLDB db, boolean usingMySQL) {
super("plan_tps", db, usingMySQL); super("plan_tps", db, usingMySQL);
serverTable = db.getServerTable(); serverTable = db.getServerTable();
insertStatement = "INSERT INTO " + tableName + " ("
+ columnServerID + ", "
+ columnDate + ", "
+ columnTPS + ", "
+ columnPlayers + ", "
+ columnCPUUsage + ", "
+ columnRAMUsage + ", "
+ columnEntities + ", "
+ columnChunksLoaded
+ ") VALUES ("
+ serverTable.statementSelectServerID + ", "
+ "?, ?, ?, ?, ?, ?, ?)";
} }
@Override @Override
@ -75,7 +86,7 @@ public class TPSTable extends Table {
statement = prepareStatement(Select.all(tableName) statement = prepareStatement(Select.all(tableName)
.where(columnServerID + "=" + serverTable.statementSelectServerID) .where(columnServerID + "=" + serverTable.statementSelectServerID)
.toString()); .toString());
statement.setFetchSize(10000); statement.setFetchSize(20000);
statement.setString(1, Plan.getServerUUID().toString()); statement.setString(1, Plan.getServerUUID().toString());
set = statement.executeQuery(); set = statement.executeQuery();
while (set.next()) { while (set.next()) {
@ -99,18 +110,7 @@ public class TPSTable extends Table {
public void insertTPS(TPS tps) throws SQLException { public void insertTPS(TPS tps) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = prepareStatement("INSERT INTO " + tableName + " (" statement = prepareStatement(insertStatement);
+ columnServerID + ", "
+ columnDate + ", "
+ columnTPS + ", "
+ columnPlayers + ", "
+ columnCPUUsage + ", "
+ columnRAMUsage + ", "
+ columnEntities + ", "
+ columnChunksLoaded
+ ") VALUES ("
+ serverTable.statementSelectServerID + ", "
+ "?, ?, ?, ?, ?, ?, ?)");
statement.setString(1, Plan.getServerUUID().toString()); statement.setString(1, Plan.getServerUUID().toString());
statement.setLong(2, tps.getDate()); statement.setLong(2, tps.getDate());
@ -132,12 +132,18 @@ public class TPSTable extends Table {
* @throws SQLException * @throws SQLException
*/ */
public void clean() throws SQLException { public void clean() throws SQLException {
Optional<TPS> allTimePeak = getAllTimePeak();
int p = -1;
if (allTimePeak.isPresent()) {
p = allTimePeak.get().getPlayers();
}
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = prepareStatement("DELETE FROM " + tableName + statement = prepareStatement("DELETE FROM " + tableName +
" WHERE (" + columnDate + "<?)" + " WHERE (" + columnDate + "<?)" +
" AND (" + columnPlayers + "" + " AND (" + columnPlayers + "" +
" != (SELECT MAX(" + columnPlayers + ") FROM " + tableName + "))"); " != ?)");
statement.setInt(1, p);
// More than 2 Months ago. // More than 2 Months ago.
long fiveWeeks = TimeAmount.MONTH.ms() * 2L; long fiveWeeks = TimeAmount.MONTH.ms() * 2L;
statement.setLong(1, MiscUtils.getTime() - fiveWeeks); statement.setLong(1, MiscUtils.getTime() - fiveWeeks);
@ -167,7 +173,7 @@ public class TPSTable extends Table {
try { try {
statement = prepareStatement(Select.all(tableName) statement = prepareStatement(Select.all(tableName)
.where(columnServerID + "=" + serverTable.statementSelectServerID) .where(columnServerID + "=" + serverTable.statementSelectServerID)
.and(columnPlayers + "= (SELECT MAX(" + columnPlayers + ") FROM " + tableName+")") .and(columnPlayers + "= (SELECT MAX(" + columnPlayers + ") FROM " + tableName + ")")
.and(columnDate + ">= ?") .and(columnDate + ">= ?")
.toString()); .toString());
statement.setString(1, serverUUID.toString()); statement.setString(1, serverUUID.toString());
@ -189,4 +195,81 @@ public class TPSTable extends Table {
close(set, statement); close(set, statement);
} }
} }
public Map<UUID, List<TPS>> getAllTPS() throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
try {
String serverIDColumn = serverTable + "." + serverTable.getColumnID();
String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid";
statement = prepareStatement("SELECT " +
columnDate + ", " +
columnTPS + ", " +
columnPlayers + ", " +
columnCPUUsage + ", " +
columnRAMUsage + ", " +
columnEntities + ", " +
columnChunksLoaded + ", " +
serverUUIDColumn +
" FROM " + tableName +
" JOIN " + serverTable + " on " + serverIDColumn + "=" + columnServerID
);
statement.setFetchSize(20000);
set = statement.executeQuery();
Map<UUID, List<TPS>> serverMap = new HashMap<>();
while (set.next()) {
UUID serverUUID = UUID.fromString(set.getString("s_uuid"));
List<TPS> tpsList = serverMap.getOrDefault(serverUUID, new ArrayList<>());
long date = set.getLong(columnDate);
double tps = set.getDouble(columnTPS);
int players = set.getInt(columnPlayers);
double cpuUsage = set.getDouble(columnCPUUsage);
long ramUsage = set.getLong(columnRAMUsage);
int entities = set.getInt(columnEntities);
int chunksLoaded = set.getInt(columnChunksLoaded);
tpsList.add(new TPS(date, tps, players, cpuUsage, ramUsage, entities, chunksLoaded));
serverMap.put(serverUUID, tpsList);
}
return serverMap;
} finally {
endTransaction(statement);
close(set, statement);
}
}
public void insertAllTPS(Map<UUID, List<TPS>> allTPS) throws SQLException {
if (Verify.isEmpty(allTPS)) {
return;
}
PreparedStatement statement = null;
try {
statement = prepareStatement(insertStatement);
// Every Server
for (Map.Entry<UUID, List<TPS>> entry : allTPS.entrySet()) {
UUID serverUUID = entry.getKey();
// Every TPS Data point
List<TPS> tpsList = entry.getValue();
for (TPS tps : tpsList) {
statement.setString(1, serverUUID.toString());
statement.setLong(2, tps.getDate());
statement.setDouble(3, tps.getTicksPerSecond());
statement.setInt(4, tps.getPlayers());
statement.setDouble(5, tps.getCPUUsage());
statement.setLong(6, tps.getUsedMemory());
statement.setDouble(7, tps.getEntityCount());
statement.setDouble(8, tps.getChunksLoaded());
statement.addBatch();
}
}
statement.executeBatch();
commit(statement.getConnection());
} finally {
close(statement);
}
}
} }

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.database.tables; package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log; import com.google.common.base.Objects;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.database.Container; import main.java.com.djrapitops.plan.database.Container;
import main.java.com.djrapitops.plan.database.DBUtils; import main.java.com.djrapitops.plan.database.DBUtils;
@ -135,14 +135,8 @@ public abstract class Table {
/** /**
* @return * @return
*/ */
public boolean removeAllData() { public void removeAllData() throws SQLException {
try {
execute("DELETE FROM " + tableName); execute("DELETE FROM " + tableName);
return true;
} catch (SQLException ex) {
Log.toLog(this.getClass().getName(), ex);
return false;
}
} }
/** /**
@ -202,4 +196,19 @@ public abstract class Table {
endTransaction(statement.getConnection()); endTransaction(statement.getConnection());
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Table table = (Table) o;
return usingMySQL == table.usingMySQL &&
Objects.equal(tableName, table.tableName) &&
Objects.equal(db, table.db);
}
@Override
public int hashCode() {
return Objects.hashCode(tableName, db, usingMySQL);
}
} }

View File

@ -1,6 +1,5 @@
package main.java.com.djrapitops.plan.database.tables; package main.java.com.djrapitops.plan.database.tables;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -23,7 +22,7 @@ public abstract class UserIDTable extends Table {
usersTable = db.getUsersTable(); usersTable = db.getUsersTable();
} }
public boolean removeUser(UUID uuid) { public void removeUser(UUID uuid) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = prepareStatement("DELETE FROM " + tableName + statement = prepareStatement("DELETE FROM " + tableName +
@ -32,10 +31,6 @@ public abstract class UserIDTable extends Table {
statement.execute(); statement.execute();
commit(statement.getConnection()); commit(statement.getConnection());
return true;
} catch (SQLException ex) {
Log.toLog(this.getClass().getName(), ex);
return false;
} finally { } finally {
close(statement); close(statement);
} }

View File

@ -4,6 +4,7 @@
*/ */
package main.java.com.djrapitops.plan.database.tables; package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException; import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.data.UserInfo;
@ -16,13 +17,11 @@ import main.java.com.djrapitops.plan.database.sql.Update;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.UUID;
/** /**
* Server Specific user information table. * Server Specific user information table.
* * <p>
* Represents plan_user_info. * Represents plan_user_info.
* *
* @author Rsl1122 * @author Rsl1122
@ -155,11 +154,11 @@ public class UserInfoTable extends UserIDTable {
* *
* @return List of UserInfo objects. * @return List of UserInfo objects.
*/ */
public List<UserInfo> getAllUserInfo() throws SQLException { public List<UserInfo> getServerUserInfo() throws SQLException {
return getAllUserInfo(Plan.getServerUUID()); return getServerUserInfo(Plan.getServerUUID());
} }
public List<UserInfo> getAllUserInfo(UUID serverUUID) throws SQLException { public List<UserInfo> getServerUserInfo(UUID serverUUID) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
try { try {
@ -193,4 +192,84 @@ public class UserInfoTable extends UserIDTable {
close(set, statement); close(set, statement);
} }
} }
public Map<UUID, List<UserInfo>> getAllUserInfo() throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
try {
String usersIDColumn = usersTable + "." + usersTable.getColumnID();
String usersUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as uuid";
String serverIDColumn = serverTable + "." + serverTable.getColumnID();
String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid";
statement = prepareStatement("SELECT " +
tableName + "." + columnRegistered + ", " +
columnBanned + ", " +
columnOP + ", " +
usersUUIDColumn + ", " +
serverUUIDColumn +
" FROM " + tableName +
" JOIN " + usersTable + " on " + usersIDColumn + "=" + columnUserID +
" JOIN " + serverTable + " on " + serverIDColumn + "=" + columnServerID
);
statement.setFetchSize(5000);
set = statement.executeQuery();
Map<UUID, List<UserInfo>> serverMap = new HashMap<>();
while (set.next()) {
UUID serverUUID = UUID.fromString(set.getString("s_uuid"));
UUID uuid = UUID.fromString(set.getString("uuid"));
List<UserInfo> userInfos = serverMap.getOrDefault(serverUUID, new ArrayList<>());
long registered = set.getLong(columnRegistered);
boolean banned = set.getBoolean(columnBanned);
boolean op = set.getBoolean(columnOP);
userInfos.add(new UserInfo(uuid, "", registered, op, banned));
serverMap.put(uuid, userInfos);
}
return serverMap;
} finally {
endTransaction(statement);
close(set, statement);
}
}
public void insertUserInfo(Map<UUID, List<UserInfo>> allUserInfos) throws SQLException {
if (Verify.isEmpty(allUserInfos)) {
return;
}
PreparedStatement statement = null;
try {
statement = prepareStatement("INSERT INTO " + tableName + " (" +
columnUserID + ", " +
columnRegistered + ", " +
columnServerID + ", " +
columnBanned + ", " +
columnOP +
") VALUES (" +
usersTable.statementSelectID + ", " +
"?, " +
serverTable.statementSelectServerID + ", ?, ?)");
// Every Server
for (Map.Entry<UUID, List<UserInfo>> entry : allUserInfos.entrySet()) {
UUID serverUUID = entry.getKey();
// Every User
for (UserInfo user : entry.getValue()) {
statement.setString(1, user.getUuid().toString());
statement.setLong(2, user.getRegistered());
statement.setString(3, serverUUID.toString());
statement.setBoolean(4, user.isBanned());
statement.setBoolean(5, user.isOpped());
statement.addBatch();
}
}
statement.executeBatch();
commit(statement.getConnection());
} finally {
close(statement);
}
}
} }

View File

@ -77,7 +77,7 @@ public class UsersTable extends UserIDTable {
* @return if the removal was successful. * @return if the removal was successful.
*/ */
@Override @Override
public boolean removeUser(UUID uuid) { public void removeUser(UUID uuid) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
try { try {
statement = prepareStatement("DELETE FROM " + tableName + " WHERE (" + columnUUID + "=?)"); statement = prepareStatement("DELETE FROM " + tableName + " WHERE (" + columnUUID + "=?)");
@ -85,9 +85,6 @@ public class UsersTable extends UserIDTable {
statement.execute(); statement.execute();
commit(statement.getConnection()); commit(statement.getConnection());
return true;
} catch (SQLException ex) {
return false;
} finally { } finally {
close(statement); close(statement);
} }
@ -277,8 +274,14 @@ public class UsersTable extends UserIDTable {
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
try { try {
NicknamesTable nicknamesTable = db.getNicknamesTable();
statement = prepareStatement( statement = prepareStatement(
"SELECT name FROM plan_users WHERE name LIKE LOWER(?) UNION SELECT name FROM plan_users WHERE id = (SELECT user_id FROM plan_nicknames WHERE nickname LIKE LOWER(?))" "SELECT " + columnName + " FROM " + tableName +
" WHERE " + columnName + " LIKE LOWER(?)" +
" UNION SELECT " + columnName + " FROM " + tableName +
" WHERE " + columnID + " =" +
" (SELECT " + columnID + " FROM " + nicknamesTable +
" WHERE " + nicknamesTable.getColumnNick() + " LIKE LOWER(?))"
); );
statement.setString(1, searchString); statement.setString(1, searchString);
statement.setString(2, searchString); statement.setString(2, searchString);

View File

@ -210,7 +210,6 @@ public class WorldTimesTable extends UserIDTable {
try { try {
String worldIDColumn = worldTable + "." + worldTable.getColumnID(); String worldIDColumn = worldTable + "." + worldTable.getColumnID();
String worldNameColumn = worldTable + "." + worldTable.getColumnWorldName() + " as world_name"; String worldNameColumn = worldTable + "." + worldTable.getColumnWorldName() + " as world_name";
String sessionIDColumn = sessionsTable + "." + sessionsTable.getColumnID();
statement = prepareStatement("SELECT " + statement = prepareStatement("SELECT " +
"SUM(" + columnSurvival + ") as survival, " + "SUM(" + columnSurvival + ") as survival, " +
"SUM(" + columnCreative + ") as creative, " + "SUM(" + columnCreative + ") as creative, " +

View File

@ -0,0 +1,119 @@
/*
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package main.java.com.djrapitops.plan.database.tables.move;
import main.java.com.djrapitops.plan.api.exceptions.DBCreateTableException;
import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.tables.ServerTable;
import main.java.com.djrapitops.plan.database.tables.Table;
import main.java.com.djrapitops.plan.systems.info.server.ServerInfo;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
/**
* A Fake table used to store a lot of big table operations.
* <p>
* To use this table create a new BatchOperationTable with both SQLDB objects.
* {@code SQLDB from; SQLDB to;}
* {@code fromT = new BatchOperationTable(from);}
* {@code toT = new BatchOperationTable(to);}
* {@code fromT.copy(toT);}
* <p>
* The copy methods assume that the table has been cleared, or that no duplicate data will be entered for a user.
* <p>
* clearTable methods can be used to clear the table beforehand.
* <p>
* Server & User tables should be copied first.
*
* @author Rsl1122
* @since 4.0.0
*/
public class BatchOperationTable extends Table {
public BatchOperationTable(SQLDB db, boolean usingMySQL) {
super("", db, usingMySQL);
}
@Override
public void createTable() throws DBCreateTableException {
throw new IllegalStateException("Method not supposed to be used on this table.");
}
public void clearTable(Table table) throws SQLException {
table.removeAllData();
}
public void clearTable(Collection<UUID> uuids, Table table) {
// TODO
}
public void copyActions(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getActionsTable().insertActions(db.getActionsTable().getAllActions());
}
public void copyCommandUse(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getCommandUseTable().insertCommandUsage(db.getCommandUseTable().getAllCommandUsages());
}
public void copyIPsAndGeolocs(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getIpsTable().insertIPsAndGeolocations(db.getIpsTable().getAllIPsAndGeolocations());
}
public void copyNicknames(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getNicknamesTable().insertNicknames(db.getNicknamesTable().getAllNicknames());
}
public void copyWebUsers(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getSecurityTable().addUsers(db.getSecurityTable().getUsers());
}
public void copyServers(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
ServerTable serverTable = db.getServerTable();
List<ServerInfo> servers = serverTable.getBukkitServers();
serverTable.getBungeeInfo().ifPresent(servers::add);
toDB.db.getServerTable().insertAllServers(servers);
}
public void copyTPS(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getTpsTable().insertAllTPS(db.getTpsTable().getAllTPS());
}
public void copyUserInfo(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getUserInfoTable().insertUserInfo(db.getUserInfoTable().getAllUserInfo());
}
public void copyWorlds(BatchOperationTable toDB) throws SQLException {
if (toDB.equals(this)) {
return;
}
toDB.db.getWorldTable().saveWorlds(db.getWorldTable().getWorlds());
}
}

View File

@ -73,7 +73,7 @@ public class InformationManager {
} }
public void cachePlayer(UUID uuid) { public void cachePlayer(UUID uuid) {
PageCache.loadPage("inspectPage: "+uuid, () -> new InspectPageResponse(this, uuid)); PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(this, uuid));
// TODO Player page plugin tab request // TODO Player page plugin tab request
} }

View File

@ -95,9 +95,10 @@ public class PlanPlayerListener implements Listener {
cache.cacheSession(uuid, Session.start(time, world, gm)); cache.cacheSession(uuid, Session.start(time, world, gm));
plugin.addToProcessQueue( plugin.addToProcessQueue(
new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline), new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline,
new IPUpdateProcessor(uuid, ip), new IPUpdateProcessor(uuid, ip),
new NameProcessor(uuid, playerName, displayName) new NameProcessor(uuid, playerName, displayName)
)
); );
} }

View File

@ -11,6 +11,7 @@ import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.tables.Actions; import main.java.com.djrapitops.plan.database.tables.Actions;
import main.java.com.djrapitops.plan.database.tables.UserInfoTable; import main.java.com.djrapitops.plan.database.tables.UserInfoTable;
import main.java.com.djrapitops.plan.database.tables.UsersTable; import main.java.com.djrapitops.plan.database.tables.UsersTable;
import main.java.com.djrapitops.plan.systems.processing.Processor;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.UUID; import java.util.UUID;
@ -26,13 +27,15 @@ public class RegisterProcessor extends PlayerProcessor {
private final long time; private final long time;
private final int playersOnline; private final int playersOnline;
private final String name; private final String name;
private final Processor[] afterProcess;
public RegisterProcessor(UUID uuid, long registered, long time, String name, int playersOnline) { public RegisterProcessor(UUID uuid, long registered, long time, String name, int playersOnline, Processor... afterProcess) {
super(uuid); super(uuid);
this.registered = registered; this.registered = registered;
this.time = time; this.time = time;
this.playersOnline = playersOnline; this.playersOnline = playersOnline;
this.name = name; this.name = name;
this.afterProcess = afterProcess;
} }
@Override @Override
@ -55,5 +58,6 @@ public class RegisterProcessor extends PlayerProcessor {
} catch (SQLException e) { } catch (SQLException e) {
Log.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
} }
plugin.addToProcessQueue(afterProcess);
} }
} }

View File

@ -478,11 +478,6 @@ public class WebServer {
return PageCache.loadPage("notFound: " + error, () -> new NotFoundResponse(error)); return PageCache.loadPage("notFound: " + error, () -> new NotFoundResponse(error));
} }
if (!infoManager.isCached(uuid)) {
String error = "Player's data was not cached.<br>Use /plan inspect " + playerName + " to cache the Data.";
return PageCache.loadPage("notFound: " + error, () -> new NotFoundResponse(error));
}
return PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(infoManager, uuid)); return PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(infoManager, uuid));
} }

View File

@ -68,7 +68,7 @@ public class ManageUtils {
*/ */
public static boolean clearAndCopy(Database clearAndCopyToDB, Database copyFromDB) { public static boolean clearAndCopy(Database clearAndCopyToDB, Database copyFromDB) {
// try { // try {
clearAndCopyToDB.removeAllData(); //clearAndCopyToDB.removeAllData();
//TODO List<UserInfo> allUserData = copyFromDB.getUserDataForUUIDS(copyFromDB.getSavedUUIDs()); //TODO List<UserInfo> allUserData = copyFromDB.getUserDataForUUIDS(copyFromDB.getSavedUUIDs());
// clearAndCopyToDB.saveMultipleUserData(allUserData); // clearAndCopyToDB.saveMultipleUserData(allUserData);
// TODO clearAndCopyToDB.getCommandUseTable().saveCommandUse(copyFromDB.getCommandUseTable().getCommandUse()); // TODO clearAndCopyToDB.getCommandUseTable().saveCommandUse(copyFromDB.getCommandUseTable().getCommandUse());

View File

@ -5,10 +5,7 @@ import com.djrapitops.plugin.task.AbsRunnable;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.AnalysisData; import main.java.com.djrapitops.plan.data.*;
import main.java.com.djrapitops.plan.data.Session;
import main.java.com.djrapitops.plan.data.TPS;
import main.java.com.djrapitops.plan.data.UserInfo;
import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.HookHandler; import main.java.com.djrapitops.plan.data.additional.HookHandler;
import main.java.com.djrapitops.plan.data.additional.PluginData; import main.java.com.djrapitops.plan.data.additional.PluginData;
@ -240,6 +237,7 @@ public class Analysis {
CommandUsagePart commandUsagePart = analysisData.getCommandUsagePart(); CommandUsagePart commandUsagePart = analysisData.getCommandUsagePart();
GeolocationPart geolocPart = analysisData.getGeolocationPart(); GeolocationPart geolocPart = analysisData.getGeolocationPart();
JoinInfoPart joinInfo = analysisData.getJoinInfoPart(); JoinInfoPart joinInfo = analysisData.getJoinInfoPart();
KillPart killPart = analysisData.getKillPart();
PlayerCountPart playerCount = analysisData.getPlayerCountPart(); PlayerCountPart playerCount = analysisData.getPlayerCountPart();
PlaytimePart playtime = analysisData.getPlaytimePart(); PlaytimePart playtime = analysisData.getPlaytimePart();
TPSPart tpsPart = analysisData.getTpsPart(); TPSPart tpsPart = analysisData.getTpsPart();
@ -260,7 +258,7 @@ public class Analysis {
tpsPart.addTpsData(tpsData); tpsPart.addTpsData(tpsData);
Log.debug("Analysis", "TPS Data Size: " + tpsData.size()); Log.debug("Analysis", "TPS Data Size: " + tpsData.size());
List<UserInfo> userInfo = db.getUserInfoTable().getAllUserInfo(); List<UserInfo> userInfo = db.getUserInfoTable().getServerUserInfo();
Map<UUID, UserInfo> mappedUserInfo = userInfo.stream().collect(Collectors.toMap(UserInfo::getUuid, Function.identity())); Map<UUID, UserInfo> mappedUserInfo = userInfo.stream().collect(Collectors.toMap(UserInfo::getUuid, Function.identity()));
Map<UUID, Long> lastSeen = db.getSessionsTable().getLastSeenForAllPlayers(); Map<UUID, Long> lastSeen = db.getSessionsTable().getLastSeenForAllPlayers();
for (Map.Entry<UUID, Long> entry : lastSeen.entrySet()) { for (Map.Entry<UUID, Long> entry : lastSeen.entrySet()) {
@ -290,6 +288,9 @@ public class Analysis {
joinInfo.addActiveSessions(activeSessions); joinInfo.addActiveSessions(activeSessions);
joinInfo.addSessions(sessions); joinInfo.addSessions(sessions);
Map<UUID, List<PlayerKill>> playerKills = db.getKillsTable().getPlayerKills();
killPart.addKills(playerKills);
Map<UUID, List<String>> geolocations = db.getIpsTable().getAllGeolocations(); Map<UUID, List<String>> geolocations = db.getIpsTable().getAllGeolocations();
geolocPart.addGeoLocations(geolocations); geolocPart.addGeoLocations(geolocations);

View File

@ -1,103 +0,0 @@
package main.java.com.djrapitops.plan.database;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.TPS;
import main.java.com.djrapitops.plan.data.WebUser;
import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
import org.bukkit.plugin.java.JavaPlugin;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.RandomData;
import test.java.utils.TestInit;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@RunWith(PowerMockRunner.class)
@PrepareForTest(JavaPlugin.class)
public class DatabaseCommitTest {
private Plan plan;
private SQLDB db;
private int rows;
@Before
public void setUp() throws Exception {
TestInit t = TestInit.init();
plan = t.getPlanMock();
db = new SQLiteDB(plan, "debug" + MiscUtils.getTime());
db.init();
File file = new File(plan.getDataFolder(), "Errors.txt");
rows = FileUtil.lines(file).size();
}
@After
public void tearDown() throws IOException, SQLException {
db.close();
File f = new File(plan.getDataFolder(), "Errors.txt");
List<String> lines = FileUtil.lines(f);
int rowsAgain = lines.size();
if (rowsAgain > 0) {
for (String line : lines) {
System.out.println(line);
}
}
assertTrue("Errors were caught.", rows == rowsAgain);
}
@Test
public void testNoExceptionWhenCommitEmpty() throws Exception {
db.init();
db.commit(db.getConnection());
db.commit(db.getConnection());
db.commit(db.getConnection());
}
@Ignore("//TODO")
@Test
public void testCommitToDBFile() throws Exception {
db.init();
}
@Ignore("//TODO")
@Test
public void testCommitToDBFile2() throws Exception {
db.init();
List<TPS> tps = RandomData.randomTPS();
// db.getTpsTable().saveTPSData(tps);
db.close();
db.init();
assertFalse(db.getTpsTable().getTPSData().isEmpty());
}
// TODO Commit tests for new Login save features.
@Test
public void testCommitToDBFile5() throws Exception {
db.init();
WebUser webUser = new WebUser("Test", "SHA1:rioegnorgiengoieng:oiegnoeigneo:352", 0);
db.getSecurityTable().addNewUser(webUser);
db.close();
db.init();
assertEquals(webUser, db.getSecurityTable().getWebUser("Test"));
}
}

View File

@ -11,6 +11,7 @@ import main.java.com.djrapitops.plan.data.*;
import main.java.com.djrapitops.plan.data.time.GMTimes; import main.java.com.djrapitops.plan.data.time.GMTimes;
import main.java.com.djrapitops.plan.data.time.WorldTimes; import main.java.com.djrapitops.plan.data.time.WorldTimes;
import main.java.com.djrapitops.plan.database.databases.MySQLDB; import main.java.com.djrapitops.plan.database.databases.MySQLDB;
import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB; import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import main.java.com.djrapitops.plan.database.tables.*; import main.java.com.djrapitops.plan.database.tables.*;
import main.java.com.djrapitops.plan.systems.info.server.ServerInfo; import main.java.com.djrapitops.plan.systems.info.server.ServerInfo;
@ -91,6 +92,15 @@ public class DatabaseTest {
db.init(); db.init();
} }
@Test
public void testNoExceptionWhenCommitEmpty() throws Exception {
db.init();
db.commit(((SQLDB) db).getConnection());
db.commit(((SQLDB) db).getConnection());
db.commit(((SQLDB) db).getConnection());
}
@Test @Test
public void testSQLiteGetConfigName() { public void testSQLiteGetConfigName() {
assertEquals("sqlite", db.getConfigName()); assertEquals("sqlite", db.getConfigName());
@ -112,7 +122,7 @@ public class DatabaseTest {
} }
@Test @Test
public void testSaveCommandUse() throws SQLException { public void testSaveCommandUse() throws SQLException, DatabaseInitException {
CommandUseTable commandUseTable = db.getCommandUseTable(); CommandUseTable commandUseTable = db.getCommandUseTable();
Map<String, Integer> expected = new HashMap<>(); Map<String, Integer> expected = new HashMap<>();
@ -139,7 +149,7 @@ public class DatabaseTest {
commandUseTable.commandUsed("roiergbnougbierubieugbeigubeigubgierbgeugeg"); commandUseTable.commandUsed("roiergbnougbierubieugbeigubeigubgierbgeugeg");
} }
expected.remove("roiergbnougbierubieugbeigubeigubgierbgeugeg"); commitTest();
Map<String, Integer> commandUse = db.getCommandUse(); Map<String, Integer> commandUse = db.getCommandUse();
assertEquals(expected, commandUse); assertEquals(expected, commandUse);
@ -207,6 +217,8 @@ public class DatabaseTest {
tpsTable.insertTPS(tps); tpsTable.insertTPS(tps);
} }
commitTest();
assertEquals(expected, tpsTable.getTPSData()); assertEquals(expected, tpsTable.getTPSData());
} }
@ -233,7 +245,7 @@ public class DatabaseTest {
} }
@Test @Test
public void testIPTable() throws SQLException { public void testIPTable() throws SQLException, DatabaseInitException {
saveUserOne(); saveUserOne();
IPsTable ipsTable = db.getIpsTable(); IPsTable ipsTable = db.getIpsTable();
@ -242,6 +254,7 @@ public class DatabaseTest {
ipsTable.saveIP(uuid, expectedIP, expectedGeoLoc); ipsTable.saveIP(uuid, expectedIP, expectedGeoLoc);
ipsTable.saveIP(uuid, expectedIP, expectedGeoLoc); ipsTable.saveIP(uuid, expectedIP, expectedGeoLoc);
commitTest();
List<String> ips = ipsTable.getIps(uuid); List<String> ips = ipsTable.getIps(uuid);
assertEquals(1, ips.size()); assertEquals(1, ips.size());
@ -257,14 +270,15 @@ public class DatabaseTest {
assertEquals(expectedGeoLoc, result.get()); assertEquals(expectedGeoLoc, result.get());
} }
@Test // Does not test getting sessions from another server. @Test
public void testNicknamesTable() throws SQLException { public void testNicknamesTable() throws SQLException, DatabaseInitException {
saveUserOne(); saveUserOne();
NicknamesTable nickTable = db.getNicknamesTable(); NicknamesTable nickTable = db.getNicknamesTable();
String expected = "TestNickname"; String expected = "TestNickname";
nickTable.saveUserName(uuid, expected); nickTable.saveUserName(uuid, expected);
nickTable.saveUserName(uuid, expected); nickTable.saveUserName(uuid, expected);
commitTest();
List<String> nicknames = nickTable.getNicknames(uuid); List<String> nicknames = nickTable.getNicknames(uuid);
assertEquals(1, nicknames.size()); assertEquals(1, nicknames.size());
@ -275,10 +289,12 @@ public class DatabaseTest {
} }
@Test @Test
public void testSecurityTable() throws SQLException { public void testSecurityTable() throws SQLException, DatabaseInitException {
SecurityTable securityTable = db.getSecurityTable(); SecurityTable securityTable = db.getSecurityTable();
WebUser expected = new WebUser("Test", "RandomGarbageBlah", 0); WebUser expected = new WebUser("Test", "RandomGarbageBlah", 0);
securityTable.addNewUser(expected); securityTable.addNewUser(expected);
commitTest();
assertTrue(securityTable.userExists("Test")); assertTrue(securityTable.userExists("Test"));
WebUser test = securityTable.getWebUser("Test"); WebUser test = securityTable.getWebUser("Test");
assertEquals(expected, test); assertEquals(expected, test);
@ -296,11 +312,13 @@ public class DatabaseTest {
} }
@Test @Test
public void testWorldTable() throws SQLException { public void testWorldTable() throws SQLException, DatabaseInitException {
WorldTable worldTable = db.getWorldTable(); WorldTable worldTable = db.getWorldTable();
List<String> worlds = Arrays.asList("Test", "Test2", "Test3"); List<String> worlds = Arrays.asList("Test", "Test2", "Test3");
worldTable.saveWorlds(worlds); worldTable.saveWorlds(worlds);
commitTest();
List<String> saved = worldTable.getWorlds(); List<String> saved = worldTable.getWorlds();
assertEquals(worlds, saved); assertEquals(worlds, saved);
} }
@ -330,7 +348,7 @@ public class DatabaseTest {
} }
@Test @Test
public void testSessionPlaytimeSaving() throws SQLException { public void testSessionPlaytimeSaving() throws SQLException, DatabaseInitException {
saveTwoWorlds(); saveTwoWorlds();
saveUserOne(); saveUserOne();
saveUserTwo(); saveUserTwo();
@ -346,6 +364,8 @@ public class DatabaseTest {
SessionsTable sessionsTable = db.getSessionsTable(); SessionsTable sessionsTable = db.getSessionsTable();
sessionsTable.saveSession(uuid, session); sessionsTable.saveSession(uuid, session);
commitTest();
assertEquals(expectedLength, sessionsTable.getPlaytime(uuid)); assertEquals(expectedLength, sessionsTable.getPlaytime(uuid));
assertEquals(0L, sessionsTable.getPlaytime(uuid, 30000L)); assertEquals(0L, sessionsTable.getPlaytime(uuid, 30000L));
@ -358,7 +378,7 @@ public class DatabaseTest {
} }
@Test @Test
public void testSessionSaving() throws SQLException { public void testSessionSaving() throws SQLException, DatabaseInitException {
saveUserOne(); saveUserOne();
saveUserTwo(); saveUserTwo();
@ -370,6 +390,8 @@ public class DatabaseTest {
SessionsTable sessionsTable = db.getSessionsTable(); SessionsTable sessionsTable = db.getSessionsTable();
sessionsTable.saveSession(uuid, session); sessionsTable.saveSession(uuid, session);
commitTest();
Map<String, List<Session>> sessions = sessionsTable.getSessions(uuid); Map<String, List<Session>> sessions = sessionsTable.getSessions(uuid);
for (Map.Entry<String, List<Session>> entry : sessions.entrySet()) { for (Map.Entry<String, List<Session>> entry : sessions.entrySet()) {
@ -394,7 +416,7 @@ public class DatabaseTest {
} }
@Test @Test
public void testUserInfoTableRegisterUnRegistered() throws SQLException { public void testUserInfoTableRegisterUnRegistered() throws SQLException, DatabaseInitException {
UserInfoTable userInfoTable = db.getUserInfoTable(); UserInfoTable userInfoTable = db.getUserInfoTable();
assertFalse(userInfoTable.isRegistered(uuid)); assertFalse(userInfoTable.isRegistered(uuid));
UsersTable usersTable = db.getUsersTable(); UsersTable usersTable = db.getUsersTable();
@ -402,6 +424,8 @@ public class DatabaseTest {
userInfoTable.registerUserInfo(uuid, 123456789L); userInfoTable.registerUserInfo(uuid, 123456789L);
commitTest();
assertTrue(usersTable.isRegistered(uuid)); assertTrue(usersTable.isRegistered(uuid));
assertTrue(userInfoTable.isRegistered(uuid)); assertTrue(userInfoTable.isRegistered(uuid));
@ -415,7 +439,7 @@ public class DatabaseTest {
} }
@Test @Test
public void testUserInfoTableRegisterRegistered() throws SQLException { public void testUserInfoTableRegisterRegistered() throws SQLException, DatabaseInitException {
saveUserOne(); saveUserOne();
UsersTable usersTable = db.getUsersTable(); UsersTable usersTable = db.getUsersTable();
assertTrue(usersTable.isRegistered(uuid)); assertTrue(usersTable.isRegistered(uuid));
@ -424,6 +448,7 @@ public class DatabaseTest {
assertFalse(userInfoTable.isRegistered(uuid)); assertFalse(userInfoTable.isRegistered(uuid));
userInfoTable.registerUserInfo(uuid, 223456789L); userInfoTable.registerUserInfo(uuid, 223456789L);
commitTest();
assertTrue(usersTable.isRegistered(uuid)); assertTrue(usersTable.isRegistered(uuid));
assertTrue(userInfoTable.isRegistered(uuid)); assertTrue(userInfoTable.isRegistered(uuid));
@ -436,28 +461,33 @@ public class DatabaseTest {
assertFalse(userInfo.isBanned()); assertFalse(userInfo.isBanned());
assertFalse(userInfo.isOpped()); assertFalse(userInfo.isOpped());
assertEquals(userInfo, userInfoTable.getAllUserInfo().get(0)); assertEquals(userInfo, userInfoTable.getServerUserInfo().get(0));
} }
@Test @Test
public void testUserInfoTableUpdateBannedOpped() throws SQLException { public void testUserInfoTableUpdateBannedOpped() throws SQLException, DatabaseInitException {
UserInfoTable userInfoTable = db.getUserInfoTable(); UserInfoTable userInfoTable = db.getUserInfoTable();
userInfoTable.registerUserInfo(uuid, 223456789L); userInfoTable.registerUserInfo(uuid, 223456789L);
assertTrue(userInfoTable.isRegistered(uuid)); assertTrue(userInfoTable.isRegistered(uuid));
userInfoTable.updateOpAndBanStatus(uuid, true, true); userInfoTable.updateOpAndBanStatus(uuid, true, true);
commitTest();
UserInfo userInfo = userInfoTable.getUserInfo(uuid); UserInfo userInfo = userInfoTable.getUserInfo(uuid);
assertTrue(userInfo.isBanned()); assertTrue(userInfo.isBanned());
assertTrue(userInfo.isOpped()); assertTrue(userInfo.isOpped());
userInfoTable.updateOpAndBanStatus(uuid, false, true); userInfoTable.updateOpAndBanStatus(uuid, false, true);
commitTest();
userInfo = userInfoTable.getUserInfo(uuid); userInfo = userInfoTable.getUserInfo(uuid);
assertTrue(userInfo.isBanned()); assertTrue(userInfo.isBanned());
assertFalse(userInfo.isOpped()); assertFalse(userInfo.isOpped());
userInfoTable.updateOpAndBanStatus(uuid, false, false); userInfoTable.updateOpAndBanStatus(uuid, false, false);
commitTest();
userInfo = userInfoTable.getUserInfo(uuid); userInfo = userInfoTable.getUserInfo(uuid);
assertFalse(userInfo.isBanned()); assertFalse(userInfo.isBanned());
@ -465,13 +495,16 @@ public class DatabaseTest {
} }
@Test @Test
public void testUsersTableUpdateName() throws SQLException { public void testUsersTableUpdateName() throws SQLException, DatabaseInitException {
saveUserOne(); saveUserOne();
UsersTable usersTable = db.getUsersTable(); UsersTable usersTable = db.getUsersTable();
assertEquals(uuid, usersTable.getUuidOf("Test")); assertEquals(uuid, usersTable.getUuidOf("Test"));
usersTable.updateName(uuid, "NewName"); usersTable.updateName(uuid, "NewName");
commitTest();
assertNull(usersTable.getUuidOf("Test")); assertNull(usersTable.getUuidOf("Test"));
assertEquals("NewName", usersTable.getPlayerName(uuid)); assertEquals("NewName", usersTable.getPlayerName(uuid));
@ -479,7 +512,7 @@ public class DatabaseTest {
} }
@Test @Test
public void testUsersTableKickSaving() throws SQLException { public void testUsersTableKickSaving() throws SQLException, DatabaseInitException {
saveUserOne(); saveUserOne();
UsersTable usersTable = db.getUsersTable(); UsersTable usersTable = db.getUsersTable();
assertEquals(0, usersTable.getTimesKicked(uuid)); assertEquals(0, usersTable.getTimesKicked(uuid));
@ -489,7 +522,7 @@ public class DatabaseTest {
for (int i = 0; i < random + 1; i++) { for (int i = 0; i < random + 1; i++) {
usersTable.kicked(uuid); usersTable.kicked(uuid);
} }
commitTest();
assertEquals(random + 1, usersTable.getTimesKicked(uuid)); assertEquals(random + 1, usersTable.getTimesKicked(uuid));
} }
@ -602,7 +635,7 @@ public class DatabaseTest {
} }
@Test @Test
public void testServerTableBungeeSave() throws SQLException { public void testServerTableBungeeSave() throws SQLException, DatabaseInitException {
ServerTable serverTable = db.getServerTable(); ServerTable serverTable = db.getServerTable();
Optional<ServerInfo> bungeeInfo = serverTable.getBungeeInfo(); Optional<ServerInfo> bungeeInfo = serverTable.getBungeeInfo();
@ -612,6 +645,8 @@ public class DatabaseTest {
ServerInfo bungeeCord = new ServerInfo(-1, bungeeUUID, "BungeeCord", "Random:1234", 20); ServerInfo bungeeCord = new ServerInfo(-1, bungeeUUID, "BungeeCord", "Random:1234", 20);
serverTable.saveCurrentServerInfo(bungeeCord); serverTable.saveCurrentServerInfo(bungeeCord);
commitTest();
bungeeCord.setId(2); bungeeCord.setId(2);
bungeeInfo = serverTable.getBungeeInfo(); bungeeInfo = serverTable.getBungeeInfo();
@ -624,7 +659,7 @@ public class DatabaseTest {
} }
@Test @Test
public void testServerTableBungee() throws SQLException { public void testServerTableBungee() throws SQLException, DatabaseInitException {
testServerTableBungeeSave(); testServerTableBungeeSave();
ServerTable serverTable = db.getServerTable(); ServerTable serverTable = db.getServerTable();
@ -637,4 +672,55 @@ public class DatabaseTest {
Map<UUID, Long> lastSeen = db.getSessionsTable().getLastSeenForAllPlayers(); Map<UUID, Long> lastSeen = db.getSessionsTable().getLastSeenForAllPlayers();
assertTrue(lastSeen.isEmpty()); assertTrue(lastSeen.isEmpty());
} }
private void commitTest() throws DatabaseInitException, SQLException {
db.close();
db.init();
}
@Test
public void testSessionTableGetInfoOfServer() throws SQLException, DatabaseInitException {
saveUserOne();
saveUserTwo();
Session session = new Session(12345L, "", "");
session.endSession(22345L);
session.setWorldTimes(createWorldTimes());
session.setPlayerKills(createKills());
SessionsTable sessionsTable = db.getSessionsTable();
sessionsTable.saveSession(uuid, session);
commitTest();
Map<UUID, List<Session>> sessions = sessionsTable.getSessionInfoOfServer();
session.setPlayerKills(new ArrayList<>());
session.setWorldTimes(new WorldTimes(new HashMap<>()));
List<Session> sSessions = sessions.get(uuid);
assertFalse(sessions.isEmpty());
assertNotNull(sSessions);
assertFalse(sSessions.isEmpty());
assertEquals(session, sSessions.get(0));
}
@Test
public void testKillTableGetKillsOfServer() throws SQLException, DatabaseInitException {
saveUserOne();
saveUserTwo();
KillsTable killsTable = db.getKillsTable();
List<PlayerKill> expected = createKills();
killsTable.savePlayerKills(uuid, 1, expected);
commitTest();
Map<UUID, List<PlayerKill>> playerKills = killsTable.getPlayerKills();
List<PlayerKill> kills = playerKills.get(uuid);
assertFalse(playerKills.isEmpty());
assertNotNull(kills);
assertFalse(kills.isEmpty());
assertEquals(expected, kills);
}
} }

View File

@ -0,0 +1,20 @@
package main.java.com.djrapitops.plan.database.tables;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* //TODO Class Javadoc Comment
*
* @author Rsl1122
*/
public class ActionsTest {
@Test
public void getUnknownActionsEnum() {
Actions action = Actions.getById(Integer.MIN_VALUE);
assertEquals(Actions.UNKNOWN, action);
}
}

View File

@ -10,6 +10,7 @@ import main.java.com.djrapitops.plan.data.time.WorldTimes;
import main.java.com.djrapitops.plan.utilities.analysis.Point; import main.java.com.djrapitops.plan.utilities.analysis.Point;
import main.java.com.djrapitops.plan.utilities.html.graphs.*; import main.java.com.djrapitops.plan.utilities.html.graphs.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import test.java.utils.RandomData; import test.java.utils.RandomData;
@ -53,7 +54,30 @@ public class GraphTest {
assertEquals("[[0,0.0],[9,9.0]]", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsList)); assertEquals("[[0,0.0],[9,9.0]]", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsList));
assertEquals("[[0,0.0],[9,9.0]]", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsList)); assertEquals("[[0,0.0],[9,9.0]]", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsList));
assertEquals("[{'code':'1','value':1},{'code':'2','value':2},{'code':'3','value':3},{'code':'4','value':4},{'code':'5','value':5},{'code':'6','value':6},{'code':'7','value':7},{'code':'8','value':8},{'code':'9','value':9}]", WorldMapCreator.createDataSeries(geoList)); assertEquals("[{'code':'1','value':1},{'code':'2','value':2},{'code':'3','value':3},{'code':'4','value':4},{'code':'5','value':5},{'code':'6','value':6},{'code':'7','value':7},{'code':'8','value':8},{'code':'9','value':9}]", WorldMapCreator.createDataSeries(geoList));
assertEquals(Arrays.toString(WorldPieCreator.createSeriesData(worldTimes)), "[[{name:'WORLD',y:0,drilldown: 'WORLD'}], {name:'WORLD', id:'WORLD',data: []}]"); assertEquals("[[{name:'WORLD',y:0,drilldown: 'WORLD'}], {name:'WORLD', id:'WORLD',data: []}]", Arrays.toString(WorldPieCreator.createSeriesData(worldTimes)));
}
@Test
public void testGraphCreatorsForBracketMistakes() {
String[] series = new String[]{
CPUGraphCreator.buildSeriesDataString(tpsList),
PlayerActivityGraphCreator.buildSeriesDataString(tpsList),
PunchCardGraphCreator.createDataSeries(sessionList),
RamGraphCreator.buildSeriesDataString(tpsList),
TPSGraphCreator.buildSeriesDataString(tpsList),
WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsList),
WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsList),
WorldMapCreator.createDataSeries(geoList),
Arrays.toString(WorldPieCreator.createSeriesData(worldTimes))
};
for (String test : series) {
int opened = StringUtils.countMatches(test, "{");
int closed = StringUtils.countMatches(test, "}");
Assert.assertEquals(opened, closed);
opened = StringUtils.countMatches(test, "[");
closed = StringUtils.countMatches(test, "]");
Assert.assertEquals(opened, closed);
}
} }
@Test @Test

View File

@ -4,12 +4,11 @@
*/ */
package test.java.utils; package test.java.utils;
import main.java.com.djrapitops.plan.database.DatabaseTest;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.Suite; import org.junit.runners.Suite;
import main.java.com.djrapitops.plan.database.DatabaseCommitTest;
import main.java.com.djrapitops.plan.database.DatabaseTest;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -18,7 +17,7 @@ import java.io.IOException;
* @author Fuzzlemann * @author Fuzzlemann
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)
@Suite.SuiteClasses({DatabaseCommitTest.class, DatabaseTest.class}) @Suite.SuiteClasses({DatabaseTest.class})
public class DBTestSuite { public class DBTestSuite {
@BeforeClass @BeforeClass
public static void setUp() throws IOException { public static void setUp() throws IOException {