Updated Javadoc

This commit is contained in:
Rsl1122 2017-10-02 21:52:13 +03:00
parent 46f1ee40b2
commit 86ea8ec02c
48 changed files with 210 additions and 341 deletions

View File

@ -328,8 +328,6 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
* Initializes the database according to settings in the config. * Initializes the database according to settings in the config.
* <p> * <p>
* If database connection can not be established plugin is disabled. * If database connection can not be established plugin is disabled.
*
* @return true if init was successful, false if not.
*/ */
private void initDatabase() throws DatabaseInitException { private void initDatabase() throws DatabaseInitException {
databases = new HashSet<>(); databases = new HashSet<>();

View File

@ -58,7 +58,7 @@ public class ServerSpecificSettings {
} }
config.set(path, value); config.set(path, value);
Log.debug(" " + path + ": " + value); Log.debug(" " + path + ": " + value);
} catch (NullPointerException e) { } catch (NullPointerException ignored) {
} }
changedSomething = true; changedSomething = true;
} }

View File

@ -53,8 +53,8 @@ public class AnalyzeCommand extends SubCommand {
} }
Plan plugin = Plan.getInstance(); Plan plugin = Plan.getInstance();
Optional<String> serverName = plugin.getDB().getServerTable().getServerName(serverUUID); Optional<String> serverName = plugin.getDB().getServerTable().getServerName(serverUUID);
if (serverName.isPresent()) { serverName.ifPresent(name -> {
String target = "/server/" + serverName.get(); String target = "/server/" + name;
String url = plugin.getInfoManager().getLinkTo(target); String url = plugin.getInfoManager().getLinkTo(target);
String message = Locale.get(Msg.CMD_INFO_LINK).toString(); String message = Locale.get(Msg.CMD_INFO_LINK).toString();
@ -70,7 +70,7 @@ public class AnalyzeCommand extends SubCommand {
} }
sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString()); sender.sendMessage(Locale.get(Msg.CMD_CONSTANT_FOOTER).toString());
} }
} });
} }
@Override @Override

View File

@ -13,8 +13,8 @@ import java.util.Objects;
* <p> * <p>
* Includes: * Includes:
* <ul> * <ul>
* <li>World & GameMode playtimes</li> * <li>World and GameMode playtimes</li>
* <li>Player & Mob kills</li> * <li>Player and Mob kills</li>
* <li>Deaths</li> * <li>Deaths</li>
* </ul> * </ul>
* <p> * <p>

View File

@ -118,10 +118,8 @@ public abstract class Database {
/** /**
* Initiates the database. * Initiates the database.
* <p>
* Default method returns false.
* *
* @return Was the initiation successful? * @throws DatabaseInitException if SQLException or other exception occurs.
*/ */
public void init() throws DatabaseInitException { public void init() throws DatabaseInitException {
} }
@ -175,7 +173,7 @@ public abstract class Database {
public abstract void setVersion(int version) throws SQLException; public abstract void setVersion(int version) throws SQLException;
/** /**
* Closes the database & it's resources. * Closes the database and it's resources.
* *
* @throws SQLException If a database error occurs. * @throws SQLException If a database error occurs.
*/ */

View File

@ -18,7 +18,7 @@ import java.sql.SQLException;
import java.util.UUID; import java.util.UUID;
/** /**
* Class containing main logic for different data related save & load functionality. * Class containing main logic for different data related save and load functionality.
* *
* @author Rsl1122 * @author Rsl1122
* @since 2.0.0 * @since 2.0.0
@ -29,9 +29,6 @@ public abstract class SQLDB extends Database {
private boolean open = false; private boolean open = false;
private ITask dbCleanTask; private ITask dbCleanTask;
/**
* @param plugin
*/
public SQLDB(IPlan plugin) { public SQLDB(IPlan plugin) {
super(plugin); super(plugin);
usingMySQL = getName().equals("MySQL"); usingMySQL = getName().equals("MySQL");
@ -62,7 +59,7 @@ public abstract class SQLDB extends Database {
* Converts Unsaved Bukkit player files to database data. * Converts Unsaved Bukkit player files to database data.
* Cleans the database. * Cleans the database.
* *
* @return Was the Initialization successful. * @throws DatabaseInitException if Database fails to initiate.
*/ */
@Override @Override
public void init() throws DatabaseInitException { public void init() throws DatabaseInitException {
@ -140,8 +137,6 @@ public abstract class SQLDB extends Database {
* Creates the tables that contain data. * Creates the tables that contain data.
* <p> * <p>
* Updates table columns to latest schema. * Updates table columns to latest schema.
*
* @return true if successful.
*/ */
private void createTables() throws DatabaseInitException { private void createTables() throws DatabaseInitException {
Benchmark.start("Create tables"); Benchmark.start("Create tables");
@ -152,7 +147,9 @@ public abstract class SQLDB extends Database {
} }
/** /**
* @return * Get all tables in a good order.
*
* @return Table array.
*/ */
public Table[] getAllTables() { public Table[] getAllTables() {
return new Table[]{ return new Table[]{
@ -164,7 +161,7 @@ public abstract class SQLDB extends Database {
} }
/** /**
* Get all tables except securityTable for removal of user data. * Get all tables for removal of data.
* *
* @return Tables in the order the data should be removed in. * @return Tables in the order the data should be removed in.
*/ */
@ -184,7 +181,9 @@ public abstract class SQLDB extends Database {
public abstract void setupDataSource() throws DatabaseInitException; public abstract void setupDataSource() throws DatabaseInitException;
/** /**
* @throws SQLException * Closes the SQLDB
*
* @throws SQLException DB Error
*/ */
@Override @Override
public void close() throws SQLException { public void close() throws SQLException {
@ -205,10 +204,6 @@ public abstract class SQLDB extends Database {
return versionTable.getVersion(); return versionTable.getVersion();
} }
/**
* @param version
* @throws SQLException
*/
@Override @Override
public void setVersion(int version) throws SQLException { public void setVersion(int version) throws SQLException {
versionTable.setVersion(version); versionTable.setVersion(version);
@ -219,10 +214,6 @@ public abstract class SQLDB extends Database {
return versionTable.isNewDatabase(); return versionTable.isNewDatabase();
} }
/**
* @param uuid
* @return
*/
@Override @Override
public boolean wasSeenBefore(UUID uuid) { public boolean wasSeenBefore(UUID uuid) {
if (uuid == null) { if (uuid == null) {
@ -267,9 +258,6 @@ public abstract class SQLDB extends Database {
Log.info("Clean complete."); Log.info("Clean complete.");
} }
/**
* @return
*/
@Override @Override
public void removeAllData() throws SQLException { public void removeAllData() throws SQLException {
setStatus("Clearing all data"); setStatus("Clearing all data");

View File

@ -22,10 +22,6 @@ public class SQLiteDB extends SQLDB {
this(plugin, "database"); this(plugin, "database");
} }
/**
* @param plugin
* @param dbName
*/
public SQLiteDB(Plan plugin, String dbName) { public SQLiteDB(Plan plugin, String dbName) {
super(plugin); super(plugin);
this.dbName = dbName; this.dbName = dbName;

View File

@ -1,7 +1,7 @@
package main.java.com.djrapitops.plan.database.sql; package main.java.com.djrapitops.plan.database.sql;
/** /**
* SqlParser Class for parsing table creation, removal & modification statements. * SqlParser Class for parsing table creation, removal and modification statements.
* *
* @author Rsl1122 * @author Rsl1122
* @since 3.7.0 * @since 3.7.0

View File

@ -94,9 +94,9 @@ public class ActionsTable extends UserIDTable {
/** /**
* Used to get all Actions done by a user on this server. * Used to get all Actions done by a user on this server.
* *
* @param uuid * @param uuid UUID of the player
* @return * @return List of actions done by the player. Does not include the kills.
* @throws SQLException * @throws SQLException DB Error
*/ */
public List<Action> getActions(UUID uuid) throws SQLException { public List<Action> getActions(UUID uuid) throws SQLException {
List<Action> actions = new ArrayList<>(); List<Action> actions = new ArrayList<>();

View File

@ -29,10 +29,6 @@ public class CommandUseTable extends Table {
private final ServerTable serverTable; private final ServerTable serverTable;
private String insertStatement; private String insertStatement;
/**
* @param db
* @param usingMySQL
*/
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();
@ -43,9 +39,6 @@ public class CommandUseTable extends Table {
+ ") VALUES (?, ?, " + serverTable.statementSelectServerID + ")"; + ") VALUES (?, ?, " + serverTable.statementSelectServerID + ")";
} }
/**
* @return
*/
@Override @Override
public void createTable() throws DBCreateTableException { public void createTable() throws DBCreateTableException {
ServerTable serverTable = db.getServerTable(); ServerTable serverTable = db.getServerTable();
@ -64,7 +57,7 @@ public class CommandUseTable extends Table {
* Used to get all commands used in this server. * Used to get all commands used in this server.
* *
* @return command - times used Map * @return command - times used Map
* @throws SQLException * @throws SQLException DB Error
*/ */
public Map<String, Integer> getCommandUse() throws SQLException { public Map<String, Integer> getCommandUse() throws SQLException {
return getCommandUse(Plan.getServerUUID()); return getCommandUse(Plan.getServerUUID());
@ -75,7 +68,7 @@ public class CommandUseTable extends Table {
* *
* @param serverUUID UUID of the server. * @param serverUUID UUID of the server.
* @return command - times used Map * @return command - times used Map
* @throws SQLException * @throws SQLException DB Error
*/ */
public Map<String, Integer> getCommandUse(UUID serverUUID) throws SQLException { public Map<String, Integer> getCommandUse(UUID serverUUID) throws SQLException {
Map<String, Integer> commandUse = new HashMap<>(); Map<String, Integer> commandUse = new HashMap<>();

View File

@ -37,9 +37,6 @@ public class IPsTable extends UserIDTable {
+ "?, ?)"; + "?, ?)";
} }
/**
* @return if the table was created successfully
*/
@Override @Override
public void createTable() throws DBCreateTableException { public void createTable() throws DBCreateTableException {
createTable(TableSqlParser.createTable(tableName) createTable(TableSqlParser.createTable(tableName)

View File

@ -30,10 +30,6 @@ public class KillsTable extends UserIDTable {
private final SessionsTable sessionsTable; private final SessionsTable sessionsTable;
private String insertStatement; private String insertStatement;
/**
* @param db
* @param usingMySQL
*/
public KillsTable(SQLDB db, boolean usingMySQL) { public KillsTable(SQLDB db, boolean usingMySQL) {
super("plan_kills", db, usingMySQL); super("plan_kills", db, usingMySQL);
sessionsTable = db.getSessionsTable(); sessionsTable = db.getSessionsTable();
@ -49,9 +45,6 @@ public class KillsTable extends UserIDTable {
+ "?, ?, ?)"; + "?, ?, ?)";
} }
/**
* @return
*/
@Override @Override
public void createTable() throws DBCreateTableException { public void createTable() throws DBCreateTableException {
createTable(TableSqlParser.createTable(tableName) createTable(TableSqlParser.createTable(tableName)
@ -154,7 +147,7 @@ public class KillsTable extends UserIDTable {
public Map<UUID, List<PlayerKill>> getPlayerKills(UUID serverUUID) throws SQLException { public Map<UUID, List<PlayerKill>> getPlayerKills(UUID serverUUID) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
try (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
String usersVictimIDColumn = usersTable + "." + usersTable.getColumnID(); String usersVictimIDColumn = usersTable + "." + usersTable.getColumnID();
String usersKillerIDColumn = "a." + usersTable.getColumnID(); String usersKillerIDColumn = "a." + usersTable.getColumnID();
String usersVictimUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as victim_uuid"; String usersVictimUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as victim_uuid";
@ -206,7 +199,7 @@ public class KillsTable extends UserIDTable {
return; return;
} }
PreparedStatement statement = null; PreparedStatement statement = null;
try (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
statement = connection.prepareStatement(insertStatement); statement = connection.prepareStatement(insertStatement);
String[] gms = GMTimes.getGMKeyArray(); String[] gms = GMTimes.getGMKeyArray();
for (UUID serverUUID : allSessions.keySet()) { for (UUID serverUUID : allSessions.keySet()) {
@ -240,7 +233,7 @@ public class KillsTable extends UserIDTable {
public Map<Integer, List<PlayerKill>> getAllPlayerKillsBySessionID() throws SQLException { public Map<Integer, List<PlayerKill>> getAllPlayerKillsBySessionID() throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
try (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
String usersIDColumn = usersTable + "." + usersTable.getColumnID(); String usersIDColumn = usersTable + "." + usersTable.getColumnID();
String usersUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as victim_uuid"; String usersUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as victim_uuid";
statement = connection.prepareStatement("SELECT " + statement = connection.prepareStatement("SELECT " +

View File

@ -41,9 +41,6 @@ public class NicknamesTable extends UserIDTable {
"?)"; "?)";
} }
/**
* @return if the table was created successfully
*/
@Override @Override
public void createTable() throws DBCreateTableException { public void createTable() throws DBCreateTableException {
createTable(TableSqlParser.createTable(tableName) createTable(TableSqlParser.createTable(tableName)

View File

@ -108,7 +108,7 @@ public class ServerTable extends Table {
* *
* @param info Info to instert (All variables should be present. * @param info Info to instert (All variables should be present.
* @throws IllegalStateException if one of the ServerInfo variables is null * @throws IllegalStateException if one of the ServerInfo variables is null
* @throws SQLException * @throws SQLException DB Error
*/ */
private void saveNewServerInfo(ServerInfo info) throws SQLException { private void saveNewServerInfo(ServerInfo info) throws SQLException {
UUID uuid = info.getUuid(); UUID uuid = info.getUuid();
@ -137,7 +137,7 @@ public class ServerTable extends Table {
* *
* @param serverUUID UUID of the server. * @param serverUUID UUID of the server.
* @return ID or or empty optional. * @return ID or or empty optional.
* @throws SQLException * @throws SQLException DB Error
*/ */
public Optional<Integer> getServerID(UUID serverUUID) throws SQLException { public Optional<Integer> getServerID(UUID serverUUID) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
@ -164,7 +164,7 @@ public class ServerTable extends Table {
* *
* @param serverUUID UUID of the server. * @param serverUUID UUID of the server.
* @return Name or empty optional. * @return Name or empty optional.
* @throws SQLException * @throws SQLException DB Error
*/ */
public Optional<String> getServerName(UUID serverUUID) throws SQLException { public Optional<String> getServerName(UUID serverUUID) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
@ -209,7 +209,7 @@ public class ServerTable extends Table {
* Used to get BungeeCord WebServer info if present. * Used to get BungeeCord WebServer info if present.
* *
* @return information about Bungee server. * @return information about Bungee server.
* @throws SQLException * @throws SQLException DB Error
*/ */
public Optional<ServerInfo> getBungeeInfo() throws SQLException { public Optional<ServerInfo> getBungeeInfo() throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;

View File

@ -32,10 +32,6 @@ public class SessionsTable extends UserIDTable {
private final ServerTable serverTable; private final ServerTable serverTable;
private String insertStatement; private String insertStatement;
/**
* @param db
* @param usingMySQL
*/
public SessionsTable(SQLDB db, boolean usingMySQL) { public SessionsTable(SQLDB db, boolean usingMySQL) {
super("plan_sessions", db, usingMySQL); super("plan_sessions", db, usingMySQL);
serverTable = db.getServerTable(); serverTable = db.getServerTable();
@ -52,9 +48,6 @@ public class SessionsTable extends UserIDTable {
+ serverTable.statementSelectServerID + ")"; + serverTable.statementSelectServerID + ")";
} }
/**
* @return
*/
@Override @Override
public void createTable() throws DBCreateTableException { public void createTable() throws DBCreateTableException {
createTable(TableSqlParser.createTable(this.tableName) createTable(TableSqlParser.createTable(this.tableName)
@ -79,7 +72,7 @@ public class SessionsTable extends UserIDTable {
* *
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @param session Session of the player that has ended ({@code endSession} has been called) * @param session Session of the player that has ended ({@code endSession} has been called)
* @throws SQLException * @throws SQLException DB Error
*/ */
public void saveSession(UUID uuid, Session session) throws SQLException { public void saveSession(UUID uuid, Session session) throws SQLException {
saveSessionInformation(uuid, session); saveSessionInformation(uuid, session);
@ -99,7 +92,7 @@ public class SessionsTable extends UserIDTable {
* *
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @param session Session of the player that has ended ({@code endSession} has been called) * @param session Session of the player that has ended ({@code endSession} has been called)
* @throws SQLException * @throws SQLException DB Error
*/ */
private void saveSessionInformation(UUID uuid, Session session) throws SQLException { private void saveSessionInformation(UUID uuid, Session session) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
@ -156,7 +149,7 @@ public class SessionsTable extends UserIDTable {
* *
* @param uuid UUID of the player * @param uuid UUID of the player
* @return Map with Sessions that don't contain Kills or WorldTimes. * @return Map with Sessions that don't contain Kills or WorldTimes.
* @throws SQLException * @throws SQLException DB Error
*/ */
private Map<String, List<Session>> getSessionInformation(UUID uuid) throws SQLException { private Map<String, List<Session>> getSessionInformation(UUID uuid) throws SQLException {
Map<Integer, String> serverNames = serverTable.getServerNames(); Map<Integer, String> serverNames = serverTable.getServerNames();
@ -205,7 +198,7 @@ public class SessionsTable extends UserIDTable {
* *
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @return Milliseconds played on THIS server. 0 if player or server not found. * @return Milliseconds played on THIS server. 0 if player or server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public long getPlaytime(UUID uuid) throws SQLException { public long getPlaytime(UUID uuid) throws SQLException {
return getPlaytime(uuid, Plan.getServerUUID()); return getPlaytime(uuid, Plan.getServerUUID());
@ -217,7 +210,7 @@ public class SessionsTable extends UserIDTable {
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @param afterDate Epoch ms (Playtime after this date is calculated) * @param afterDate Epoch ms (Playtime after this date is calculated)
* @return Milliseconds played on THIS server. 0 if player or server not found. * @return Milliseconds played on THIS server. 0 if player or server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public long getPlaytime(UUID uuid, long afterDate) throws SQLException { public long getPlaytime(UUID uuid, long afterDate) throws SQLException {
return getPlaytime(uuid, Plan.getServerUUID(), afterDate); return getPlaytime(uuid, Plan.getServerUUID(), afterDate);
@ -229,7 +222,7 @@ public class SessionsTable extends UserIDTable {
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @param serverUUID UUID of the server. @see ServerTable * @param serverUUID UUID of the server. @see ServerTable
* @return Milliseconds played on the server. 0 if player or server not found. * @return Milliseconds played on the server. 0 if player or server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public long getPlaytime(UUID uuid, UUID serverUUID) throws SQLException { public long getPlaytime(UUID uuid, UUID serverUUID) throws SQLException {
return getPlaytime(uuid, serverUUID, 0L); return getPlaytime(uuid, serverUUID, 0L);
@ -242,7 +235,7 @@ public class SessionsTable extends UserIDTable {
* @param serverUUID UUID of the server. @see ServerTable * @param serverUUID UUID of the server. @see ServerTable
* @param afterDate Epoch ms (Playtime after this date is calculated) * @param afterDate Epoch ms (Playtime after this date is calculated)
* @return Milliseconds played after given epoch ms on the server. 0 if player or server not found. * @return Milliseconds played after given epoch ms on the server. 0 if player or server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public long getPlaytime(UUID uuid, UUID serverUUID, long afterDate) throws SQLException { public long getPlaytime(UUID uuid, UUID serverUUID, long afterDate) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
@ -272,7 +265,7 @@ public class SessionsTable extends UserIDTable {
* *
* @param uuid UUID of the Player. * @param uuid UUID of the Player.
* @return key - ServerName, value ms played * @return key - ServerName, value ms played
* @throws SQLException * @throws SQLException DB Error
*/ */
public Map<String, Long> getPlaytimeByServer(UUID uuid) throws SQLException { public Map<String, Long> getPlaytimeByServer(UUID uuid) throws SQLException {
return getPlaytimeByServer(uuid, 0L); return getPlaytimeByServer(uuid, 0L);
@ -284,7 +277,7 @@ public class SessionsTable extends UserIDTable {
* @param uuid UUID of the Player. * @param uuid UUID of the Player.
* @param afterDate Epoch ms (Playtime after this date is calculated) * @param afterDate Epoch ms (Playtime after this date is calculated)
* @return key - ServerName, value ms played * @return key - ServerName, value ms played
* @throws SQLException * @throws SQLException DB Error
*/ */
public Map<String, Long> getPlaytimeByServer(UUID uuid, long afterDate) throws SQLException { public Map<String, Long> getPlaytimeByServer(UUID uuid, long afterDate) throws SQLException {
Map<Integer, String> serverNames = serverTable.getServerNames(); Map<Integer, String> serverNames = serverTable.getServerNames();
@ -317,7 +310,7 @@ public class SessionsTable extends UserIDTable {
* Used to get the Total Playtime of THIS Server. * Used to get the Total Playtime of THIS Server.
* *
* @return Milliseconds played on the server. 0 if server not found. * @return Milliseconds played on the server. 0 if server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public long getPlaytimeOfServer() throws SQLException { public long getPlaytimeOfServer() throws SQLException {
return getPlaytimeOfServer(Plan.getServerUUID()); return getPlaytimeOfServer(Plan.getServerUUID());
@ -328,7 +321,7 @@ public class SessionsTable extends UserIDTable {
* *
* @param serverUUID UUID of the server. * @param serverUUID UUID of the server.
* @return Milliseconds played on the server. 0 if server not found. * @return Milliseconds played on the server. 0 if server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public long getPlaytimeOfServer(UUID serverUUID) throws SQLException { public long getPlaytimeOfServer(UUID serverUUID) throws SQLException {
return getPlaytimeOfServer(serverUUID, 0L); return getPlaytimeOfServer(serverUUID, 0L);
@ -339,7 +332,7 @@ public class SessionsTable extends UserIDTable {
* *
* @param afterDate Epoch ms (Playtime after this date is calculated) * @param afterDate Epoch ms (Playtime after this date is calculated)
* @return Milliseconds played after given epoch ms on the server. 0 if server not found. * @return Milliseconds played after given epoch ms on the server. 0 if server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public long getPlaytimeOfServer(long afterDate) throws SQLException { public long getPlaytimeOfServer(long afterDate) throws SQLException {
return getPlaytimeOfServer(Plan.getServerUUID(), afterDate); return getPlaytimeOfServer(Plan.getServerUUID(), afterDate);
@ -351,7 +344,7 @@ public class SessionsTable extends UserIDTable {
* @param serverUUID UUID of the server. * @param serverUUID UUID of the server.
* @param afterDate Epoch ms (Playtime after this date is calculated) * @param afterDate Epoch ms (Playtime after this date is calculated)
* @return Milliseconds played after given epoch ms on the server. 0 if server not found. * @return Milliseconds played after given epoch ms on the server. 0 if server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public long getPlaytimeOfServer(UUID serverUUID, long afterDate) throws SQLException { public long getPlaytimeOfServer(UUID serverUUID, long afterDate) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
@ -380,7 +373,7 @@ public class SessionsTable extends UserIDTable {
* *
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @return How many sessions player has. 0 if player or server not found. * @return How many sessions player has. 0 if player or server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public int getSessionCount(UUID uuid) throws SQLException { public int getSessionCount(UUID uuid) throws SQLException {
return getSessionCount(uuid, 0L); return getSessionCount(uuid, 0L);
@ -392,7 +385,7 @@ public class SessionsTable extends UserIDTable {
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @param afterDate Epoch ms (Session count after this date is calculated) * @param afterDate Epoch ms (Session count after this date is calculated)
* @return How many sessions player has. 0 if player or server not found. * @return How many sessions player has. 0 if player or server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public int getSessionCount(UUID uuid, long afterDate) throws SQLException { public int getSessionCount(UUID uuid, long afterDate) throws SQLException {
return getSessionCount(uuid, Plan.getServerUUID(), afterDate); return getSessionCount(uuid, Plan.getServerUUID(), afterDate);
@ -404,7 +397,7 @@ public class SessionsTable extends UserIDTable {
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @param serverUUID UUID of the server. * @param serverUUID UUID of the server.
* @return How many sessions player has. 0 if player or server not found. * @return How many sessions player has. 0 if player or server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public int getSessionCount(UUID uuid, UUID serverUUID) throws SQLException { public int getSessionCount(UUID uuid, UUID serverUUID) throws SQLException {
return getSessionCount(uuid, serverUUID, 0L); return getSessionCount(uuid, serverUUID, 0L);
@ -417,7 +410,7 @@ public class SessionsTable extends UserIDTable {
* @param serverUUID UUID of the server. * @param serverUUID UUID of the server.
* @param afterDate Epoch ms (Session count after this date is calculated) * @param afterDate Epoch ms (Session count after this date is calculated)
* @return How many sessions player has. 0 if player or server not found. * @return How many sessions player has. 0 if player or server not found.
* @throws SQLException * @throws SQLException DB Error
*/ */
public int getSessionCount(UUID uuid, UUID serverUUID, long afterDate) throws SQLException { public int getSessionCount(UUID uuid, UUID serverUUID, long afterDate) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;

View File

@ -38,10 +38,6 @@ public class TPSTable extends Table {
private final ServerTable serverTable; private final ServerTable serverTable;
private String insertStatement; private String insertStatement;
/**
* @param db
* @param usingMySQL
*/
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();
@ -83,7 +79,7 @@ public class TPSTable extends Table {
List<TPS> data = new ArrayList<>(); List<TPS> data = new ArrayList<>();
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
try (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
statement = connection.prepareStatement(Select.all(tableName) statement = connection.prepareStatement(Select.all(tableName)
.where(columnServerID + "=" + serverTable.statementSelectServerID) .where(columnServerID + "=" + serverTable.statementSelectServerID)
.toString()); .toString());
@ -109,7 +105,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 (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
statement = connection.prepareStatement(insertStatement); statement = connection.prepareStatement(insertStatement);
statement.setString(1, Plan.getServerUUID().toString()); statement.setString(1, Plan.getServerUUID().toString());
@ -129,7 +125,9 @@ public class TPSTable extends Table {
} }
/** /**
* @throws SQLException * Clean the TPS Table of old data.
*
* @throws SQLException DB Error
*/ */
public void clean() throws SQLException { public void clean() throws SQLException {
Optional<TPS> allTimePeak = getAllTimePeak(); Optional<TPS> allTimePeak = getAllTimePeak();
@ -138,7 +136,7 @@ public class TPSTable extends Table {
p = allTimePeak.get().getPlayers(); p = allTimePeak.get().getPlayers();
} }
PreparedStatement statement = null; PreparedStatement statement = null;
try (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
statement = connection.prepareStatement("DELETE FROM " + tableName + statement = connection.prepareStatement("DELETE FROM " + tableName +
" WHERE (" + columnDate + "<?)" + " WHERE (" + columnDate + "<?)" +
" AND (" + columnPlayers + "" + " AND (" + columnPlayers + "" +
@ -170,7 +168,7 @@ public class TPSTable extends Table {
public Optional<TPS> getPeakPlayerCount(UUID serverUUID, long afterDate) throws SQLException { public Optional<TPS> getPeakPlayerCount(UUID serverUUID, long afterDate) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
try (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
statement = connection.prepareStatement(Select.all(tableName) statement = connection.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 + ")")
@ -199,7 +197,7 @@ public class TPSTable extends Table {
public Map<UUID, List<TPS>> getAllTPS() throws SQLException { public Map<UUID, List<TPS>> getAllTPS() throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
try (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
String serverIDColumn = serverTable + "." + serverTable.getColumnID(); String serverIDColumn = serverTable + "." + serverTable.getColumnID();
String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid"; String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid";
statement = connection.prepareStatement("SELECT " + statement = connection.prepareStatement("SELECT " +
@ -244,7 +242,7 @@ public class TPSTable extends Table {
return; return;
} }
PreparedStatement statement = null; PreparedStatement statement = null;
try (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
statement = connection.prepareStatement(insertStatement); statement = connection.prepareStatement(insertStatement);
// Every Server // Every Server
@ -275,7 +273,7 @@ public class TPSTable extends Table {
public List<TPS> getNetworkOnlineData() throws SQLException { public List<TPS> getNetworkOnlineData() throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
try (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
statement = connection.prepareStatement("SELECT " + statement = connection.prepareStatement("SELECT " +
columnDate + ", " + columnDate + ", " +
"SUM(" + columnPlayers + ") as players" + "SUM(" + columnPlayers + ") as players" +

View File

@ -3,16 +3,12 @@ package main.java.com.djrapitops.plan.database.tables;
import com.djrapitops.plugin.utilities.Verify; import com.djrapitops.plugin.utilities.Verify;
import com.google.common.base.Objects; 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.DBUtils;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.List;
import java.util.Map;
/** /**
* @author Rsl1122 * @author Rsl1122
@ -35,9 +31,11 @@ public abstract class Table {
protected final boolean usingMySQL; protected final boolean usingMySQL;
/** /**
* @param name * Constructor.
* @param db *
* @param usingMySQL * @param name Name of the table in the db.
* @param db Database to use.
* @param usingMySQL Is the database using MySQL?
*/ */
public Table(String name, SQLDB db, boolean usingMySQL) { public Table(String name, SQLDB db, boolean usingMySQL) {
this.tableName = name; this.tableName = name;
@ -45,9 +43,6 @@ public abstract class Table {
this.usingMySQL = usingMySQL; this.usingMySQL = usingMySQL;
} }
/**
* @return
*/
public abstract void createTable() throws DBCreateTableException; public abstract void createTable() throws DBCreateTableException;
protected void createTable(String sql) throws DBCreateTableException { protected void createTable(String sql) throws DBCreateTableException {
@ -59,29 +54,35 @@ public abstract class Table {
} }
/** /**
* @return * Used to get a new Connection to the Database.
* @throws SQLException *
* @return SQL Connection
* @throws SQLException DB Error
*/ */
protected Connection getConnection() throws SQLException { protected Connection getConnection() throws SQLException {
return db.getConnection(); return db.getConnection();
} }
/** /**
* @return * Get the Database Schema version from VersionTable.
* @throws SQLException *
* @return Database Schema version.
* @throws SQLException DB Error
*/ */
public int getVersion() throws SQLException { public int getVersion() throws SQLException {
return db.getVersion(); return db.getVersion();
} }
/** /**
* @param statementString * Executes an SQL Statement
* @return *
* @throws SQLException * @param statementString Statement to execute
* @return What execute returns.
* @throws SQLException DB error
*/ */
protected boolean execute(String statementString) throws SQLException { protected boolean execute(String statementString) throws SQLException {
Statement statement = null; Statement statement = null;
try (Connection connection = getConnection()){ try (Connection connection = getConnection()) {
statement = connection.createStatement(); statement = connection.createStatement();
boolean b = statement.execute(statementString); boolean b = statement.execute(statementString);
commit(connection); commit(connection);
@ -108,35 +109,25 @@ public abstract class Table {
} }
/** /**
* @param toClose * Closes DB elements.
*
* @param toClose All elements to close.
*/ */
protected void close(AutoCloseable... toClose) { protected void close(AutoCloseable... toClose) {
MiscUtils.close(toClose); MiscUtils.close(toClose);
} }
/**
* @return
*/
public String getTableName() { public String getTableName() {
return tableName; return tableName;
} }
/** /**
* @return * Removes all data from the table.
*/ */
public void removeAllData() throws SQLException { public void removeAllData() throws SQLException {
execute("DELETE FROM " + tableName); execute("DELETE FROM " + tableName);
} }
/**
* @param <T>
* @param objects
* @return
*/
protected <T> List<List<Container<T>>> splitIntoBatches(Map<Integer, List<T>> objects) {
return DBUtils.splitIntoBatchesId(objects);
}
protected void addColumns(String... columnInfo) { protected void addColumns(String... columnInfo) {
for (int i = 0; i < columnInfo.length; i++) { for (int i = 0; i < columnInfo.length; i++) {
columnInfo[i] = "ALTER TABLE " + tableName + " ADD " + (usingMySQL ? "" : "COLUMN ") + columnInfo[i]; columnInfo[i] = "ALTER TABLE " + tableName + " ADD " + (usingMySQL ? "" : "COLUMN ") + columnInfo[i];

View File

@ -89,10 +89,7 @@ public class UserInfoTable extends UserIDTable {
.toString()); .toString());
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
set = statement.executeQuery(); set = statement.executeQuery();
if (set.next()) { return set.next() && set.getInt("c") >= 1;
return set.getInt("c") >= 1;
}
return false;
} finally { } finally {
close(set, statement); close(set, statement);
} }

View File

@ -25,10 +25,6 @@ public class UsersTable extends UserIDTable {
private final String columnTimesKicked = "times_kicked"; private final String columnTimesKicked = "times_kicked";
private String insertStatement; private String insertStatement;
/**
* @param db
* @param usingMySQL
*/
public UsersTable(SQLDB db, boolean usingMySQL) { public UsersTable(SQLDB db, boolean usingMySQL) {
super("plan_users", db, usingMySQL); super("plan_users", db, usingMySQL);
statementSelectID = "(" + Select.from(tableName, tableName + "." + columnID).where(columnUUID + "=?").toString() + ")"; statementSelectID = "(" + Select.from(tableName, tableName + "." + columnID).where(columnUUID + "=?").toString() + ")";
@ -38,9 +34,6 @@ public class UsersTable extends UserIDTable {
columnName); columnName);
} }
/**
* @return
*/
@Override @Override
public void createTable() throws DBCreateTableException { public void createTable() throws DBCreateTableException {
createTable(TableSqlParser.createTable(tableName) createTable(TableSqlParser.createTable(tableName)
@ -79,8 +72,10 @@ public class UsersTable extends UserIDTable {
} }
/** /**
* Remove a user from Users Table.
*
* @param uuid the UUID of the user that should be removed. * @param uuid the UUID of the user that should be removed.
* @return if the removal was successful. * @throws SQLException DB Error
*/ */
@Override @Override
public void removeUser(UUID uuid) throws SQLException { public void removeUser(UUID uuid) throws SQLException {
@ -111,18 +106,20 @@ public class UsersTable extends UserIDTable {
} }
/** /**
* @param playername * Get UUID of a player.
* @return *
* @throws SQLException * @param playerName Name of a player
* @return UUID of the player
* @throws SQLException DB Error
*/ */
public UUID getUuidOf(String playername) throws SQLException { public UUID getUuidOf(String playerName) throws SQLException {
PreparedStatement statement = null; PreparedStatement statement = null;
ResultSet set = null; ResultSet set = null;
try (Connection connection = getConnection()) { try (Connection connection = getConnection()) {
statement = connection.prepareStatement(Select.from(tableName, columnUUID) statement = connection.prepareStatement(Select.from(tableName, columnUUID)
.where("UPPER(" + columnName + ")=UPPER(?)") .where("UPPER(" + columnName + ")=UPPER(?)")
.toString()); .toString());
statement.setString(1, playername); statement.setString(1, playerName);
set = statement.executeQuery(); set = statement.executeQuery();
if (set.next()) { if (set.next()) {
String uuidS = set.getString(columnUUID); String uuidS = set.getString(columnUUID);
@ -156,7 +153,7 @@ public class UsersTable extends UserIDTable {
* @param uuid UUID of the player. * @param uuid UUID of the player.
* @param registered Register date. * @param registered Register date.
* @param name Name of the player. * @param name Name of the player.
* @throws SQLException * @throws SQLException DB Error
* @throws IllegalArgumentException If uuid or name are null. * @throws IllegalArgumentException If uuid or name are null.
*/ */
public void registerUser(UUID uuid, long registered, String name) throws SQLException { public void registerUser(UUID uuid, long registered, String name) throws SQLException {
@ -185,10 +182,7 @@ public class UsersTable extends UserIDTable {
.toString()); .toString());
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
set = statement.executeQuery(); set = statement.executeQuery();
if (set.next()) { return set.next() && set.getInt("c") >= 1;
return set.getInt("c") >= 1;
}
return false;
} finally { } finally {
close(set, statement); close(set, statement);
} }
@ -308,8 +302,8 @@ public class UsersTable extends UserIDTable {
* This method is for batch operations, and should not be used to add information of users. * This method is for batch operations, and should not be used to add information of users.
* Use UserInfoTable instead. * Use UserInfoTable instead.
* *
* @param users * @param users Users to insert
* @throws SQLException * @throws SQLException DB Error
*/ */
public void insertUsers(Map<UUID, UserInfo> users) throws SQLException { public void insertUsers(Map<UUID, UserInfo> users) throws SQLException {
if (Verify.isEmpty(users)) { if (Verify.isEmpty(users)) {

View File

@ -16,17 +16,10 @@ import java.sql.SQLException;
*/ */
public class VersionTable extends Table { public class VersionTable extends Table {
/**
* @param db
* @param usingMySQL
*/
public VersionTable(SQLDB db, boolean usingMySQL) { public VersionTable(SQLDB db, boolean usingMySQL) {
super("plan_version", db, usingMySQL); super("plan_version", db, usingMySQL);
} }
/**
* @return
*/
@Override @Override
public void createTable() throws DBCreateTableException { public void createTable() throws DBCreateTableException {
createTable(TableSqlParser.createTable(tableName) createTable(TableSqlParser.createTable(tableName)
@ -77,8 +70,10 @@ public class VersionTable extends Table {
} }
/** /**
* @param version * Set the DB Schema version
* @throws SQLException *
* @param version DB Schema version
* @throws SQLException DB Error
*/ */
public void setVersion(int version) throws SQLException { public void setVersion(int version) throws SQLException {
removeAllData(); removeAllData();

View File

@ -32,7 +32,7 @@ import java.util.UUID;
* <p> * <p>
* clearTable methods can be used to clear the table beforehand. * clearTable methods can be used to clear the table beforehand.
* <p> * <p>
* Server & User tables should be copied first. * Server and User tables should be copied first.
* *
* @author Rsl1122 * @author Rsl1122
* @since 4.0.0 * @since 4.0.0
@ -42,7 +42,7 @@ public class BatchOperationTable extends Table {
/** /**
* Constructor, call to access copy functionality. * Constructor, call to access copy functionality.
* *
* @param database * @param database Database to copy things from
* @throws IllegalStateException if database.init has not been called. * @throws IllegalStateException if database.init has not been called.
* @throws ClassCastException if database is not SQLDB. * @throws ClassCastException if database is not SQLDB.
*/ */

View File

@ -14,7 +14,7 @@ import java.util.*;
* <ul> * <ul>
* <li>PlayerName cache, used for reducing database calls on chat events</li> * <li>PlayerName cache, used for reducing database calls on chat events</li>
* <li>DisplayName cache, used for reducing database calls on chat events</li> * <li>DisplayName cache, used for reducing database calls on chat events</li>
* <li>FirstSession MessageCount Map, used for tracking first session & message count on that session.</li> * <li>FirstSession MessageCount Map, used for tracking first session and message count on that session.</li>
* </ul> * </ul>
* *
* @author Rsl1122 * @author Rsl1122
@ -114,8 +114,10 @@ public class DataCache extends SessionCache {
} }
/** /**
* @param uuid * Check if a session is player's first session on the server.
* @return *
* @param uuid UUID of the player
* @return true / false
*/ */
public boolean isFirstSession(UUID uuid) { public boolean isFirstSession(UUID uuid) {
return firstSessionInformation.containsKey(uuid); return firstSessionInformation.containsKey(uuid);

View File

@ -318,7 +318,7 @@ public class BukkitInformationManager extends InformationManager {
if (usingAnotherWebServer) { if (usingAnotherWebServer) {
try { try {
getWebAPI().getAPI(PostNetworkPageContentWebAPI.class).sendNetworkContent(webServerAddress, HtmlStructure.createServerContainer(plugin)); getWebAPI().getAPI(PostNetworkPageContentWebAPI.class).sendNetworkContent(webServerAddress, HtmlStructure.createServerContainer(plugin));
} catch (WebAPIException e) { } catch (WebAPIException ignored) {
} }
} }
} }

View File

@ -124,8 +124,8 @@ public class BukkitServerInfoManager {
/** /**
* Saves Bungee connection information to local file on Bukkit servers. * Saves Bungee connection information to local file on Bukkit servers.
* *
* @param address * @param address Address to save
* @throws IOException * @throws IOException If ServerInfo file can not be written to.
*/ */
public void saveBungeeConnectionAddress(String address) throws IOException { public void saveBungeeConnectionAddress(String address) throws IOException {
serverInfoFile.saveInfo(serverInfo, new ServerInfo(-1, null, "Bungee", address, -1)); serverInfoFile.saveInfo(serverInfo, new ServerInfo(-1, null, "Bungee", address, -1));

View File

@ -20,7 +20,7 @@ import java.util.UUID;
/** /**
* Manages local server info file. * Manages local server info file.
* <p> * <p>
* ServerInfo.yml contains current server's ID, UUID & Bungee WebServer connection information. * ServerInfo.yml contains current server's ID, UUID and Bungee WebServer connection information.
* It * It
* *
* @author Rsl1122 * @author Rsl1122

View File

@ -34,7 +34,7 @@ public abstract class Queue<T> {
} }
/** /**
* Used to stop the queue processing & get the unprocessed objects. * Used to stop the queue processing and get the unprocessed objects.
* *
* @return List of unprocessed objects. * @return List of unprocessed objects.
*/ */

View File

@ -27,14 +27,12 @@ import java.util.UUID;
public class ResponseHandler extends APIResponseHandler { public class ResponseHandler extends APIResponseHandler {
private final IPlan plugin; private final IPlan plugin;
private final WebServer webServer;
private final boolean usingHttps; private final boolean usingHttps;
public ResponseHandler(IPlan plugin, WebServer webServer) { public ResponseHandler(IPlan plugin, WebServer webServer) {
super(webServer.getWebAPI()); super(webServer.getWebAPI());
this.plugin = plugin; this.plugin = plugin;
this.webServer = webServer;
this.usingHttps = webServer.isUsingHTTPS(); this.usingHttps = webServer.isUsingHTTPS();
} }

View File

@ -43,9 +43,6 @@ public class WebServer {
private boolean usingHttps = false; private boolean usingHttps = false;
/**
* @param plugin
*/
public WebServer(IPlan plugin) { public WebServer(IPlan plugin) {
this.plugin = plugin; this.plugin = plugin;
this.port = Settings.WEBSERVER_PORT.getNumber(); this.port = Settings.WEBSERVER_PORT.getNumber();

View File

@ -13,7 +13,9 @@ import main.java.com.djrapitops.plan.systems.info.InformationManager;
public class AnalysisPageResponse extends Response { public class AnalysisPageResponse extends Response {
/** /**
* @param informationManager * Constructor.
*
* @param informationManager InformationManager to use for getting the Html
* @throws NullPointerException if AnalysisData has not been cached after 1 second. * @throws NullPointerException if AnalysisData has not been cached after 1 second.
*/ */
public AnalysisPageResponse(InformationManager informationManager) { public AnalysisPageResponse(InformationManager informationManager) {

View File

@ -9,7 +9,7 @@ import main.java.com.djrapitops.plan.utilities.PassEncryptUtil;
import java.util.*; import java.util.*;
/** /**
* @author Fuzzlemann & Rsl1122 * @author Fuzzlemann and Rsl1122
*/ */
public class WebAPIManager { public class WebAPIManager {

View File

@ -17,7 +17,7 @@ import java.util.UUID;
/** /**
* WebAPI for requesting Inspect plugins tab contents from a Bukkit Server. * WebAPI for requesting Inspect plugins tab contents from a Bukkit Server.
* <p> * <p>
* Call: Bungee -> Bukkit * Call: Bungee to Bukkit
* <p> * <p>
* Bad Requests: * Bad Requests:
* - Called a Bungee Server * - Called a Bungee Server

View File

@ -16,7 +16,7 @@ import java.util.UUID;
/** /**
* WebAPI for posting Inspect page Plugins tab contents to the Bungee server. * WebAPI for posting Inspect page Plugins tab contents to the Bungee server.
* <p> * <p>
* Call: Bukkit -> Bungee * Call: Bukkit to Bungee
* <p> * <p>
* Bad Requests: * Bad Requests:
* - Did not include uuid * - Did not include uuid

View File

@ -22,7 +22,7 @@ import java.util.UUID;
/** /**
* WebAPI for requesting Bungee Server to request Plugins tab contents from every server. * WebAPI for requesting Bungee Server to request Plugins tab contents from every server.
* <p> * <p>
* Call: Bukkit -> Bungee * Call: Bukkit to Bungee
* <p> * <p>
* Bad Requests: * Bad Requests:
* - Called a Bukkit Server * - Called a Bukkit Server

View File

@ -16,15 +16,19 @@ public class Benchmark {
} }
/** /**
* @param source * Start a benchmark.
*
* @param source Thing to bench.
*/ */
public static void start(String source) { public static void start(String source) {
getBenchUtil().start(source); getBenchUtil().start(source);
} }
/** /**
* @param source * End a benchmark.
* @return *
* @param source Thing to stop benching.
* @return ms it took.
*/ */
public static long stop(String source) { public static long stop(String source) {
long ms = getBenchUtil().stop(source); long ms = getBenchUtil().stop(source);

View File

@ -23,42 +23,34 @@ public class FormatUtils {
} }
/** /**
* @param ms * Format time amount according to the config settings.
* @return *
* @param ms Milliseconds.
* @return String formatted with the config settings.
*/ */
public static String formatTimeAmount(long ms) { public static String formatTimeAmount(long ms) {
return formatMilliseconds(ms); return formatMilliseconds(ms);
} }
/** /**
* @param before * Format the time difference between an end point and a start point.
* @param after *
* @return * @param before Epoch ms.
* @param after Epoch ms.
* @return String formatted with the config settings.
*/ */
public static String formatTimeAmountDifference(long before, long after) { public static String formatTimeAmountDifference(long before, long after) {
return formatMilliseconds(Math.abs(after - before)); return formatMilliseconds(Math.abs(after - before));
} }
/**
* @param epochMs
* @return
*/
public static String formatTimeStamp(long epochMs) { public static String formatTimeStamp(long epochMs) {
return FormattingUtils.formatTimeStamp(epochMs); return FormattingUtils.formatTimeStamp(epochMs);
} }
/**
* @param epochMs
* @return
*/
public static String formatTimeStampSecond(long epochMs) { public static String formatTimeStampSecond(long epochMs) {
return FormattingUtils.formatTimeStampSecond(epochMs); return FormattingUtils.formatTimeStampSecond(epochMs);
} }
/**
* @param epochMs
* @return
*/
public static String formatTimeStampYear(long epochMs) { public static String formatTimeStampYear(long epochMs) {
return FormattingUtils.formatTimeStampYear(epochMs); return FormattingUtils.formatTimeStampYear(epochMs);
} }
@ -66,8 +58,8 @@ public class FormatUtils {
/** /**
* Removes letters from a string leaving only numbers and dots. * Removes letters from a string leaving only numbers and dots.
* *
* @param dataPoint * @param dataPoint String to remove stuff from.
* @return * @return String with the stuff removed.
*/ */
public static String removeLetters(String dataPoint) { public static String removeLetters(String dataPoint) {
return Format.create(dataPoint) return Format.create(dataPoint)
@ -78,8 +70,10 @@ public class FormatUtils {
} }
/** /**
* @param dataPoint * Removes numbers from a string leaving only letters.
* @return *
* @param dataPoint String to remove stuff from.
* @return String with the stuff removed.
*/ */
public static String removeNumbers(String dataPoint) { public static String removeNumbers(String dataPoint) {
return Format.create(dataPoint) return Format.create(dataPoint)
@ -176,8 +170,10 @@ public class FormatUtils {
} }
/** /**
* @param d * Remove extra decimals from the end of the double.
* @return *
* @param d Double.
* @return String format of the double.
*/ */
public static String cutDecimals(double d) { public static String cutDecimals(double d) {
return df.format(d); return df.format(d);

View File

@ -28,7 +28,6 @@ public class ManageUtils {
* *
* @param dbName Name of database (mysql/sqlite) * @param dbName Name of database (mysql/sqlite)
* @param copyFromDB Database you want to backup. * @param copyFromDB Database you want to backup.
* @return success?
*/ */
public static void backup(String dbName, Database copyFromDB) throws DatabaseInitException, SQLException { public static void backup(String dbName, Database copyFromDB) throws DatabaseInitException, SQLException {
Plan plugin = Plan.getInstance(); Plan plugin = Plan.getInstance();
@ -66,7 +65,6 @@ public class ManageUtils {
* @param clearAndCopyToDB Database that will be cleared data will be copied * @param clearAndCopyToDB Database that will be cleared data will be copied
* to. * to.
* @param copyFromDB Database where data will be copied from * @param copyFromDB Database where data will be copied from
* @return success?
*/ */
public static void clearAndCopy(Database clearAndCopyToDB, Database copyFromDB) throws SQLException { public static void clearAndCopy(Database clearAndCopyToDB, Database copyFromDB) throws SQLException {
BatchOperationTable toDB = new BatchOperationTable(clearAndCopyToDB); BatchOperationTable toDB = new BatchOperationTable(clearAndCopyToDB);

View File

@ -48,9 +48,11 @@ public class MiscUtils {
} }
/** /**
* @param args * Get a players name that matches the given arguments or name of the sender.
* @param sender *
* @return * @param args Arguments of command.
* @param sender Sender of command
* @return Player name.
*/ */
public static String getPlayerName(String[] args, ISender sender) { public static String getPlayerName(String[] args, ISender sender) {
return getPlayerName(args, sender, Permissions.INSPECT_OTHER); return getPlayerName(args, sender, Permissions.INSPECT_OTHER);
@ -61,7 +63,7 @@ public class MiscUtils {
* *
* @param args Arguments of a command, must not be empty if console sender. * @param args Arguments of a command, must not be empty if console sender.
* @param sender Command sender * @param sender Command sender
* @param perm * @param perm Permission to use when checking. No permission will notify user.
* @return The name of the player (first argument or sender) * @return The name of the player (first argument or sender)
*/ */
public static String getPlayerName(String[] args, ISender sender, Permissions perm) { public static String getPlayerName(String[] args, ISender sender, Permissions perm) {

View File

@ -97,8 +97,10 @@ public class Analysis {
} }
/** /**
* Analyze data in the db about this server.
*
* @param infoManager InformationManager of the plugin. * @param infoManager InformationManager of the plugin.
* @return * @return Success?
*/ */
public boolean analyzeData(InformationManager infoManager, Database db) { public boolean analyzeData(InformationManager infoManager, Database db) {
try { try {
@ -210,7 +212,9 @@ public class Analysis {
} }
/** /**
* @return * Check whether or not analysis is being run.
*
* @return true / false (state)
*/ */
public boolean isAnalysisBeingRun() { public boolean isAnalysisBeingRun() {
return taskId != -1; return taskId != -1;

View File

@ -26,13 +26,6 @@ public class AnalysisUtils {
throw new IllegalStateException("Utility class"); throw new IllegalStateException("Utility class");
} }
/**
* @param now
* @param lastPlayed
* @param playTime
* @param loginTimes
* @return
*/
public static boolean isActive(long now, long lastPlayed, long playTime, int loginTimes) { public static boolean isActive(long now, long lastPlayed, long playTime, int loginTimes) {
int timeToActive = 10; int timeToActive = 10;
long twoWeeks = 1209600000; long twoWeeks = 1209600000;
@ -41,12 +34,6 @@ public class AnalysisUtils {
&& playTime > 60 * timeToActive; && playTime > 60 * timeToActive;
} }
/**
* @param registered
* @param scale
* @param now
* @return
*/
public static long getNewPlayers(List<Long> registered, long scale, long now) { public static long getNewPlayers(List<Long> registered, long scale, long now) {
long newPlayers = 0; long newPlayers = 0;
if (!registered.isEmpty()) { if (!registered.isEmpty()) {
@ -59,10 +46,6 @@ public class AnalysisUtils {
return newPlayers; return newPlayers;
} }
/**
* @param data
* @return
*/
public static List<Long> transformSessionDataToLengths(Collection<Session> data) { public static List<Long> transformSessionDataToLengths(Collection<Session> data) {
return data.stream() return data.stream()
.filter(Objects::nonNull) .filter(Objects::nonNull)
@ -71,12 +54,6 @@ public class AnalysisUtils {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
/**
* @param analysisType
* @param source
* @param uuids
* @return
*/
public static String getTotal(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) { public static String getTotal(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) {
if (analysisType == null) { if (analysisType == null) {
return source.parseContainer("Err ", "Null Analysistype. "); return source.parseContainer("Err ", "Null Analysistype. ");
@ -112,12 +89,6 @@ public class AnalysisUtils {
.filter(value -> !value.equals(-1L)); .filter(value -> !value.equals(-1L));
} }
/**
* @param analysisType
* @param source
* @param uuids
* @return
*/
public static String getAverage(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) { public static String getAverage(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) {
if (analysisType == null) { if (analysisType == null) {
return source.parseContainer("Err ", "Null Analysistype. "); return source.parseContainer("Err ", "Null Analysistype. ");
@ -150,12 +121,6 @@ public class AnalysisUtils {
} }
} }
/**
* @param analysisType
* @param source
* @param uuids
* @return
*/
public static String getBooleanPercentage(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) { public static String getBooleanPercentage(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) {
if (analysisType != AnalysisType.BOOLEAN_PERCENTAGE) { if (analysisType != AnalysisType.BOOLEAN_PERCENTAGE) {
return source.parseContainer("Err ", "Wrong Analysistype specified: " + analysisType.name()); return source.parseContainer("Err ", "Wrong Analysistype specified: " + analysisType.name());
@ -172,12 +137,6 @@ public class AnalysisUtils {
} }
} }
/**
* @param analysisType
* @param source
* @param uuids
* @return
*/
public static String getBooleanTotal(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) { public static String getBooleanTotal(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) {
if (analysisType != AnalysisType.BOOLEAN_TOTAL) { if (analysisType != AnalysisType.BOOLEAN_TOTAL) {
return source.parseContainer("Err ", "Wrong Analysistype specified: " + analysisType.name()); return source.parseContainer("Err ", "Wrong Analysistype specified: " + analysisType.name());
@ -224,11 +183,6 @@ public class AnalysisUtils {
return uniqueJoins.size(); return uniqueJoins.size();
} }
/**
* @param sessions
* @param scale
* @return
*/
public static int getUniqueJoinsPerDay(Map<UUID, List<Session>> sessions, long scale) { public static int getUniqueJoinsPerDay(Map<UUID, List<Session>> sessions, long scale) {
Map<Integer, Set<UUID>> uniqueJoins = new HashMap<>(); Map<Integer, Set<UUID>> uniqueJoins = new HashMap<>();
long now = MiscUtils.getTime(); long now = MiscUtils.getTime();

View File

@ -8,7 +8,6 @@ import main.java.com.djrapitops.plan.data.UserInfo;
import main.java.com.djrapitops.plan.systems.webserver.response.PlayersPageResponse; import main.java.com.djrapitops.plan.systems.webserver.response.PlayersPageResponse;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -28,9 +27,6 @@ public class ExportUtility {
throw new IllegalStateException("Utility class"); throw new IllegalStateException("Utility class");
} }
/**
* @return
*/
public static File getFolder() { public static File getFolder() {
String path = Settings.ANALYSIS_EXPORT_PATH.toString(); String path = Settings.ANALYSIS_EXPORT_PATH.toString();
@ -50,10 +46,6 @@ public class ExportUtility {
return folder; return folder;
} }
/**
* @param analysisData
* @param playerNames
*/
public static void export(AnalysisData analysisData, List<String> playerNames) { public static void export(AnalysisData analysisData, List<String> playerNames) {
if (!Settings.ANALYSIS_EXPORT.isTrue()) { if (!Settings.ANALYSIS_EXPORT.isTrue()) {
return; return;
@ -84,20 +76,12 @@ public class ExportUtility {
// } // }
} }
/**
* @param folder
* @return
*/
public static File getPlayersFolder(File folder) { public static File getPlayersFolder(File folder) {
File playersFolder = new File(folder, "player"); File playersFolder = new File(folder, "player");
playersFolder.mkdirs(); playersFolder.mkdirs();
return playersFolder; return playersFolder;
} }
/**
* @param userInfo
* @param playersFolder
*/
public static void writeInspectHtml(UserInfo userInfo, File playersFolder, String playerHtml) { public static void writeInspectHtml(UserInfo userInfo, File playersFolder, String playerHtml) {
if (!Settings.ANALYSIS_EXPORT.isTrue()) { if (!Settings.ANALYSIS_EXPORT.isTrue()) {
return; return;
@ -127,12 +111,6 @@ public class ExportUtility {
// } // }
} }
/**
* @param analysisData
* @param serverFolder
* @throws FileNotFoundException
* @throws IOException
*/
public static void writeAnalysisHtml(AnalysisData analysisData, File serverFolder) throws IOException { public static void writeAnalysisHtml(AnalysisData analysisData, File serverFolder) throws IOException {
if (!Settings.ANALYSIS_EXPORT.isTrue()) { if (!Settings.ANALYSIS_EXPORT.isTrue()) {
return; return;

View File

@ -18,26 +18,29 @@ public class MapComparator {
} }
/** /**
* Sorts a HashMap of String, Integer by the Values of the HashMap. * Sorts a Map of String, Integer by the Values of the Map.
* *
* @param hashMap * @param map Map to sort
* @return List with String Array, where first value is the value and second * @return List with String Array, where first value is the value and second
* is the key. * is the key.
*/ */
public static List<String[]> sortByValue(Map<String, Integer> hashMap) { public static List<String[]> sortByValue(Map<String, Integer> map) {
List<String[]> sortedList = new ArrayList<>(); List<String[]> sortedList = new ArrayList<>();
hashMap.keySet().forEach(key -> sortedList.add(new String[]{String.valueOf(hashMap.get(key)), key})); map.keySet().forEach(key -> sortedList.add(new String[]{String.valueOf(map.get(key)), key}));
sortedList.sort(Comparator.comparingInt(strings -> Integer.parseInt(strings[0]))); sortedList.sort(Comparator.comparingInt(strings -> Integer.parseInt(strings[0])));
return sortedList; return sortedList;
} }
/** /**
* @param hashMap * Sorts a Map of String, Long by the Values of the Map.
* @return *
* @param map Map to sort
* @return List with String Array, where first value is the value and second
* is the key.
*/ */
public static List<String[]> sortByValueLong(Map<String, Long> hashMap) { public static List<String[]> sortByValueLong(Map<String, Long> map) {
List<String[]> sortedList = new ArrayList<>(); List<String[]> sortedList = new ArrayList<>();
hashMap.keySet().forEach(key -> sortedList.add(new String[]{String.valueOf(hashMap.get(key)), key})); map.keySet().forEach(key -> sortedList.add(new String[]{String.valueOf(map.get(key)), key}));
sortedList.sort(Comparator.comparing(strings -> Long.valueOf(strings[0]))); sortedList.sort(Comparator.comparing(strings -> Long.valueOf(strings[0])));
return sortedList; return sortedList;
} }

View File

@ -3,7 +3,7 @@ package main.java.com.djrapitops.plan.utilities.comparators;
import java.util.Comparator; import java.util.Comparator;
/** /**
* Compares Strings & sorts them by length * Compares Strings and sorts them by length
* *
* @author Rsl1122 * @author Rsl1122
* @since 3.6.2 * @since 3.6.2

View File

@ -28,11 +28,12 @@ public class Hastebin {
/** /**
* Uploads the content safely to Hastebin. * Uploads the content safely to Hastebin.
* Longer than allowed content is being uploaded too. * Longer than allowed content is being uploaded too.
* * <p>
* @return The link to the Dump Log * Splits the content into parts of 390.000 chars each,
* @implNote Splits the content into parts of 390.000 chars each,
* uploads the parts in reverse order and adds the last link (if present) * uploads the parts in reverse order and adds the last link (if present)
* at each end of the following part, that's why the redundancy of 10.000 chars exists. * at each end of the following part, that's why the redundancy of 10.000 chars exists.
*
* @return The link to the Dump Log
* @see #split(String) * @see #split(String)
*/ */
public static String safeUpload(String content) { public static String safeUpload(String content) {

View File

@ -413,23 +413,15 @@ public class HtmlStructure {
String serverName = plugin.getServerInfoManager().getServerName(); String serverName = plugin.getServerInfoManager().getServerName();
String address = "../server/" + serverName; String address = "../server/" + serverName;
StringBuilder b = new StringBuilder("<div class=\"column\">");
// Header return "<div class=\"column\">" + "<div class=\"box-header\"><h2><i class=\"fa fa-server\" aria-hidden=\"true\"></i> " +
b.append("<div class=\"box-header\"><h2><i class=\"fa fa-server\" aria-hidden=\"true\"></i> ") serverName +
.append(serverName) "</h2></div>" +
.append("</h2></div>"); "<div class=\"box\"><p>" + online + "/" + maxPlayers +
" Players Online</p></div>" +
// Online players "<div class=\"box-footer\"><p>Last Refresh: " + refresh + "</p>" +
b.append("<div class=\"box\"><p>").append(online).append("/").append(maxPlayers) "<a href=\"" + address + "\" class=\"button right\">Analysis</a>" +
.append(" Players Online</p></div>"); "</div></div>";
// Footer
b.append("<div class=\"box-footer\"><p>Last Refresh: ").append(refresh).append("</p>");
b.append("<a href=\"").append(address).append("\" class=\"button right\">Analysis</a>");
b.append("</div>").append("</div>");
return b.toString();
} }
public static String parseOfflineServerContainer(String oldContent) { public static String parseOfflineServerContainer(String oldContent) {

View File

@ -23,9 +23,11 @@ public class HtmlUtils {
} }
/** /**
* @param html * Replaces ${placeholder} placeholders.
* @param replaceMap *
* @return * @param html Html to replace placeholders from
* @param replaceMap Placeholders and values
* @return Html with placeholders replaced
*/ */
public static String replacePlaceholders(String html, Map<String, Serializable> replaceMap) { public static String replacePlaceholders(String html, Map<String, Serializable> replaceMap) {
StrSubstitutor sub = new StrSubstitutor(replaceMap); StrSubstitutor sub = new StrSubstitutor(replaceMap);
@ -63,16 +65,20 @@ public class HtmlUtils {
} }
/** /**
* @param string * Attempts to remove XSS components.
* @return *
* @param string String to remove XSS components from
* @return String but with the components removed
*/ */
public static String removeXSS(String string) { public static String removeXSS(String string) {
return string.replace("<!--", "").replace("-->", "").replace("</script>", ""); return string.replace("<!--", "").replace("-->", "").replace("</script>", "").replace("<script>", "");
} }
/** /**
* @param string * Changes Minecraft color codes to HTML span elements with correct color class assignments.
* @return *
* @param string String to replace Minecraft color codes from
* @return String with span elements.
*/ */
public static String swapColorsToSpan(String string) { public static String swapColorsToSpan(String string) {
Html[] replacer = new Html[]{Html.COLOR_0, Html.COLOR_1, Html.COLOR_2, Html.COLOR_3, Html[] replacer = new Html[]{Html.COLOR_0, Html.COLOR_1, Html.COLOR_2, Html.COLOR_3,

View File

@ -8,7 +8,7 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* Class for creating scatter graph data from Chunk & Entity load snapshots with TPS task. * Class for creating scatter graph data from Chunk and Entity load snapshots with TPS task.
* *
* @author Rsl1122 * @author Rsl1122
* @see TPSCountTimer * @see TPSCountTimer

View File

@ -13,7 +13,7 @@ public class WorldPieCreator {
} }
/** /**
* Used to create HighCharts series string for series & drilldown. * Used to create HighCharts series string for series and drilldown.
* *
* @param worldTimes WorldTimes object. * @param worldTimes WorldTimes object.
* @return String array, index 0: Series data, 1: drilldown data * @return String array, index 0: Series data, 1: drilldown data

View File

@ -26,32 +26,36 @@ public class UUIDUtility {
} }
/** /**
* @param playername * Get UUID of a player.
* @return *
* @param playerName Player's name
* @return UUID of the player.
*/ */
public static UUID getUUIDOf(String playername) { public static UUID getUUIDOf(String playerName) {
try { try {
return getUUIDOf(playername, MiscUtils.getIPlan().getDB()); return getUUIDOf(playerName, MiscUtils.getIPlan().getDB());
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }
} }
/** /**
* @param playername * Get UUID of a player.
* @param db *
* @return * @param playerName Player's name
* @param db Database to check from.
* @return UUID of the player
*/ */
public static UUID getUUIDOf(String playername, Database db) { public static UUID getUUIDOf(String playerName, Database db) {
UUID uuid = null; UUID uuid = null;
try { try {
uuid = db.getUsersTable().getUuidOf(playername); uuid = db.getUsersTable().getUuidOf(playerName);
} catch (SQLException e) { } catch (SQLException e) {
Log.toLog("UUIDUtility", e); Log.toLog("UUIDUtility", e);
} }
try { try {
if (uuid == null) { if (uuid == null) {
uuid = UUIDFetcher.getUUIDOf(playername); uuid = UUIDFetcher.getUUIDOf(playerName);
} }
} catch (Exception | NoClassDefFoundError ignored) { } catch (Exception | NoClassDefFoundError ignored) {
/* Ignored */ /* Ignored */