Javadocs about 50% complete.

This commit is contained in:
Rsl1122 2017-05-14 15:19:16 +03:00
parent 13294cf308
commit 1df9eb1fd8
635 changed files with 126048 additions and 676 deletions

View File

@ -72,6 +72,20 @@
<property name='allowEmptyMethods' value='true' />
</module>
<!-- Javadoc -->
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="allowMissingParamTags" value="false"/>
<property name="allowMissingPropertyJavadoc" value="true"/>
<property name="allowMissingThrowsTags" value="false"/>
<property name="allowMissingReturnTag" value="false"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
</module>
<module name="JavadocStyle">
<property name="scope" value="public"/>
<property name="checkEmptyJavadoc" value="true"/>
</module>
</module>
<!-- File Length -->

View File

@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>CUSTOM-Javadoc</actionName>
<displayName>Javadoc</displayName>
<goals>
<goal>javadoc:javadoc</goal>
</goals>
</action>
<action>
<actionName>CUSTOM-checkstyle</actionName>
<displayName>Checkstyle</displayName>

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.djrapitops</groupId>
<artifactId>Plan</artifactId>
<version>2.0.0</version>
<version>3.1.1</version>
<packaging>jar</packaging>
<repositories>
<!-- <repository>
@ -169,6 +169,7 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<configuration>
<excludes>**/test/**/*</excludes>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>

View File

@ -52,7 +52,7 @@ public class Log {
}
/**
* Logs trace of caught Exception to Errors.txt & notifies on console.
* Logs trace of caught Exception to Errors.txt and notifies on console.
*
* @param source Class name the exception was caught in.
* @param e Throwable, eg NullPointerException

View File

@ -41,7 +41,7 @@ public enum Permissions {
}
/**
* Returns the string of the permission node in plugin.yml
* Returns the string of the permission node in plugin.yml.
*
* @return line of the permission eg. plan.inspect
*/

View File

@ -202,6 +202,8 @@ public enum Phrase {
}
/**
* Used to get the ChatColor of COLOR_ enums.
*
* @return Color of the COLOR_ENUM
*/
public ChatColor color() {
@ -209,16 +211,18 @@ public enum Phrase {
}
/**
* Used to set the text of the Enum.
*
* @param text
* @param text A String.
*/
public void setText(String text) {
this.text = text;
}
/**
* Set the ChatColor of any Enum.
*
* @param colorCode
* @param colorCode The character that determines a chatcolor. 1-9, a-f etc.
*/
public void setColor(char colorCode) {
this.color = ChatColor.getByChar(colorCode);

View File

@ -49,7 +49,7 @@ import org.bukkit.scheduler.BukkitTask;
/**
* Javaplugin class that contains methods for starting the plugin, logging to
* the Bukkit console & various get methods.
* the Bukkit console and various get methods.
*
* @author Rsl1122
* @since 1.0.0
@ -72,8 +72,9 @@ public class Plan extends JavaPlugin {
*
* Creates the config file. Checks for new version. Initializes Database.
* Hooks to Supported plugins. Initializes DataCaches. Registers Listeners.
* Registers Command /plan and initializes API. Enables Webserver & analysis
* tasks if enabled in config. Warns about possible mistakes made in config.
* Registers Command /plan and initializes API. Enables Webserver and
* analysis tasks if enabled in config. Warns about possible mistakes made
* in config.
*/
@Override
public void onEnable() {
@ -203,7 +204,7 @@ public class Plan extends JavaPlugin {
}
private void startAnalysisRefreshTask(int analysisRefreshMinutes) throws IllegalStateException, IllegalArgumentException {
BukkitTask asyncPeriodicalAnalysisTask = (new BukkitRunnable() {
BukkitTask asyncPeriodicalAnalysisTask = new BukkitRunnable() {
@Override
public void run() {
if (!analysisCache.isCached()) {
@ -212,19 +213,19 @@ public class Plan extends JavaPlugin {
analysisCache.updateCache();
}
}
}).runTaskTimerAsynchronously(this, analysisRefreshMinutes * 60 * 20, analysisRefreshMinutes * 60 * 20);
}.runTaskTimerAsynchronously(this, analysisRefreshMinutes * 60 * 20, analysisRefreshMinutes * 60 * 20);
}
private void startBootAnalysisTask() throws IllegalStateException, IllegalArgumentException {
Log.info(Phrase.ANALYSIS_BOOT_NOTIFY + "");
BukkitTask bootAnalysisTask = (new BukkitRunnable() {
BukkitTask bootAnalysisTask = new BukkitRunnable() {
@Override
public void run() {
Log.info(Phrase.ANALYSIS_BOOT + "");
analysisCache.updateCache();
this.cancel();
}
}).runTaskLater(this, 30 * 20);
}.runTaskLater(this, 30 * 20);
bootAnalysisTaskID = bootAnalysisTask.getTaskId();
}
@ -287,7 +288,7 @@ public class Plan extends JavaPlugin {
*
* #init() might need to be called in order for the object to function.
*
* @return Set containing the SqLite & MySQL objects.
* @return Set containing the SqLite and MySQL objects.
*/
public HashSet<Database> getDatabases() {
return databases;
@ -375,7 +376,7 @@ public class Plan extends JavaPlugin {
* Instance is set on the first line of onEnable method.
*
* @return current instance of Plan, Singleton.
* @throws IllegalStateException If onEnable method has not been called &
* @throws IllegalStateException If onEnable method has not been called and
* the instance is null.
*/
public static Plan getInstance() {
@ -400,7 +401,7 @@ public class Plan extends JavaPlugin {
*
* @return API of the current instance of Plan.
* @throws IllegalStateException If onEnable method has not been called on
* Plan & the instance is null.
* Plan and the instance is null.
*/
public static API getPlanAPI() throws IllegalStateException {
Plan INSTANCE = PlanHolder.INSTANCE;
@ -411,6 +412,7 @@ public class Plan extends JavaPlugin {
}
private static class PlanHolder {
private static Plan INSTANCE = null;
}
}

View File

@ -1,16 +1,15 @@
package main.java.com.djrapitops.plan.api;
import java.util.Date;
import java.util.UUID;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.AnalysisData;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.PluginData;
import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
import main.java.com.djrapitops.plan.ui.DataRequestHandler;
import main.java.com.djrapitops.plan.ui.webserver.WebSocketServer;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
import static org.bukkit.Bukkit.getOfflinePlayer;
@ -18,12 +17,16 @@ import org.bukkit.OfflinePlayer;
/**
* This class contains the API methods.
* <p>
* Methods can be called from Asyncronous task & are thread safe unless
*
* Methods can be called from Asyncronous task and are thread safe unless
* otherwise stated.
*
* @author Rsl1122
* @since 2.0.0
* @see PluginData
* @see AnalysisType
* @see DBCallableProcessor
* @see HandlingInfo
*/
public class API {
@ -55,7 +58,7 @@ public class API {
* data source that extends PluginData correctly.
*
* @param dataSource an object that extends PluginData-object, thus allowing
* Analysis & Inspect to manage the data of a plugin correctly.
* Analysis and Inspect to manage the data of a plugin correctly.
* @see PluginData
*/
public void addPluginDataSource(PluginData dataSource) {
@ -143,7 +146,7 @@ public class API {
* Uses cache if data is cached or database if not. Call from an Asyncronous
* thread.
*
* @param uuid
* @param uuid UUID of the player.
*/
public void cacheUserDataToInspectCache(UUID uuid) {
plugin.getInspectCache().cache(uuid);
@ -167,7 +170,7 @@ public class API {
}
/**
* Check if the Analysis has been run & is cached to the AnalysisCache.
* Check if the Analysis has been run and is cached to the AnalysisCache.
*
* @return true/false
*/
@ -176,7 +179,7 @@ public class API {
}
/**
* Run's the analysis with the current data in the cache & fetches rest from
* Run's the analysis with the current data in the cache and fetches rest from
* the database.
*
* Starts a new Asyncronous task to run the analysis.
@ -230,7 +233,7 @@ public class API {
}
/**
* Uses UUIDFetcher to turn PlayerName to UUID
* Uses UUIDFetcher to turn PlayerName to UUID.
*
* @param playerName Player's name
* @return UUID of the Player
@ -239,25 +242,4 @@ public class API {
public UUID playerNameToUUID(String playerName) throws Exception {
return UUIDFetcher.getUUIDOf(playerName);
}
// DEPRECATED METHODS WILL BE REMOVED IN 3.2.0
@Deprecated
public static String formatTimeSinceDate(Date before, Date after) {
return FormatUtils.formatTimeAmountSinceDate(before, after);
}
@Deprecated
public static String formatTimeSinceString(String before, Date after) {
return FormatUtils.formatTimeAmountSinceString(before, after);
}
@Deprecated
public static String formatTimeAmount(String timeInMs) {
return FormatUtils.formatTimeAmount(timeInMs);
}
@Deprecated
public static String formatTimeStamp(String timeInMs) {
return FormatUtils.formatTimeStamp(timeInMs);
}
}

View File

@ -83,7 +83,7 @@ public class PlanCommand implements CommandExecutor {
*
* @param sender source of the command.
* @param cmd command.
* @param commandLabel
* @param commandLabel label.
* @param args arguments of the command
* @return true
*/
@ -113,7 +113,7 @@ public class PlanCommand implements CommandExecutor {
return true;
}
if (console && command.getCommandType() == CommandType.PLAYER) {;
if (console && command.getCommandType() == CommandType.PLAYER) {
sender.sendMessage("" + Phrase.COMMAND_SENDER_NOT_PLAYER);
return true;
@ -125,9 +125,7 @@ public class PlanCommand implements CommandExecutor {
realArgs[i - 1] = args[i];
}
if (!command.onCommand(sender, cmd, commandLabel, realArgs)) {
// Phrase.TRY_COMMAND.sendWithPrefix( sender, parse( commandLabel, command ) );
}
command.onCommand(sender, cmd, commandLabel, realArgs);
return true;
}

View File

@ -2,6 +2,7 @@ package main.java.com.djrapitops.plan.command;
import main.java.com.djrapitops.plan.Permissions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
/**
@ -93,11 +94,12 @@ public abstract class SubCommand {
/**
* The Command Execution method.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args
* @param sender Parameter of onCommand in CommandExecutor.
* @param cmd Parameter of onCommand in CommandExecutor.
* @param commandLabel Parameter of onCommand in CommandExecutor.
* @param args Parameter of onCommand in CommandExecutor.
* @return Was the execution successful?
* @see CommandExecutor
*/
public abstract boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args);
}

View File

@ -12,7 +12,6 @@ import main.java.com.djrapitops.plan.ui.TextUI;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -40,18 +39,6 @@ public class AnalyzeCommand extends SubCommand {
analysisCache = plugin.getAnalysisCache();
}
/**
* Subcommand analyze.
*
* Updates AnalysisCache if last refresh was over 60 seconds ago and sends
* player the link that views cache with a delayed timer task.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
@ -73,7 +60,7 @@ public class AnalyzeCommand extends SubCommand {
analysisCache.updateCache();
}
BukkitTask analysisMessageSenderTask = (new BukkitRunnable() {
BukkitTask analysisMessageSenderTask = new BukkitRunnable() {
private int timesrun = 0;
@Override
@ -88,7 +75,7 @@ public class AnalyzeCommand extends SubCommand {
this.cancel();
}
}
}).runTaskTimer(plugin, 1 * 20, 5 * 20);
}.runTaskTimer(plugin, 1 * 20, 5 * 20);
return true;
}
@ -96,9 +83,8 @@ public class AnalyzeCommand extends SubCommand {
* Used to send the message after /plan analysis.
*
* @param sender Command sender.
* @throws CommandException
*/
public void sendAnalysisMessage(CommandSender sender) throws CommandException {
public void sendAnalysisMessage(CommandSender sender) {
boolean textUI = Settings.USE_ALTERNATIVE_UI.isTrue();
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER + "");
if (textUI) {

View File

@ -11,7 +11,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
/**
* This subcommand is used to view the version & the database type in use.
* This subcommand is used to view the version and the database type in use.
*
* @author Rsl1122
* @since 2.0.0

View File

@ -43,17 +43,6 @@ public class InspectCommand extends SubCommand {
inspectCache = plugin.getInspectCache();
}
/**
* Subcommand inspect.
*
* Adds player's data from DataCache/DB to the InspectCache
*
* @param sender args is empty, can not be Console.
* @param cmd
* @param commandLabel
* @param args Player's name or nothing - if empty sender's name is used.
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
final boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
@ -66,7 +55,7 @@ public class InspectCommand extends SubCommand {
}
}
String playerName = MiscUtils.getPlayerName(args, sender);
BukkitTask inspectTask = (new BukkitRunnable() {
BukkitTask inspectTask = new BukkitRunnable() {
@Override
public void run() {
UUID uuid;
@ -98,7 +87,7 @@ public class InspectCommand extends SubCommand {
configValue = 4;
}
final int available = configValue;
BukkitTask inspectMessageSenderTask = (new BukkitRunnable() {
BukkitTask inspectMessageSenderTask = new BukkitRunnable() {
private int timesrun = 0;
@Override
@ -134,9 +123,9 @@ public class InspectCommand extends SubCommand {
this.cancel();
}
}
}).runTaskTimer(plugin, 1 * 20, 5 * 20);
}.runTaskTimer(plugin, 1 * 20, 5 * 20);
}
}).runTaskAsynchronously(plugin);
}.runTaskAsynchronously(plugin);
return true;
}
}

View File

@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
/**
* This command is used to manage the database of the plugin.
* <p>
*
* No arguments will run ManageHelpCommand. Contains subcommands.
*
* @author Rsl1122
@ -79,16 +79,6 @@ public class ManageCommand extends SubCommand {
onCommand(sender, cmd, commandLabel, FormatUtils.mergeArrays(new String[]{command}, args));
}
/**
* Checks if Sender has rights to run the command and executes matching
* subcommand.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (args.length < 1) {
@ -116,7 +106,7 @@ public class ManageCommand extends SubCommand {
return true;
}
if (console && command.getCommandType() == CommandType.PLAYER) {;
if (console && command.getCommandType() == CommandType.PLAYER) {
sender.sendMessage("" + Phrase.COMMAND_SENDER_NOT_PLAYER);
return true;
@ -128,8 +118,7 @@ public class ManageCommand extends SubCommand {
realArgs[i - 1] = args[i];
}
if (!command.onCommand(sender, cmd, commandLabel, realArgs)) {
}
command.onCommand(sender, cmd, commandLabel, realArgs);
return true;
}

View File

@ -36,18 +36,6 @@ public class QuickAnalyzeCommand extends SubCommand {
analysisCache = plugin.getAnalysisCache();
}
/**
* Subcommand qanalyze (QuickAnalyze).
*
* Updates AnalysisCache if last refresh was over 60 seconds ago and sends
* player the text ui msgs about analysis data
*
* @param sender
* @param cmd
* @param commandLabel
* @param args
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
@ -61,7 +49,7 @@ public class QuickAnalyzeCommand extends SubCommand {
analysisCache.updateCache();
}
BukkitTask analysisMessageSenderTask = (new BukkitRunnable() {
BukkitTask analysisMessageSenderTask = new BukkitRunnable() {
private int timesrun = 0;
@Override
@ -78,7 +66,7 @@ public class QuickAnalyzeCommand extends SubCommand {
this.cancel();
}
}
}).runTaskTimer(plugin, 1 * 20, 5 * 20);
}.runTaskTimer(plugin, 1 * 20, 5 * 20);
return true;
}
}

View File

@ -42,21 +42,10 @@ public class QuickInspectCommand extends SubCommand {
inspectCache = plugin.getInspectCache();
}
/**
* Subcommand qinspect (QuickInspect).
*
* Adds player's data from DataCache/DB to the InspectCache
*
* @param sender args is empty, can not be Console.
* @param cmd
* @param commandLabel
* @param args Player's name or nothing - if empty sender's name is used.
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.QUICK_INSPECT_OTHER);
BukkitTask inspectTask = (new BukkitRunnable() {
BukkitTask inspectTask = new BukkitRunnable() {
@Override
public void run() {
UUID uuid;
@ -88,7 +77,7 @@ public class QuickInspectCommand extends SubCommand {
configValue = 4;
}
final int available = configValue;
BukkitTask inspectMessageSenderTask = (new BukkitRunnable() {
BukkitTask inspectMessageSenderTask = new BukkitRunnable() {
private int timesrun = 0;
@Override
@ -105,9 +94,9 @@ public class QuickInspectCommand extends SubCommand {
this.cancel();
}
}
}).runTaskTimer(plugin, 1 * 20, 5 * 20);
}.runTaskTimer(plugin, 1 * 20, 5 * 20);
}
}).runTaskAsynchronously(plugin);
}.runTaskAsynchronously(plugin);
return true;
}
}

View File

@ -43,18 +43,6 @@ public class SearchCommand extends SubCommand {
inspectCache = plugin.getInspectCache();
}
/**
* Subcommand search.
*
* Searches database for matching playernames and caches matching UserData
* to InspectCache. Shows all links to matching players data.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args Part of a Players name
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
@ -68,7 +56,7 @@ public class SearchCommand extends SubCommand {
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
Set<OfflinePlayer> matches = MiscUtils.getMatchingDisplaynames(args[0]);
BukkitTask searchTask = (new BukkitRunnable() {
BukkitTask searchTask = new BukkitRunnable() {
@Override
public void run() {
Set<UUID> uuids = new HashSet<>();
@ -122,7 +110,7 @@ public class SearchCommand extends SubCommand {
sender.sendMessage(Phrase.CMD_RESULTS_AVAILABLE.parse(available + ""));
sender.sendMessage(Phrase.CMD_FOOTER + "");
}
}).runTaskAsynchronously(plugin);
}.runTaskAsynchronously(plugin);
return true;
}
}

View File

@ -33,15 +33,6 @@ public class ManageBackupCommand extends SubCommand {
this.plugin = plugin;
}
/**
* Subcommand Manage backup.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args mysql or sqlite, -a to confirm.
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
try {

View File

@ -34,19 +34,6 @@ public class ManageClearCommand extends SubCommand {
this.plugin = plugin;
}
/**
* Subcommand inspect.
*
* Adds player's data from DataCache/DB to the InspectCache for amount of
* time specified in the config, and clears the data from Cache with a timer
* task.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args Player's name or nothing - if empty sender's name is used.
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (args.length == 0) {

View File

@ -33,16 +33,6 @@ public class ManageHotswapCommand extends SubCommand {
this.plugin = plugin;
}
/**
* Subcommand hotswap. Swaps db type and reloads plugin if the connection
* works.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args Player's name or nothing - if empty sender's name is used.
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (args.length == 0) {

View File

@ -43,19 +43,6 @@ public class ManageImportCommand extends SubCommand {
this.plugin = plugin;
}
/**
* Subcommand inspect.
*
* Adds player's data from DataCache/DB to the InspectCache for amount of
* time specified in the config, and clears the data from Cache with a timer
* task.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args Player's name or nothing - if empty sender's name is used.
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
@ -90,7 +77,7 @@ public class ManageImportCommand extends SubCommand {
uuids.add(p.getUniqueId());
}
HashMap<UUID, Long> numbericData = importPlugins.get(importFromPlugin).grabNumericData(uuids);
BukkitTask asyncImportTask = (new BukkitRunnable() {
BukkitTask asyncImportTask = new BukkitRunnable() {
@Override
public void run() {
if (importFromPlugin.equals("ontime")) {
@ -100,7 +87,7 @@ public class ManageImportCommand extends SubCommand {
}
this.cancel();
}
}).runTaskAsynchronously(plugin);
}.runTaskAsynchronously(plugin);
return true;
}
}

View File

@ -71,7 +71,7 @@ public class ManageRestoreCommand extends SubCommand {
return true;
}
final Database copyToDB = database;
BukkitTask asyncRestoreTask = (new BukkitRunnable() {
BukkitTask asyncRestoreTask = new BukkitRunnable() {
@Override
public void run() {
String backupDBName = args[0];
@ -105,7 +105,7 @@ public class ManageRestoreCommand extends SubCommand {
}
this.cancel();
}
}).runTaskAsynchronously(plugin);
}.runTaskAsynchronously(plugin);
} catch (NullPointerException e) {
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
}

View File

@ -6,6 +6,7 @@ import java.util.Map;
import java.util.Objects;
import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.ui.RecentPlayersButtonsCreator;
import main.java.com.djrapitops.plan.ui.graphs.PlayerActivityGraphCreator;
import main.java.com.djrapitops.plan.ui.tables.SortableCommandUseTableCreator;
import main.java.com.djrapitops.plan.ui.tables.SortablePlayersTableCreator;
import main.java.com.djrapitops.plan.utilities.Analysis;
@ -304,7 +305,7 @@ public class AnalysisData {
}
/**
* Used to get the amount of players who have joined only once
* Used to get the amount of players who have joined only once.
*
* @return Number from 0 to Integer.MAX
*/
@ -777,7 +778,7 @@ public class AnalysisData {
*
* No check for correct value.
*
* @param totaldeaths
* @param totaldeaths 0 to Long.MAX
*/
public void setTotaldeaths(long totaldeaths) {
this.totaldeaths = totaldeaths;
@ -792,8 +793,8 @@ public class AnalysisData {
* 0, 1 day; 2, 3 week; 4, 5 month
*
* @return String array containing multiple toString representations of
* number & label arrays.
* @see PlayersActivityGraphCreator
* number and label arrays.
* @see PlayerActivityGraphCreator
* @see Analysis
*/
public String[] getPlayersDataArray() {
@ -809,8 +810,8 @@ public class AnalysisData {
* 0, 1 day; 2, 3 week; 4, 5 month
*
* @param playersDataArray String array containing multiple toString
* representations of number & label arrays.
* @see PlayersActivityGraphCreator
* representations of number and label arrays.
* @see PlayerActivityGraphCreator
* @see Analysis
*/
public void setPlayersDataArray(String[] playersDataArray) {

View File

@ -31,7 +31,7 @@ public class KillData {
}
/**
* Get the victim's UUID
* Get the victim's UUID.
*
* @return UUID of the victim.
*/

View File

@ -4,13 +4,15 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import main.java.com.djrapitops.plan.utilities.Analysis;
/**
* This class is used for storing combined data of several UserData objects
* during Analysis.
* during Analysis and thus is not documented.
*
* @author Rsl1122
* @since 2.6.0
* @see Analysis
*/
public class RawAnalysisData {
@ -370,7 +372,7 @@ public class RawAnalysisData {
*
* @param commandUse
*/
public void setCommandUse(HashMap<String, Integer> commandUse) {
public void setCommandUse(Map<String, Integer> commandUse) {
this.commandUse = commandUse;
}

View File

@ -56,10 +56,10 @@ public class UserData {
private List<SessionData> sessions;
/**
* Creates a new UserData object with given values & default values.
* Creates a new UserData object with given values and default values.
*
* Some variables are left uninitialized: isBanned, lastPlayed, playTime,
* loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths &
* loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths and
* currentSession.
*
* These variables need to be set with setters.
@ -110,7 +110,7 @@ public class UserData {
* Creates a new UserData object with the variables inside a Player object.
*
* Some variables are left uninitialized: lastPlayed, playTime, loginTimes,
* timesKicked, lastGmSwapTime, mobKills, deaths & currentSession.
* timesKicked, lastGmSwapTime, mobKills, deaths and currentSession.
*
* These variables need to be set with setters.
*
@ -139,7 +139,7 @@ public class UserData {
* object.
*
* Some variables are left uninitialized: location, lastPlayed, playTime,
* loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths &
* loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths and
* currentSession.
*
* These variables need to be set with setters.
@ -454,7 +454,7 @@ public class UserData {
}
/**
* Get the nickname String Set
* Get the nickname String Set.
*
* @return a HashSet of Strings.
*/
@ -696,7 +696,7 @@ public class UserData {
/**
* Set the GM Times map containing playtime in each gamemode.
*
* @param gmTimes Map containing SURVIVAL, CREATIVE, ADVENTURE & SPECTATOR
* @param gmTimes Map containing SURVIVAL, CREATIVE, ADVENTURE and SPECTATOR
* (After 1.8) keys.
*/
public void setGmTimes(Map<GameMode, Long> gmTimes) {

View File

@ -1,8 +1,6 @@
package main.java.com.djrapitops.plan.data.additional;
import main.java.com.djrapitops.plan.data.additional.advancedachievements.AdvancedAchievementsTable;
import main.java.com.djrapitops.plan.data.additional.factions.FactionsMaxPower;
import main.java.com.djrapitops.plan.data.additional.factions.FactionsPower;
import main.java.com.djrapitops.plan.data.additional.factions.FactionsTable;
import main.java.com.djrapitops.plan.data.additional.towny.TownyTable;
@ -16,46 +14,47 @@ import main.java.com.djrapitops.plan.data.additional.towny.TownyTable;
* Refer to the documentation on github for additional information.
*
* @author Rsl1122
* @since 3.1.0
*/
public enum AnalysisType {
/**
* Used when the getValue() method returns an integer & average should be
* Used when the getValue() method returns an integer and average should be
* calculated.
*
* -1 values will be disregarded from the calculation (size will not grow).
*/
INT_AVG("avgInt_","Average "),
INT_AVG("avgInt_", "Average "),
/**
* Used when the getValue() method returns a long & average should be
* Used when the getValue() method returns a long and average should be
* calculated.
*
* -1 values will be disregarded from the calculation (size will not grow).
*/
LONG_AVG("avgLong_","Average "),
LONG_AVG("avgLong_", "Average "),
/**
* Used when the getValue() method returns double & average should be
* Used when the getValue() method returns double and average should be
* calculated.
*
* -1 values will be disregarded from the calculation (size will not grow).
*/
DOUBLE_AVG("avgDouble_", "Average "),
/**
* Used when the getValue() method returns an integer & total should be
* Used when the getValue() method returns an integer and total should be
* calculated.
*
* -1 values will be disregarded from the calculation (size will not grow).
*/
INT_TOTAL("totalInt_"),
/**
* Used when the getValue() method returns a long & total should be
* Used when the getValue() method returns a long and total should be
* calculated.
*
* -1 values will be disregarded from the calculation (size will not grow).
*/
LONG_TOTAL("totalLong_"),
/**
* Used when the getValue() method returns a double & total should be
* Used when the getValue() method returns a double and total should be
* calculated.
*
* -1 values will be disregarded from the calculation (size will not grow).
@ -63,24 +62,24 @@ public enum AnalysisType {
DOUBLE_TOTAL("totalDouble_"),
/**
* Used when the getValue() method returns an amount of milliseconds as long
* & average should be calculated.
* and average should be calculated.
*
* -1 values will be disregarded from the calculation (size will not grow).
*/
LONG_TIME_MS_AVG("avgTimeMs_", "Average "),
/**
* Used when the getValue() method returns an amount of milliseconds as long
* & total should be calculated.
* and total should be calculated.
*
* -1 values will be disregarded from the calculation (size will not grow).
*/
LONG_TIME_MS_TOTAL("totalTimeMs_"),
/**
* Used when the getValue() method returns an Epoch Millisecond as long &
* average of differences between the millisecond & current millisecond
* Used when the getValue() method returns an Epoch Millisecond as long and
* average of differences between the millisecond and current millisecond
* should be calculated.
*
* For example if a player has dropped a Foo on epoch ms 1494486504000 &
* For example if a player has dropped a Foo on epoch ms 1494486504000 and
* that was 5s (5000ms) ago. Now you want to calculate the average
* time-since for all players. Then you use this one.
*
@ -90,7 +89,7 @@ public enum AnalysisType {
/**
* Used to calculate %-true for the returned boolean values of getValue().
*/
BOOLEAN_PERCENTAGE("perchBool_","Percentage "),
BOOLEAN_PERCENTAGE("perchBool_", "Percentage "),
/**
* Used to calculate number of true values for the returned boolean values
* of getValue().
@ -101,7 +100,7 @@ public enum AnalysisType {
/**
* Used to add html tags to the plugins tab.
*
* Can be used to add Tables, Images (for example maps) & other html
* Can be used to add Tables, Images (for example maps) and other html
* elements.
*
* @see AdvancedAchievementsTable
@ -140,6 +139,11 @@ public enum AnalysisType {
return modifier;
}
/**
* Used to get the Placeholder modifier.
*
* @return for example "_total"
*/
public String getPlaceholderModifier() {
return placeholderModifier;
}

View File

@ -7,6 +7,7 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
* Abstract class for easy hooking of plugins.
*
* @author Rsl1122
* @since 2.6.0
*/
public abstract class Hook {
@ -35,4 +36,13 @@ public abstract class Hook {
public Hook() {
enabled = false;
}
/**
* Check if the hooked plugin is enabled.
*
* @return true/false
*/
public boolean isEnabled() {
return enabled;
}
}

View File

@ -17,10 +17,11 @@ import main.java.com.djrapitops.plan.data.additional.vault.VaultHook;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
/**
* Class responsible for hooking to other plugins & managing the %plugins%
* placeholder on Analysis & Inspect pages.
* Class responsible for hooking to other plugins and managing the %plugins%
* placeholder on Analysis and Inspect pages.
*
* @author Rsl1122
* @since 2.6.0
*/
public class HookHandler {

View File

@ -10,12 +10,13 @@ import main.java.com.djrapitops.plan.ui.Html;
/**
* This is an abstract class that can be used to add data from a plugin to the
* "Plugins"-tab of Analysis & Inspect pages.
* "Plugins"-tab of Analysis and Inspect pages.
*
* API-section of documentation has examples on the usage of this class & how to
* register objects extending this class.
* API-section of documentation has examples on the usage of this class and how
* to register objects extending this class.
*
* @author Rsl1122
* @since 3.1.0
*/
public abstract class PluginData {
@ -23,7 +24,7 @@ public abstract class PluginData {
* Placeholder string, for example "stepsTaken". This will be used when
* building the structure of the Plugins tab.
*
* The complete placeholder also includes the plugin name & if analysis is
* The complete placeholder also includes the plugin name and if analysis is
* run, a modifier.
*
* Second parameter of any super constructor.
@ -78,7 +79,7 @@ public abstract class PluginData {
*
* Defaults analysisOnly to true.
*
* Defaults icon, prefix & suffix to "".
* Defaults icon, prefix and suffix to "".
*
* @param sourcePlugin Name of the plugin the data is coming from
* @param placeholder Placeholder string, for example "stepsTaken"
@ -96,7 +97,7 @@ public abstract class PluginData {
}
/**
* Constructor for accepting single, multiple & arrays of AnalysisType.
* Constructor for accepting single, multiple and arrays of AnalysisType.
*
* @param sourcePlugin Name of the plugin the data is coming from
* @param placeholder Placeholder string, for example "stepsTaken"
@ -135,7 +136,7 @@ public abstract class PluginData {
* This method should be used with the return values of
* getHtmlReplaceValue(String, UUID).
*
* It will add the div, icon, modifier, prefix & suffix to the value.
* It will add the div, icon, modifier, prefix and suffix to the value.
* Modifier is for example, if calculating AnalysisType.INT_AVG "Average ",
* it is a text that helps user understand that a calculation has been made.
*
@ -147,13 +148,13 @@ public abstract class PluginData {
* @see AnalysisType
*/
public final String parseContainer(String modifier, String contents) {
return "<div class=\"plugin-data\">" + icon + modifier + prefix + contents + suffix + "</div>";
return "<div class=\"plugin-data\">" + Html.FONT_AWESOME_ICON.parse(icon) + modifier + prefix + contents + suffix + "</div>";
}
/**
* Used to get the full placeholder.
*
* Used to avoid conflicts with existing placeholders & placeholders of
* Used to avoid conflicts with existing placeholders and placeholders of
* other plugins.
*
* @param modifier Modifier determined by AnalysisType's
@ -178,7 +179,7 @@ public abstract class PluginData {
* Used to get the string for the html page.
*
* parseContainer(modifierPrefix, value); should be used for all return
* values so that div, icon, prefix & suffix are added.
* values so that div, icon, prefix and suffix are added.
*
* This method is used when AnalysisType.HTML is set, or while getting the
* value for the inspect page.
@ -199,11 +200,11 @@ public abstract class PluginData {
* AnalysisType you have specified. If the AnalysisType's name has a BOOLEAN
* in it, Analysis will expect boolean values etc.
*
* If the Type & return value mismatch, exception is thrown and the result
* If the Type and return value mismatch, exception is thrown and the result
* on the analysis page will say that error occurred as the value.
*
* If a player has no value a -1 should be returned in the case of a Number.
* -1 is excluded from the Average calculation's size & total.
* -1 is excluded from the Average calculation's size and total.
*
* @param uuid UUID of the player the value belongs to.
* @return Long, Integer, Double, Boolean or String, return -1 if the player
@ -235,7 +236,7 @@ public abstract class PluginData {
* @param iconName Icon's name http://fontawesome.io/icons/
*/
public final void setIcon(String iconName) {
this.icon = Html.FONT_AWESOME_ICON.parse(iconName) + " ";
this.icon = iconName + " ";
}
/**
@ -261,6 +262,7 @@ public abstract class PluginData {
/**
* Used to get the prefix.
*
* @return example: "Steps Taken "
*/
public final String getPrefix() {
@ -269,6 +271,7 @@ public abstract class PluginData {
/**
* Used to get the suffix.
*
* @return example: " steps"
*/
public final String getSuffix() {
@ -276,7 +279,7 @@ public abstract class PluginData {
}
/**
* If a PluginData object has same placeholder, sourcePlugin &
* If a PluginData object has same placeholder, sourcePlugin and
* analysisTypes, it is considired equal.
*
* @param obj Another Object.

View File

@ -7,13 +7,25 @@ import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.PluginData;
/**
* PluginData class for AdvancedAchievements-plugin.
*
* Registered to the plugin by AdvancedAchievementsHook.
*
* Gives the amount of achievements as value.
*
* @author Rsl1122
* @since 3.1.0
* @see AdvancedAchievementsHook
*/
public class AdvancedAchievementsAchievements extends PluginData {
private AdvancedAchievementsAPI aaAPI;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param aaAPI AdvancedAchievementsAPI given by AdvancedAchievementsHook
*/
public AdvancedAchievementsAchievements(AdvancedAchievementsAPI aaAPI) {
super("AdvancedAchievements", "achievements", new AnalysisType[]{AnalysisType.INT_TOTAL, AnalysisType.INT_AVG});
this.aaAPI = aaAPI;

View File

@ -4,19 +4,29 @@ import main.java.com.djrapitops.plan.data.additional.Hook;
import com.hm.achievement.AdvancedAchievements;
import com.hm.achievement.api.AdvancedAchievementsAPI;
import com.hm.achievement.api.AdvancedAchievementsBukkitAPI;
import main.java.com.djrapitops.plan.api.API;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/**
* A Class responsible for hooking to AdvancedAchievements and registering 2 data
* sources.
*
* @author Rsl1122
* @since 3.1.0
*/
public class AdvancedAchievementsHook extends Hook {
private AdvancedAchievements aa;
/**
* Hooks the plugin and calculates Total Achievements.
* Hooks the plugin and registers it's PluginData objects.
*
* API#addPluginDataSource uses the same method from HookHandler.
*
* @param hookH HookHandler instance for registering the data sources.
* @see API
* @throws NoClassDefFoundError when the plugin class can not be found.
*/
public AdvancedAchievementsHook(HookHandler hookH) throws NoClassDefFoundError {
super("com.hm.achievement.AdvancedAchievements");

View File

@ -14,13 +14,28 @@ import static org.bukkit.Bukkit.getOfflinePlayers;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for AdvancedAchievements-plugin.
*
* Registered to the plugin by AdvancedAchievementsHook
*
* Gives a table of players and achievements achievements.
*
* @author Rsl1122
* @since 3.1.0
* @see AdvancedAchievementsHook
*/
public class AdvancedAchievementsTable extends PluginData {
private AdvancedAchievementsAPI aaAPI;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* Uses Html to easily parse Html for the table.
*
* @param aaAPI AdvancedAchievementsAPI given by AdvancedAchievementsHook
* @see Html
*/
public AdvancedAchievementsTable(AdvancedAchievementsAPI aaAPI) {
super("AdvancedAchievements", "achievementstable", AnalysisType.HTML);
this.aaAPI = aaAPI;
@ -36,7 +51,7 @@ public class AdvancedAchievementsTable extends PluginData {
StringBuilder html = new StringBuilder();
List<OfflinePlayer> offlinePlayers = Arrays.stream(getOfflinePlayers()).filter(p -> p.hasPlayedBefore()).collect(Collectors.toList());
if (offlinePlayers.isEmpty()) {
html.append(Html.TABLELINE_2.parse("No Players.",""));
html.append(Html.TABLELINE_2.parse("No Players.", ""));
} else {
for (OfflinePlayer p : offlinePlayers) {
String inspectUrl = HtmlUtils.getInspectUrl(p.getName());

View File

@ -2,20 +2,28 @@ package main.java.com.djrapitops.plan.data.additional.essentials;
import main.java.com.djrapitops.plan.data.additional.Hook;
import com.earth2me.essentials.Essentials;
import main.java.com.djrapitops.plan.api.API;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/**
* A Class responsible for hooking to Essentials and registering 3 data sources.
*
* @author Rsl1122
* @since 3.1.0
*/
public class EssentialsHook extends Hook {
/**
* Hooks to Essentials plugin
* Hooks the plugin and registers it's PluginData objects.
*
* API#addPluginDataSource uses the same method from HookHandler.
*
* @param hookH HookHandler instance for registering the data sources.
* @see API
* @throws NoClassDefFoundError when the plugin class can not be found.
*/
public EssentialsHook(HookHandler hookH) throws NoClassDefFoundError{
public EssentialsHook(HookHandler hookH) throws NoClassDefFoundError {
super("com.earth2me.essentials.Essentials");
if (enabled) {
Essentials ess = getPlugin(Essentials.class);

View File

@ -8,13 +8,25 @@ import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.PluginData;
/**
* PluginData class for Essentials-plugin.
*
* Registered to the plugin by EssentialsHook
*
* Gives Jailed boolean value.
*
* @author Rsl1122
* @since 3.1.0
* @see EssentialsHook
*/
public class EssentialsJailed extends PluginData {
private Essentials essentials;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param essentials Instance of Essentials plugin.
*/
public EssentialsJailed(Essentials essentials) {
super("Essentials", "jailed", AnalysisType.BOOLEAN_PERCENTAGE, AnalysisType.BOOLEAN_TOTAL);
this.essentials = essentials;
@ -37,5 +49,5 @@ public class EssentialsJailed extends PluginData {
User user = essentials.getUser(uuid);
return user != null && user.isJailed();
}
}

View File

@ -8,13 +8,25 @@ import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.PluginData;
/**
* PluginData class for Essentials-plugin.
*
* Registered to the plugin by EssentialsHook
*
* Gives Muted boolean value.
*
* @author Rsl1122
* @since 3.1.0
* @see EssentialsHook
*/
public class EssentialsMuted extends PluginData {
private Essentials essentials;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param essentials Instance of Essentials plugin.
*/
public EssentialsMuted(Essentials essentials) {
super("Essentials", "muted", AnalysisType.BOOLEAN_PERCENTAGE, AnalysisType.BOOLEAN_TOTAL);
this.essentials = essentials;
@ -27,7 +39,7 @@ public class EssentialsMuted extends PluginData {
public String getHtmlReplaceValue(String modifier, UUID uuid) {
User user = essentials.getUser(uuid);
if (user != null) {
return parseContainer("", user.isMuted()? "Yes" : "No");
return parseContainer("", user.isMuted() ? "Yes" : "No");
}
return "";
}
@ -37,5 +49,5 @@ public class EssentialsMuted extends PluginData {
User user = essentials.getUser(uuid);
return user != null && user.isMuted();
}
}

View File

@ -8,13 +8,25 @@ import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.PluginData;
/**
* PluginData class for Essentials-plugin.
*
* Registered to the plugin by EssentialsHook
*
* Gives a list of warps as a String value.
*
* @author Rsl1122
* @since 3.1.0
* @see EssentialsHook
*/
public class EssentialsWarps extends PluginData {
private Essentials essentials;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param essentials Instance of Essentials plugin.
*/
public EssentialsWarps(Essentials essentials) {
super("Essentials", "warps", AnalysisType.HTML);
this.essentials = essentials;

View File

@ -4,13 +4,18 @@ import com.massivecraft.factions.entity.Faction;
import java.util.Comparator;
/**
* This class is used to compare factions in terms of Power.
*
* Compare method should only be used if FactionsHook.isEnabled() returns true.
*
* Note: this comparator imposes orderings that are inconsistent with equals.
*
* @author Rsl1122
* @since 3.1.0
* @see FactionsHook
*/
public class FactionComparator implements Comparator<Faction> {
// This method should only be used if FactionsHook.isEnabled() returns true.
// Note: this comparator imposes orderings that are inconsistent with equals.
@Override
public int compare(Faction fac1, Faction fac2) {
if (fac1.getPower() > fac2.getPower()) {

View File

@ -6,11 +6,21 @@ import java.util.UUID;
import main.java.com.djrapitops.plan.data.additional.PluginData;
/**
* PluginData class for Factions-plugin.
*
* Registered to the plugin by FactionsHook
*
* Gives a Faction name String as value.
*
* @author Rsl1122
* @since 3.1.0
* @see FactionsHook
*/
public class FactionsFaction extends PluginData {
/**
* Class Constructor, sets the parameters of the PluginData object.
*/
public FactionsFaction() {
super("Factions", "faction");
super.setIcon("flag");

View File

@ -8,21 +8,28 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.api.API;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
/**
* A Class responsible for hooking to Factions and registering 4 data sources.
*
* @author Rsl1122
* @since 3.1.0
*/
public class FactionsHook extends Hook {
/**
* Hooks to Factions plugin
* Hooks the plugin and registers it's PluginData objects.
*
* API#addPluginDataSource uses the same method from HookHandler.
*
* @param hookH HookHandler instance for registering the data sources.
* @see API
*/
public FactionsHook(HookHandler hookH) {
super("com.massivecraft.factions.Factions");
if (enabled) {
if (enabled) {
hookH.addPluginDataSource(new FactionsFaction());
hookH.addPluginDataSource(new FactionsPower());
hookH.addPluginDataSource(new FactionsMaxPower());
@ -31,7 +38,9 @@ public class FactionsHook extends Hook {
}
/**
* @return List of Faction names sorted by power
* Used to get the list of Factions and filter out unnessecary ones.
*
* @return List of Factions sorted by power
*/
public List<Faction> getTopFactions() {
List<Faction> topFactions = new ArrayList<>();

View File

@ -3,16 +3,25 @@ package main.java.com.djrapitops.plan.data.additional.factions;
import com.massivecraft.factions.entity.MPlayer;
import java.io.Serializable;
import java.util.UUID;
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.PluginData;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
/**
* PluginData class for Factions-plugin.
*
* Registered to the plugin by FactionsHook
*
* Gives Max Power Integer as value.
*
* @author Rsl1122
* @since 3.1.0
* @see FactionsHook
*/
public class FactionsMaxPower extends PluginData {
/**
* Class Constructor, sets the parameters of the PluginData object.
*/
public FactionsMaxPower() {
super("Factions", "maxpower");
super.setPrefix("Max Power: ");

View File

@ -8,11 +8,21 @@ import main.java.com.djrapitops.plan.data.additional.PluginData;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
/**
* PluginData class for Factions-plugin.
*
* Registered to the plugin by FactionsHook
*
* Gives Power Integer as value.
*
* @author Rsl1122
* @since 3.1.0
* @see FactionsHook
*/
public class FactionsPower extends PluginData {
/**
* Class Constructor, sets the parameters of the PluginData object.
*/
public FactionsPower() {
super("Factions", "power", AnalysisType.DOUBLE_AVG);
super.setAnalysisOnly(false);

View File

@ -12,13 +12,27 @@ import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
/**
* PluginData class for Factions-plugin.
*
* Registered to the plugin by FactionsHook
*
* @author Rsl1122
* @since 3.1.0
* @see FactionsHook
*/
public class FactionsTable extends PluginData {
private List<Faction> factions;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* Uses Html to easily parse Html for the table.
*
* @param factions List of filtered Factions.
* @see FactionsHook
* @see Html
*/
public FactionsTable(List<Faction> factions) {
super("Factions", "factionstable", AnalysisType.HTML);
this.factions = factions;

View File

@ -1,17 +1,25 @@
package main.java.com.djrapitops.plan.data.additional.ontime;
import main.java.com.djrapitops.plan.api.API;
import main.java.com.djrapitops.plan.data.additional.Hook;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
/**
* A Class responsible for hooking to OnTime and registering 6 data sources.
*
* @author Rsl1122
* @since 3.1.0
*/
public class OnTimeHook extends Hook {
/**
* Hooks to OnTime plugin
* Hooks the plugin and registers it's PluginData objects.
*
* API#addPluginDataSource uses the same method from HookHandler.
*
* @param hookH HookHandler instance for registering the data sources.
* @see API
* @throws NoClassDefFoundError when the plugin class can not be found.
*/
public OnTimeHook(HookHandler hookH) throws NoClassDefFoundError {
super("me.edge209.OnTime.OnTime");

View File

@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for Ontime-plugin.
*
* Registered to the plugin by OnTimeHook
*
* Gives Total Referral Integer as value.
*
* @author Rsl1122
* @since 3.1.0
* @see OnTimeHook
*/
public class OntimeRefer extends PluginData {
/**
* Class Constructor, sets the parameters of the PluginData object.
*/
public OntimeRefer() {
super("OnTime", "refer", AnalysisType.INT_TOTAL, AnalysisType.INT_AVG);
super.setAnalysisOnly(false);

View File

@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for Ontime-plugin.
*
* Registered to the plugin by OnTimeHook
*
* Gives Months Referral Integer as value.
*
* @author Rsl1122
* @since 3.1.0
* @see OnTimeHook
*/
public class OntimeReferMonth extends PluginData {
/**
* Class Constructor, sets the parameters of the PluginData object.
*/
public OntimeReferMonth() {
super("OnTime", "refer_30d", AnalysisType.INT_TOTAL);
super.setAnalysisOnly(false);

View File

@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for Ontime-plugin.
*
* Registered to the plugin by OnTimeHook
*
* Gives Week's Referral Integer as value.
*
* @author Rsl1122
* @since 3.1.0
* @see OnTimeHook
*/
public class OntimeReferWeek extends PluginData {
/**
* Class Constructor, sets the parameters of the PluginData object.
*/
public OntimeReferWeek() {
super("OnTime", "refer_7d", AnalysisType.INT_TOTAL);
super.setAnalysisOnly(false);

View File

@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for Ontime-plugin.
*
* Registered to the plugin by OnTimeHook
*
* Gives Total Votes Integer as value.
*
* @author Rsl1122
* @since 3.1.0
* @see OnTimeHook
*/
public class OntimeVotes extends PluginData {
/**
* Class Constructor, sets the parameters of the PluginData object.
*/
public OntimeVotes() {
super("OnTime", "votes", AnalysisType.INT_TOTAL, AnalysisType.INT_AVG);
super.setAnalysisOnly(false);

View File

@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for Ontime-plugin.
*
* Registered to the plugin by OnTimeHook
*
* Gives Month's Votes Integer as value.
*
* @author Rsl1122
* @since 3.1.0
* @see OnTimeHook
*/
public class OntimeVotesMonth extends PluginData {
/**
* Class Constructor, sets the parameters of the PluginData object.
*/
public OntimeVotesMonth() {
super("OnTime", "votes_30d", AnalysisType.INT_TOTAL);
super.setAnalysisOnly(false);

View File

@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for Ontime-plugin.
*
* Registered to the plugin by OnTimeHook
*
* Gives Week's Votes Integer as value.
*
* @author Rsl1122
* @since 3.1.0
* @see OnTimeHook
*/
public class OntimeVotesWeek extends PluginData {
/**
* Class Constructor, sets the parameters of the PluginData object.
*/
public OntimeVotesWeek() {
super("OnTime", "votes_7d", AnalysisType.INT_TOTAL);
super.setAnalysisOnly(false);

View File

@ -4,8 +4,15 @@ import com.palmergames.bukkit.towny.object.Town;
import java.util.Comparator;
/**
* This class is used to compare towns in terms of Amount of residents.
*
* Compare method should only be used if TownyHook.isEnabled() returns true.
*
* Note: this comparator imposes orderings that are inconsistent with equals.
*
* @author Rsl1122
* @since 3.1.0
* @see TownyHook
*/
public class TownComparator implements Comparator<Town> {
@ -16,7 +23,8 @@ public class TownComparator implements Comparator<Town> {
*
* Note: this comparator imposes orderings that are inconsistent with
* equals.
*
* @param tow1 Town 1
* @param tow2 Town 2
*/
@Override
public int compare(Town tow1, Town tow2) {

View File

@ -7,30 +7,40 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.api.API;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
/**
* A Class responsible for hooking to Towny and registering 2 data sources.
*
* @author Rsl1122
* @since 3.1.0
*/
public class TownyHook extends Hook {
/**
* Hooks to Factions plugin
* Hooks the plugin and registers it's PluginData objects.
*
* API#addPluginDataSource uses the same method from HookHandler.
*
* @param hookH HookHandler instance for registering the data sources.
* @see API
* @throws NoClassDefFoundError when the plugin class can not be found.
*/
public TownyHook(HookHandler hookH) throws NoClassDefFoundError {
super("com.palmergames.bukkit.towny.Towny");
if (enabled) {
hookH.addPluginDataSource(new TownyTable(getTopTowns()));
hookH.addPluginDataSource(new TownyTown());
hookH.addPluginDataSource(new TownyTown());
}
}
/**
* @return List of Towns sorted by residents
* Used to get the list of Towns and filter out unnessecary ones.
*
* @return List of Towns sorted by amount of residents.
*/
public List<Town> getTopTowns() {
public List<Town> getTopTowns() {
List<Town> topTowns = TownyUniverse.getDataSource().getTowns();
Collections.sort(topTowns, new TownComparator());
List<String> hide = Settings.HIDE_TOWNS.getStringList();

View File

@ -11,13 +11,27 @@ import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
/**
* PluginData class for Towny-plugin.
*
* Registered to the plugin by TownyHook
*
* @author Rsl1122
* @since 3.1.0
* @see TownyHook
*/
public class TownyTable extends PluginData {
private List<Town> towns;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* Uses Html to easily parse Html for the table.
*
* @param towns List of filtered Towns.
* @see TownyHook
* @see Html
*/
public TownyTable(List<Town> towns) {
super("Towny", "townstable", AnalysisType.HTML);
this.towns = towns;

View File

@ -11,11 +11,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for Towny-plugin.
*
* Registered to the plugin by TownyHook
*
* Gives Town name as String.
*
* @author Rsl1122
* @since 3.1.0
* @see TownyHook
*/
public class TownyTown extends PluginData {
/**
* Class Constructor, sets the parameters of the PluginData object.
*/
public TownyTown() {
super("Towny", "town");
super.setAnalysisOnly(false);

View File

@ -10,27 +10,39 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.OfflinePlayer;
/**
* PluginData class for Vault-plugin.
*
* Registered to the plugin by VaultHook
*
* Gives Total Balance Double as value.
*
* @author Rsl1122
* @since 3.1.0
* @see VaultHook
*/
public class EconomyBalance extends PluginData {
private Economy econ;
/**
* Class Constructor, sets the parameters of the PluginData object.
*
* @param econ Economy given by Vault.
*/
public EconomyBalance(Economy econ) {
super("Vault", "balance", AnalysisType.DOUBLE_TOTAL, AnalysisType.DOUBLE_AVG);
this.econ = econ;
super.setAnalysisOnly(false);
super.setIcon("money");
super.setPrefix("Balance: ");
super.setSuffix(" "+FormatUtils.removeNumbers(econ.format(0)));
super.setSuffix(" " + FormatUtils.removeNumbers(econ.format(0)));
}
@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
OfflinePlayer p = getOfflinePlayer(uuid);
if (p.hasPlayedBefore()) {
parseContainer(modifierPrefix, this.econ.getBalance(p)+"");
parseContainer(modifierPrefix, this.econ.getBalance(p) + "");
}
return "";
}

View File

@ -1,39 +1,47 @@
package main.java.com.djrapitops.plan.data.additional.vault;
import main.java.com.djrapitops.plan.api.API;
import main.java.com.djrapitops.plan.data.additional.Hook;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
import net.milkbowl.vault.economy.Economy;
import static org.bukkit.Bukkit.getServer;
/**
* A Class responsible for hooking to Vault and registering 1 data source.
*
* @author Rsl1122
* @since 3.1.0
*/
public class VaultHook extends Hook {
private Economy econ;
/**
* Hooks to Vault plugin
* Hooks the plugin and registers it's PluginData objects.
*
* API#addPluginDataSource uses the same method from HookHandler.
*
* @param hookH HookHandler instance for registering the data sources.
* @see API
* @throws NoClassDefFoundError when the plugin class can not be found.
*/
public VaultHook(HookHandler hookH) throws NoClassDefFoundError {
super("net.milkbowl.vault.Vault");
if (!enabled) {
return;
}
try {
this.econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
enabled = true;
} catch (Throwable e) {
enabled = false;
}
if (!enabled) {
return;
}
hookH.addPluginDataSource(new EconomyBalance(econ));
}
}

View File

@ -5,8 +5,11 @@ import main.java.com.djrapitops.plan.data.AnalysisData;
import main.java.com.djrapitops.plan.utilities.Analysis;
/**
* This class is used to store the most recent AnalysisData object and to run
* Analysis.
*
* @author Rsl1122
* @since 2.0.0
*/
public class AnalysisCacheHandler {
@ -53,6 +56,8 @@ public class AnalysisCacheHandler {
}
/**
* Check if the AnalysisData has been cached.
*
* @return true if there is data in the cache.
*/
public boolean isCached() {

View File

@ -1,17 +1,25 @@
package main.java.com.djrapitops.plan.data.cache;
import main.java.com.djrapitops.plan.data.UserData;
/**
* This abstract class can be extended with anything as the process method and
* given to the Database.
*
* The process method will be called with the UserData object fetched from the
* database.
*
* @author Rsl1122
* @since 2.6.0
*/
public abstract class DBCallableProcessor {
/**
* Method used to do multiple things to UserData objects such as Caching,
* changing properties etc.
*
* @param data
* @param data UserData object given to the DBCallableProcessor by the
* method it was given as parameter to.
*/
public abstract void process(UserData data);
}

View File

@ -7,6 +7,7 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase;
@ -31,8 +32,18 @@ import org.bukkit.scheduler.BukkitTask;
import static org.bukkit.Bukkit.getOfflinePlayer;
/**
* This Class contains the Cache.
*
* This class is the main processing class that initializes Save, Clear, Process
* and Get queue and Starts the asyncronous save task.
*
* It is used to store commanduse, locations, active sessions and UserData objects
* in memory.
*
* It's methods can be used to access all the data it stores and to clear them.
*
* @author Rsl1122
* @since 2.0.0
*/
public class DataCacheHandler extends LocationCache {
@ -57,8 +68,8 @@ public class DataCacheHandler extends LocationCache {
/**
* Class Constructor.
*
* Creates the set of Handlers that will be used to modify UserData. Gets
* the Database from the plugin. Registers Asyncronous Periodic Save Task
* Gets the Database from the plugin. Starts the queues. Registers
* Asyncronous Periodic Save Task
*
* @param plugin Current instance of Plan
*/
@ -83,33 +94,36 @@ public class DataCacheHandler extends LocationCache {
}
/**
* Used to get the initial commandUse Map from the database.
*
* @return
* @return Was the fetch successful?
*/
public boolean getCommandUseFromDb() {
try {
commandUse = db.getCommandUse();
return true;
} catch (SQLException e) {
} catch (Exception e) {
Log.toLog(this.getClass().getName(), e);
}
return false;
}
/**
*
* Used to start all processing Queue Threads.
*/
public void startQueues() {
clearTask = new DataCacheClearQueue(plugin, this);
clearTask = new DataCacheClearQueue(this);
saveTask = new DataCacheSaveQueue(plugin, clearTask);
getTask = new DataCacheGetQueue(plugin);
processTask = new DataCacheProcessQueue(this);
}
/**
* Used to start the Asyncronous Save Task.
*
* @throws IllegalArgumentException
* @throws IllegalStateException
* @throws IllegalArgumentException BukkitRunnable was given wrong
* parameters.
* @throws IllegalStateException BukkitScheduler is in a wrong state.
*/
public void startAsyncPeriodicSaveTask() throws IllegalArgumentException, IllegalStateException {
int minutes = Settings.SAVE_CACHE_MIN.getNumber();
@ -123,7 +137,7 @@ public class DataCacheHandler extends LocationCache {
} else {
clearAfterXsaves = configValue;
}
BukkitTask asyncPeriodicCacheSaveTask = (new BukkitRunnable() {
BukkitTask asyncPeriodicCacheSaveTask = new BukkitRunnable() {
@Override
public void run() {
DataCacheHandler handler = Plan.getInstance().getHandler();
@ -135,22 +149,22 @@ public class DataCacheHandler extends LocationCache {
saveCommandUse();
timesSaved++;
}
}).runTaskTimerAsynchronously(plugin, 60 * 20 * minutes, 60 * 20 * minutes);
}.runTaskTimerAsynchronously(plugin, 60 * 20 * minutes, 60 * 20 * minutes);
}
/**
* Uses Database to retrieve the UserData of a matching player
* Uses Database or Cache to retrieve the UserData of a matching player.
*
* Caches the data to the HashMap if cache: true
* Caches the data to the Cache if cache-parameter is true.
*
* @param processor DBCallableProcessor Object used to process the data
* after it was retrieved
* @param uuid Player's UUID
* @param cache Wether or not the UserData will be Cached in this instance
* of DataCacheHandler
* @param cache Whether or not the UserData will be Cached in this instance
* of DataCacheHandler after it has been fetched (if not already fetched)
*/
public void getUserDataForProcessing(DBCallableProcessor processor, UUID uuid, boolean cache) {
Log.debug(uuid+": HANDLER getForProcess,"+" Cache:"+cache);
Log.debug(uuid + ": HANDLER getForProcess," + " Cache:" + cache);
UserData uData = dataCache.get(uuid);
if (uData == null) {
if (cache) {
@ -169,14 +183,22 @@ public class DataCacheHandler extends LocationCache {
}
}
/**
* Used to Cache a UserData object to the Cache.
*
* If a object already exists it will be replaced.
*
* @param data UserData object with the UUID inside used as key.
*/
public void cache(UserData data) {
dataCache.put(data.getUuid(), data);
Log.info(Phrase.CACHE_ADD.parse(data.getUuid().toString()));
}
/**
** Uses Database to retrieve the UserData of a matching player Caches the
* data to the HashMap
* Uses Database or Cache to retrieve the UserData of a matching player.
*
* Always Caches the data after retrieval (unless already cached)
*
* @param processor DBCallableProcessor Object used to process the data
* after it was retrieved
@ -187,8 +209,11 @@ public class DataCacheHandler extends LocationCache {
}
/**
* Saves all data in the cache to Database. Should only be called from Async
* thread
* Saves all UserData in the cache to Database.
*
* ATTENTION: TODO - Doesn't save the Locations in the locationCache.
*
* Should only be called from Async thread
*/
public void saveCachedUserData() {
List<UserData> data = new ArrayList<>();
@ -201,17 +226,23 @@ public class DataCacheHandler extends LocationCache {
}
/**
* Used to add event HandlingInfo to the processTask's pool.
*
* @param i
* Given HandlingInfo object's process method will be called.
*
* @param i Object that extends HandlingInfo.
*/
public void addToPool(HandlingInfo i) {
Log.debug(i.getUuid()+ ": Adding to pool, type:" + i.getType().name());
Log.debug(i.getUuid() + ": Adding to pool, type:" + i.getType().name());
processTask.addToPool(i);
}
/**
* Saves all data in the cache to Database and closes the database down.
* Closes save clear and get tasks.
*
* Stops all tasks.
*
* If processTask has unprocessed information, it will be processed.
*/
public void saveCacheOnDisable() {
long time = new Date().getTime();
@ -226,22 +257,16 @@ public class DataCacheHandler extends LocationCache {
for (Player p : onlinePlayers) {
UUID uuid = p.getUniqueId();
endSession(uuid);
if (dataCache.containsKey(uuid)) {
dataCache.get(uuid).addLocations(getLocationsForSaving(uuid));
}
toProcess.add(new LogoutInfo(uuid, time, p.isBanned(), p.getGameMode(), getSession(uuid)));
}
Log.debug("ToProcess size_AFTER: " + toProcess.size() + " DataCache size: " + dataCache.keySet().size());
Collections.sort(toProcess, new HandlingInfoTimeComparator());
processUnprocessedHandlingInfo(toProcess);
// for (UUID uuid : dataCache.keySet()) {
// UserData uData = dataCache.get(uuid);
// endSession(uuid);
// new LogoutInfo(uuid, time, uData.isBanned(), uData.getLastGamemode(), getSession(uuid)).process(uData);
// }
List<UserData> data = new ArrayList<>();
data.addAll(dataCache.values());
// data.parallelStream()
// .forEach((userData) -> {
// addSession(userData);
// });
Log.debug("SAVING, DataCache size: " + dataCache.keySet().size());
try {
db.saveMultipleUserData(data);
@ -272,31 +297,29 @@ public class DataCacheHandler extends LocationCache {
}
/**
* Saves the cached data of matching Player if it is in the cache
* Saves the cached data of matching Player if it is in the cache.
*
* @param uuid Player's UUID
*/
public void saveCachedData(UUID uuid) {
Log.debug(uuid+": SaveCachedData");
Log.debug(uuid + ": SaveCachedData");
DBCallableProcessor saveProcessor = new DBCallableProcessor() {
@Override
public void process(UserData data) {
data.addLocations(getLocationsForSaving(uuid));
clearLocations(uuid);
// addSession(data);
data.access();
data.setClearAfterSave(true);
saveTask.scheduleForSave(data);
// scheludeForClear(uuid);
}
};
getUserDataForProcessing(saveProcessor, uuid);
// getTask.scheduleForGet(uuid, saveProcessor);
}
/**
* Scheludes the cached CommandUsage to be saved.
* Saves the cached CommandUse.
*
* Should be only called from an Asyncronous Thread.
*/
public void saveCommandUse() {
try {
@ -307,7 +330,7 @@ public class DataCacheHandler extends LocationCache {
}
/**
*
* Refreshes the calculations for all online players with ReloadInfo.
*/
public void saveHandlerDataToCache() {
Bukkit.getServer().getOnlinePlayers().parallelStream().forEach((p) -> {
@ -322,21 +345,21 @@ public class DataCacheHandler extends LocationCache {
}
/**
* Clears all UserData from the HashMap
* Schedules all UserData from the Cache to be cleared.
*/
public void clearCache() {
clearTask.scheduleForClear(dataCache.keySet());
}
/**
* Clears the matching UserData from the HashMap
* Clears the matching UserData from the Cache if they're not online.
*
* @param uuid Player's UUID
*/
public void clearFromCache(UUID uuid) {
Log.debug(uuid+": Clear");
Log.debug(uuid + ": Clear");
if (getOfflinePlayer(uuid).isOnline()) {
Log.debug(uuid+": Online, did not clear");
Log.debug(uuid + ": Online, did not clear");
UserData data = dataCache.get(uuid);
if (data != null) {
data.setClearAfterSave(false);
@ -348,24 +371,26 @@ public class DataCacheHandler extends LocationCache {
}
/**
* Schedules a matching UserData object to be cleared from the cache.
*
* @param uuid
* @param uuid Player's UUID.
*/
public void scheludeForClear(UUID uuid) {
clearTask.scheduleForClear(uuid);
}
/**
* Check whether or not the UserData object is being accessed by save or
* process tasks.
*
* @param uuid
* @return
* @param uuid Player's UUID
* @return true/false
*/
public boolean isDataAccessed(UUID uuid) {
UserData userData = dataCache.get(uuid);
if (userData == null) {
return false;
}
// Log.debug("Is data accessed?:" + userData.isAccessed() + " " + saveTask.containsUUID(uuid) + " " + processTask.containsUUID(uuid));
boolean isAccessed = (userData.isAccessed()) || saveTask.containsUUID(uuid) || processTask.containsUUID(uuid);
if (isAccessed) {
userData.setClearAfterSave(false);
@ -374,7 +399,7 @@ public class DataCacheHandler extends LocationCache {
}
/**
* Creates a new UserData instance and saves it to the Database
* Creates a new UserData instance and saves it to the Database.
*
* @param player Player the new UserData is created for
*/
@ -383,16 +408,18 @@ public class DataCacheHandler extends LocationCache {
}
/**
* Creates a new UserData instance and saves it to the Database.
*
* @param player
* @param player Player the new UserData is created for
*/
public void newPlayer(OfflinePlayer player) {
newPlayer(NewPlayerCreator.createNewPlayer(player));
}
/**
* Schedules a new player's data to be saved to the Database.
*
* @param data
* @param data UserData object to schedule for save.
*/
public void newPlayer(UserData data) {
saveTask.scheduleNewPlayer(data);
@ -400,6 +427,8 @@ public class DataCacheHandler extends LocationCache {
}
/**
* Used to get the contents of the cache.
*
* @return The HashMap containing all Cached UserData
*/
public HashMap<UUID, UserData> getDataCache() {
@ -407,28 +436,14 @@ public class DataCacheHandler extends LocationCache {
}
/**
* @return Current instance of the LocationHandler
*/
public LocationCache getLocationHandler() {
return this;
}
/**
* Used to get the cached commandUse.
*
* @return
* @return Map with key:value - "/command":4
*/
public HashMap<String, Integer> getCommandUse() {
public Map<String, Integer> getCommandUse() {
return commandUse;
}
/**
*
* @return
*/
public SessionCache getSessionCache() {
return this;
}
/**
* If /reload is run this treats every online player as a new login.
*
@ -462,8 +477,9 @@ public class DataCacheHandler extends LocationCache {
}
/**
* Used to handle a command's execution.
*
* @param command
* @param command "/command"
*/
public void handleCommand(String command) {
if (!commandUse.containsKey(command)) {

View File

@ -6,8 +6,10 @@ import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.UserData;
/**
* This class stores UserData objects used for displaying the Html pages.
*
* @author Rsl1122
* @since 2.0.0
*/
public class InspectCacheHandler {
@ -16,7 +18,7 @@ public class InspectCacheHandler {
private HashMap<UUID, UserData> cache;
/**
* Class constructor
* Class constructor.
*
* @param plugin Current instance of Plan.class
*/
@ -25,10 +27,14 @@ public class InspectCacheHandler {
this.plugin = plugin;
this.cache = new HashMap<>();
}
/**
* Caches the UserData object to InspectCache.
*
* @param uuid
* If the Userdata is cached in DataCache it will be used. Otherwise the Get
* Queue will handle the DBCallableProcessor.
*
* @param uuid UUID of the player.
*/
public void cache(UUID uuid) {
DBCallableProcessor cacher = new DBCallableProcessor() {
@ -41,7 +47,7 @@ public class InspectCacheHandler {
}
/**
* Checks the cache for UserData matching UUID
* Checks the cache for UserData matching UUID.
*
* @param uuid UUID of the Player
* @return UserData that matches the player, null if not cached.

View File

@ -8,16 +8,19 @@ import java.util.UUID;
import org.bukkit.Location;
/**
* This class is used to save locations players walk at.
*
* Extends SessionCache so that DataCacheHandler can have all 3 classes methods.
*
* @author Rsl1122
* @since 3.0.0
*/
public class LocationCache extends SessionCache{
public class LocationCache extends SessionCache {
private HashMap<UUID, List<Location>> locations;
/**
* Class Constructor.
*
*/
public LocationCache() {
super();
@ -25,9 +28,10 @@ public class LocationCache extends SessionCache{
}
/**
* Add a location for a player to the list.
*
* @param uuid
* @param loc
* @param uuid UUID of the player.
* @param loc Location the player moved to.
*/
public void addLocation(UUID uuid, Location loc) {
if (!locations.containsKey(uuid)) {
@ -37,9 +41,10 @@ public class LocationCache extends SessionCache{
}
/**
* Add multiple locations to the list.
*
* @param uuid
* @param locs
* @param uuid UUID of the player.
* @param locs Locations the player moved to.
*/
public void addLocations(UUID uuid, Collection<Location> locs) {
if (!locations.containsKey(uuid)) {
@ -47,11 +52,13 @@ public class LocationCache extends SessionCache{
}
locations.get(uuid).addAll(locs);
}
/**
* Get the list of locations in the cache for saving the UserData object to
* Database.
*
* @param uuid
* @return
* @param uuid UUID of the player.
* @return List of locations the player has been at.
*/
public List<Location> getLocationsForSaving(UUID uuid) {
if (!locations.containsKey(uuid)) {
@ -59,10 +66,11 @@ public class LocationCache extends SessionCache{
}
return locations.get(uuid);
}
/**
* Used to clear the locations from the locationcache.
*
* @param uuid
* @param uuid UUID of the player.
*/
public void clearLocations(UUID uuid) {
locations.remove(uuid);

View File

@ -1,68 +1,75 @@
package main.java.com.djrapitops.plan.data.cache;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.data.UserData;
/**
* This class is used to store active sessions of players in memory.
*
* @author Rsl1122
* @since 3.0.0
*/
public class SessionCache {
private final HashMap<UUID, SessionData> activeSessions;
/**
*
* Class Constructor.
*/
public SessionCache() {
this.activeSessions = new HashMap<>();
this.activeSessions = new HashMap<>();
}
/**
* Starts a session for a player at the current moment.
*
* @param uuid
* @param uuid UUID of the player.
*/
public void startSession(UUID uuid) {
long now = new Date().getTime();
Log.debug(uuid+": Starting a session: "+now);
Log.debug(uuid + ": Starting a session: " + now);
SessionData session = new SessionData(now);
activeSessions.put(uuid, session);
}
/**
* Ends a session for a player at the current moment.
*
* @param uuid
* @param uuid UUID of the player.
*/
public void endSession(UUID uuid) {
SessionData currentSession = activeSessions.get(uuid);
if (currentSession != null) {
long now = new Date().getTime();
Log.debug(uuid+": Ending a session: "+now);
Log.debug(uuid + ": Ending a session: " + now);
currentSession.endSession(now);
}
}
/**
* Used to get the SessionData of the player in the sessionCache.
*
* @param uuid
* @return
* @param uuid UUId of the player.
* @return SessionData or null if not cached.
*/
public SessionData getSession(UUID uuid) {
return activeSessions.get(uuid);
}
/**
* Add a session to the UserData object if it is cached and has been ended.
*
* @param data
* @param data UserData object a session should be added to.
*/
public void addSession(UserData data) {
UUID uuid = data.getUuid();
SessionData currentSession = activeSessions.get(uuid);
Log.debug("Adding a session: "+uuid+" "+currentSession);
Log.debug("Adding a session: " + uuid + " " + currentSession);
if (currentSession != null && currentSession.isValid() && !data.getSessions().contains(currentSession)) {
data.addSession(currentSession);
activeSessions.remove(uuid);
@ -70,10 +77,13 @@ public class SessionCache {
}
/**
* Used to get the Map of active sessions.
*
* @return
* Used for testing.
*
* @return key:value UUID:SessionData
*/
public HashMap<UUID, SessionData> getActiveSessions() {
public Map<UUID, SessionData> getActiveSessions() {
return activeSessions;
}
}

View File

@ -6,13 +6,14 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
/**
* This Class strats the Clear Queue Thread, that clears data from DataCache.
*
* @author Rsl1122
* @since 3.0.0
*/
public class DataCacheClearQueue {
@ -20,28 +21,30 @@ public class DataCacheClearQueue {
private ClearSetup s;
/**
* Class constructor, starts the new Thread for clearing.
*
* @param plugin
* @param handler
* @param handler current instance of DataCachehandler.
*/
public DataCacheClearQueue(Plan plugin, DataCacheHandler handler) {
public DataCacheClearQueue(DataCacheHandler handler) {
q = new ArrayBlockingQueue(Settings.PROCESS_CLEAR_LIMIT.getNumber());
s = new ClearSetup();
s.go(q, handler);
}
/**
* Used to schedule UserData to be cleared from the cache.
*
* @param uuid
* @param uuid UUID of the UserData object (Player's UUID)
*/
public void scheduleForClear(UUID uuid) {
Log.debug(uuid+": Scheduling for clear");
Log.debug(uuid + ": Scheduling for clear");
q.add(uuid);
}
/**
* Used to schedule multiple UserData objects to be cleared from the cache.
*
* @param uuids
* @param uuids UUIDs of the UserData object (Players' UUIDs)
*/
public void scheduleForClear(Collection<UUID> uuids) {
if (uuids.isEmpty()) {
@ -56,7 +59,7 @@ public class DataCacheClearQueue {
}
/**
*
* Stops all activity and clears the queue.
*/
public void stop() {
if (s != null) {

View File

@ -16,8 +16,10 @@ import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
import main.java.com.djrapitops.plan.database.Database;
/**
* This Class is starts the Get Queue Thread, that fetches data from DataCache.
*
* @author Rsl1122
* @since 3.0.0
*/
public class DataCacheGetQueue {
@ -25,8 +27,9 @@ public class DataCacheGetQueue {
private GetSetup s;
/**
* Class constructor, starts the new Thread for fetching.
*
* @param plugin
* @param plugin current instance of Plan
*/
public DataCacheGetQueue(Plan plugin) {
q = new ArrayBlockingQueue(Settings.PROCESS_GET_LIMIT.getNumber());
@ -35,9 +38,11 @@ public class DataCacheGetQueue {
}
/**
* Schedules UserData objects to be get for the given proecssors.
*
* @param uuid
* @param processors
* @param uuid UUID of the player whose UserData object is fetched.
* @param processors Processors which process-method will be called after
* fetch is complete, with the UserData object.
*/
public void scheduleForGet(UUID uuid, DBCallableProcessor... processors) {
Log.debug(uuid + ": Scheduling for get");
@ -54,7 +59,7 @@ public class DataCacheGetQueue {
}
/**
*
* Stops the activities and clears the queue.
*/
public void stop() {
if (s != null) {
@ -98,7 +103,7 @@ class GetConsumer implements Runnable {
}
List<DBCallableProcessor> processorsList = processors.get(uuid);
if (processorsList != null) {
Log.debug(uuid+ ": Get, For:" + processorsList.size());
Log.debug(uuid + ": Get, For:" + processorsList.size());
try {
db.giveUserDataToProcessors(uuid, processorsList);
} catch (SQLException e) {

View File

@ -14,8 +14,11 @@ import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
/**
* This Class is starts the Process Queue Thread, that processes HandlingInfo
* objects.
*
* @author Rsl1122
* @since 3.0.0
*/
public class DataCacheProcessQueue {
@ -23,8 +26,9 @@ public class DataCacheProcessQueue {
private ProcessSetup setup;
/**
* Class constructor, starts the new Thread for processing.
*
* @param handler
* @param handler current instance of DataCachehandler.
*/
public DataCacheProcessQueue(DataCacheHandler handler) {
queue = new ArrayBlockingQueue(20000);
@ -33,8 +37,9 @@ public class DataCacheProcessQueue {
}
/**
* Used to add HandlingInfo object to be processed.
*
* @param info
* @param info object that extends HandlingInfo.
*/
public void addToPool(HandlingInfo info) {
try {
@ -45,29 +50,33 @@ public class DataCacheProcessQueue {
}
/**
* Used to add multiple HandlingInfo objects to be processed.
*
* @param info
* @param info Collection of objects that extends HandlingInfo.
*/
public void addToPool(Collection<HandlingInfo> info) {
try {
queue.addAll(info);
} catch (IllegalStateException e) {
Log.toLog(this.getClass().getName(), e);
Log.toLog(this.getClass().getName(), e);
}
}
/**
* Check whether or not the queue contains a HandlingInfo object with the
* uuid.
*
* @param uuid
* @return
* @param uuid UUID of the player.
* @return true/false
*/
public boolean containsUUID(UUID uuid) {
return new ArrayList<>(queue).stream().map(d -> d.getUuid()).collect(Collectors.toList()).contains(uuid);
}
/**
* Stops all activites and clears the queue.
*
* @return
* @return unprocessed HandlingInfo objects.
*/
public List<HandlingInfo> stop() {
try {
@ -109,7 +118,7 @@ class ProcessConsumer implements Runnable {
if (handler == null) {
return;
}
Log.debug(info.getUuid()+": Processing type: " + info.getType().name());
Log.debug(info.getUuid() + ": Processing type: " + info.getType().name());
DBCallableProcessor p = new DBCallableProcessor() {
@Override
public void process(UserData data) {

View File

@ -15,8 +15,10 @@ import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.database.Database;
/**
* This Class is starts the Save Queue Thread, that saves data to the Databse.
*
* @author Rsl1122
* @since 3.0.0
*/
public class DataCacheSaveQueue {
@ -24,9 +26,11 @@ public class DataCacheSaveQueue {
private SaveSetup s;
/**
* Class constructor, starts the new Thread for saving.
*
* @param plugin
* @param clear
* @param plugin current instance of Plan
* @param clear current instance of the Clear task to schedule clear if
* UserData.clearAfterSave() is true
*/
public DataCacheSaveQueue(Plan plugin, DataCacheClearQueue clear) {
q = new ArrayBlockingQueue(Settings.PROCESS_SAVE_LIMIT.getNumber());
@ -35,11 +39,12 @@ public class DataCacheSaveQueue {
}
/**
* Schedule UserData object to be saved to the database.
*
* @param data
* @param data UserData object.
*/
public void scheduleForSave(UserData data) {
Log.debug(data.getUuid()+": Scheduling for save");
Log.debug(data.getUuid() + ": Scheduling for save");
try {
q.add(data);
} catch (IllegalStateException e) {
@ -48,11 +53,12 @@ public class DataCacheSaveQueue {
}
/**
* Schedule multiple UserData objects to be saved to the database.
*
* @param data
* @param data Collection of UserData objects.
*/
public void scheduleForSave(Collection<UserData> data) {
Log.debug("Scheduling for save: "+data.stream().map(u -> u.getUuid()).collect(Collectors.toList()));
Log.debug("Scheduling for save: " + data.stream().map(u -> u.getUuid()).collect(Collectors.toList()));
try {
q.addAll(data);
} catch (IllegalStateException e) {
@ -61,11 +67,12 @@ public class DataCacheSaveQueue {
}
/**
* Schedule UserData object for a new player to be saved to the database.
*
* @param data
* @param data UserData object.
*/
public void scheduleNewPlayer(UserData data) {
Log.debug(data.getUuid()+": Scheduling new Player");
Log.debug(data.getUuid() + ": Scheduling new Player");
try {
q.add(data);
} catch (IllegalStateException e) {
@ -74,16 +81,17 @@ public class DataCacheSaveQueue {
}
/**
* Check whether or not the queue contains a UserData object with the uuid.
*
* @param uuid
* @return
* @param uuid UUID of the player.
* @return true/false
*/
public boolean containsUUID(UUID uuid) {
return new ArrayList<>(q).stream().map(d -> d.getUuid()).collect(Collectors.toList()).contains(uuid);
}
/**
*
* Stops all activites and clears the queue.
*/
public void stop() {
if (s != null) {
@ -123,11 +131,11 @@ class SaveConsumer implements Runnable {
return;
}
UUID uuid = data.getUuid();
Log.debug(uuid+": Saving: "+uuid);
Log.debug(uuid + ": Saving: " + uuid);
try {
db.saveUserData(uuid, data);
data.stopAccessing();
Log.debug(uuid+": Saved!");
Log.debug(uuid + ": Saved!");
if (data.shouldClearAfterSave()) {
if (clear != null) {
clear.scheduleForClear(uuid);

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling;
import java.util.Arrays;
@ -12,16 +7,21 @@ import main.java.com.djrapitops.plan.api.Gender;
import main.java.com.djrapitops.plan.data.UserData;
/**
* Class containing static methods for processing information contained in a
* ChatEvent.
*
* @author Rsl1122
* @since 3.0.0
*/
public class ChatHandling {
/**
* Processes the information of the Event and changes UserData object
* accordingly.
*
* @param data
* @param nickname
* @param msg
* @param data UserData of the player.
* @param nickname Nickname of the player during the event.
* @param msg Message sent by the player.
*/
public static void processChatInfo(UserData data, String nickname, String msg) {
data.addNickname(nickname);
@ -29,9 +29,10 @@ public class ChatHandling {
}
/**
* Updates Demographics information according to various rules.
*
* @param msg
* @param data
* @param msg Message sent by the player.
* @param data UserData of the player.
*/
public static void updateDemographicInformation(String msg, UserData data) {
List<String> triggers = Arrays.asList(Settings.DEM_TRIGGERS.toString().split(", "));

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling;
import java.util.Map;
@ -10,22 +5,27 @@ import main.java.com.djrapitops.plan.data.UserData;
import org.bukkit.GameMode;
/**
* Class containing static methods for processing information contained in a
* GamemodeChangeEvent.
*
* @author Rsl1122
* @since 3.0.0
*/
public class GamemodeHandling {
/**
* Processes the information of the Event and changes UserData object
* accordingly.
*
* @param data
* @param time
* @param newGM
* @param data UserData of the player.
* @param time Epoch ms the event occurred.
* @param newGM The Gamemode the player changed to.
*/
public static void processGamemodeInfo(UserData data, long time, GameMode newGM) {
if (newGM == null) {
return;
}
GameMode lastGamemode = data.getLastGamemode();
if (lastGamemode == null) {
data.setLastGamemode(newGM);

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling;
import java.sql.SQLException;
@ -15,17 +10,22 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
/**
* Class containing static methods for processing information contained in a
* DeathEvent when the killer is a player.
*
* @author Rsl1122
* @since 3.0.0
*/
public class KillHandling {
/**
* Processes the information of the Event and changes UserData object
* accordingly.
*
* @param data
* @param time
* @param dead
* @param weaponName
* @param data UserData of the player.
* @param time Epoch ms the event occurred.
* @param dead Mob or a Player the player killed.
* @param weaponName The name of the Weapon used.
*/
public static void processKillInfo(UserData data, long time, LivingEntity dead, String weaponName) {
Plan plugin = Plan.getInstance();
@ -40,7 +40,7 @@ public class KillHandling {
}
data.addPlayerKill(new KillData(victimUUID, victimID, weaponName, time));
} catch (SQLException e) {
Log.toLog("main.java.com.djrapitops.plan.KillHandling", e);
Log.toLog("main.java.com.djrapitops.plan.KillHandling", e);
}
} else {
data.setMobKills(data.getMobKills() + 1);

View File

@ -9,19 +9,24 @@ import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData;
/**
* Class containing static methods for processing information contained in a
* JoinEvent.
*
* @author Rsl1122
* @since 3.0.0
*/
public class LoginHandling {
/**
* Processes the information of the Event and changes UserData object
* accordingly.
*
* @param data
* @param time
* @param ip
* @param banned
* @param nickname
* @param loginTimes
* @param data UserData of the player.
* @param time Epoch ms the event occurred.
* @param ip IP of the player
* @param banned Is the player banned
* @param nickname Nickname of the player
* @param loginTimes amount the loginTimes should be incremented with.
*/
public static void processLoginInfo(UserData data, long time, InetAddress ip, boolean banned, String nickname, int loginTimes) {
data.setLastPlayed(time);
@ -33,9 +38,12 @@ public class LoginHandling {
}
/**
* Updates the geolocation of the player.
*
* @param ip
* @param data
* Uses free service of freegeoip.net. 10000 requests can be sent per hour.
*
* @param ip InetAddress used for location.
* @param data UserData of the player.
*/
public static void updateGeolocation(InetAddress ip, UserData data) {
DemographicsData demData = data.getDemData();

View File

@ -1,27 +1,27 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling;
import main.java.com.djrapitops.plan.data.UserData;
/**
* Class containing static methods for processing information contained in a
* QuitEvent.
*
* @author Rsl1122
* @since 3.0.0
*/
public class LogoutHandling {
/**
* Processes the information of the Event and changes UserData object
* accordingly.
*
* @param data
* @param time
* @param banned
* @param data UserData of the player.
* @param time Epoch ms the event occurred.
* @param banned Is the player banned?
*/
public static void processLogoutInfo(UserData data, long time, boolean banned) {
data.setPlayTime(data.getPlayTime() + (time - data.getLastPlayed()));
data.setLastPlayed(time);
data.setLastPlayed(time);
data.updateBanned(banned);
}
}

View File

@ -5,18 +5,22 @@ import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.ChatHandling;
/**
* HandlingInfo Class for ChatEvent information.
*
* @author Rsl1122
* @since 3.0.0
*/
public class ChatInfo extends HandlingInfo {
private String nickname;
private String message;
/**
* Constructor.
*
* @param uuid
* @param nickname
* @param message
* @param uuid UUID of the player.
* @param nickname Nickname of the player.
* @param message Message the player sent.
*/
public ChatInfo(UUID uuid, String nickname, String message) {
super(uuid, InfoType.CHAT, 0L);
@ -24,27 +28,6 @@ public class ChatInfo extends HandlingInfo {
this.message = message;
}
/**
*
* @return
*/
public String getNickname() {
return nickname;
}
/**
*
* @return
*/
public String getMessage() {
return message;
}
/**
*
* @param uData
* @return
*/
@Override
public boolean process(UserData uData) {
if (!uData.getUuid().equals(uuid)) {

View File

@ -1,38 +1,31 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling.info;
import java.util.UUID;
import main.java.com.djrapitops.plan.data.UserData;
/**
* HandlingInfo Class for DeathEvent information.
*
* @author Rsl1122
* @since 3.0.0
*/
public class DeathInfo extends HandlingInfo{
public class DeathInfo extends HandlingInfo {
/**
* Constructor.
*
* @param uuid
* @param uuid UUID of the dead player.
*/
public DeathInfo(UUID uuid) {
super(uuid, InfoType.DEATH, 0L);
}
/**
*
* @param uData
* @return
*/
@Override
public boolean process(UserData uData) {
if (!uData.getUuid().equals(uuid)) {
return false;
}
uData.setDeaths(uData.getDeaths()+1);
uData.setDeaths(uData.getDeaths() + 1);
return true;
}
}

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling.info;
import java.util.UUID;
@ -11,28 +6,27 @@ import main.java.com.djrapitops.plan.data.handling.GamemodeHandling;
import org.bukkit.GameMode;
/**
* HandlingInfo Class for GamemodeChangeEvent information.
*
* @author Rsl1122
* @since 3.0.0
*/
public class GamemodeInfo extends HandlingInfo{
public class GamemodeInfo extends HandlingInfo {
private GameMode currentGamemode;
/**
* Constructor.
*
* @param uuid
* @param time
* @param gm
* @param uuid UUID of the player.
* @param time Epoch ms of the event.
* @param gm Gamemode the player changed to.
*/
public GamemodeInfo(UUID uuid, long time, GameMode gm) {
super(uuid, InfoType.GM, time);
currentGamemode = gm;
}
/**
*
* @param uData
* @return
*/
@Override
public boolean process(UserData uData) {
if (currentGamemode == null) {

View File

@ -4,8 +4,11 @@ import java.util.UUID;
import main.java.com.djrapitops.plan.data.UserData;
/**
* An abstract class for processing information about events and modifying
* UserData objects associated with the events.
*
* @author Rsl1122
* @since 3.0.0
*/
public abstract class HandlingInfo {
@ -14,10 +17,12 @@ public abstract class HandlingInfo {
long time;
/**
* Super Constructor.
*
* @param uuid
* @param type
* @param time
* @param uuid UUID of the player
* @param type InfoType enum of the event. Only used for debugging different
* types.
* @param time Epoch ms of the event.
*/
public HandlingInfo(UUID uuid, InfoType type, long time) {
this.uuid = uuid;
@ -26,33 +31,39 @@ public abstract class HandlingInfo {
}
/**
* Get the UUID.
*
* @return
* @return UUID of the player associated with the event.
*/
public UUID getUuid() {
return uuid;
}
/**
* Get the InfoType.
*
* @return
* @return InfoType enum.
*/
public InfoType getType() {
return type;
}
/**
* Get the epoch ms the event occurred.
*
* @return
* @return long in ms.
*/
public long getTime() {
return time;
}
/**
* Process the info and modify the UserData object accordingly.
*
* @param uData
* @return
* If the UUIDs don't match no change should occur.
*
* @param uData UserData object to modify.
* @return UUID of the UserData object and HandlingInfo match.
*/
public abstract boolean process(UserData uData);
}

View File

@ -1,53 +1,29 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling.info;
/**
* Enum class for the types of HandlingInfo to be processed.
*
* Type is only used for debugging.
*
* OTHER should be used when
*
* @author Rsl1122
* @since 3.0.0
*/
public enum InfoType {
CHAT,
DEATH,
KILL,
GM,
LOGIN,
LOGOUT,
KICK,
RELOAD,
/**
* Used for events registered with the API.
*
* @since 3.1.1
*/
CHAT,
/**
*
*/
DEATH,
/**
*
*/
KILL,
/**
*
*/
GM,
/**
*
*/
LOGIN,
/**
*
*/
LOGOUT,
/**
*
*/
KICK,
/**
*
*/
RELOAD
OTHER;
}

View File

@ -1,39 +1,32 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling.info;
import java.util.UUID;
import main.java.com.djrapitops.plan.data.UserData;
/**
* HandlingInfo Class for KickEvent information.
*
* @author Rsl1122
* @since 3.0.0
*/
public class KickInfo extends HandlingInfo {
/**
* Constructor.
*
* @param uuid
* @param uuid UUID of the kicked player.
*/
public KickInfo(UUID uuid) {
super(uuid, InfoType.KICK, 0L);
}
/**
*
* @param uData
* @return
*/
@Override
public boolean process(UserData uData) {
if (!uData.getUuid().equals(uuid)) {
return false;
}
uData.setTimesKicked(uData.getTimesKicked()+1);
uData.setTimesKicked(uData.getTimesKicked() + 1);
return true;
}
}

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling.info;
import java.util.UUID;
@ -11,8 +6,11 @@ import main.java.com.djrapitops.plan.data.handling.KillHandling;
import org.bukkit.entity.LivingEntity;
/**
* HandlingInfo Class for DeathEvent information when the dead entity is a
* player.
*
* @author Rsl1122
* @since 3.0.0
*/
public class KillInfo extends HandlingInfo {
@ -20,11 +18,12 @@ public class KillInfo extends HandlingInfo {
private String weaponName;
/**
* Constructor.
*
* @param uuid
* @param time
* @param dead
* @param weaponName
* @param uuid UUID of the killer.
* @param time Epoch ms the event occurred.
* @param dead Dead entity (Mob or Player)
* @param weaponName Weapon used.
*/
public KillInfo(UUID uuid, long time, LivingEntity dead, String weaponName) {
super(uuid, InfoType.KILL, time);
@ -32,11 +31,6 @@ public class KillInfo extends HandlingInfo {
this.weaponName = weaponName;
}
/**
*
* @param uData
* @return
*/
@Override
public boolean process(UserData uData) {
if (!uData.getUuid().equals(uuid)) {

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling.info;
import java.net.InetAddress;
@ -12,10 +7,13 @@ import main.java.com.djrapitops.plan.data.handling.LoginHandling;
import org.bukkit.GameMode;
/**
* HandlingInfo Class for JoinEvent information.
*
* @author Rsl1122
* @since 3.0.0
*/
public class LoginInfo extends HandlingInfo{
public class LoginInfo extends HandlingInfo {
private InetAddress ip;
private boolean banned;
private String nickname;
@ -23,14 +21,15 @@ public class LoginInfo extends HandlingInfo{
private int loginTimes;
/**
* Constructor.
*
* @param uuid
* @param time
* @param ip
* @param banned
* @param nickname
* @param gm
* @param loginTimes
* @param uuid UUID of the player.
* @param time Epoch ms of the event.
* @param ip IP of the player
* @param banned Is the player banned?
* @param nickname Nickname of the player
* @param gm current gamemode of the player
* @param loginTimes number the loginTimes should be incremented with.
*/
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm, int loginTimes) {
super(uuid, InfoType.LOGIN, time);
@ -40,25 +39,21 @@ public class LoginInfo extends HandlingInfo{
this.gmInfo = new GamemodeInfo(uuid, time, gm);
this.loginTimes = loginTimes;
}
/**
* Constructor for not incrementing the loginTimes.
*
* @param uuid
* @param time
* @param ip
* @param banned
* @param nickname
* @param gm
* @param uuid UUID of the player.
* @param time Epoch ms of the event.
* @param ip IP of the player
* @param banned Is the player banned?
* @param nickname Nickname of the player
* @param gm current gamemode of the player
*/
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm) {
this(uuid, time, ip, banned, nickname, gm, 0);
}
/**
*
* @param uData
* @return
*/
@Override
public boolean process(UserData uData) {
if (!uData.getUuid().equals(uuid)) {

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling.info;
import java.util.UUID;
@ -12,8 +7,10 @@ import main.java.com.djrapitops.plan.data.handling.LogoutHandling;
import org.bukkit.GameMode;
/**
* HandlingInfo Class for QuitEvent information.
*
* @author Rsl1122
* @since 3.0.0
*/
public class LogoutInfo extends HandlingInfo {
@ -22,12 +19,14 @@ public class LogoutInfo extends HandlingInfo {
private GamemodeInfo gmInfo;
/**
* Constructor.
*
* @param uuid
* @param time
* @param banned
* @param gm
* @param sData
* @param uuid UUID of the player.
* @param time Epoch ms of the event.
* @param banned Is the player banned
* @param gm current gamemode of the player
* @param sData session that has been ended at the moment of the logout
* event.
*/
public LogoutInfo(UUID uuid, long time, boolean banned, GameMode gm, SessionData sData) {
super(uuid, InfoType.LOGOUT, time);
@ -36,11 +35,6 @@ public class LogoutInfo extends HandlingInfo {
this.gmInfo = new GamemodeInfo(uuid, time, gm);
}
/**
*
* @param uData
* @return
*/
@Override
public boolean process(UserData uData) {
if (!uData.getUuid().equals(uuid)) {

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling.info;
import java.net.InetAddress;
@ -12,8 +7,10 @@ import main.java.com.djrapitops.plan.data.handling.LoginHandling;
import org.bukkit.GameMode;
/**
* HandlingInfo Class for refreshing data in the cache for online players.
*
* @author Rsl1122
* @since 3.0.0
*/
public class ReloadInfo extends HandlingInfo {
@ -23,13 +20,14 @@ public class ReloadInfo extends HandlingInfo {
private GamemodeInfo gmInfo;
/**
* Constructor.
*
* @param uuid
* @param time
* @param ip
* @param banned
* @param nickname
* @param gm
* @param uuid UUID of the player.
* @param time Epoch ms of the event.
* @param ip IP of the player
* @param banned Is the player banned?
* @param nickname Nickname of the player
* @param gm current gamemode of the player
*/
public ReloadInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm) {
super(uuid, InfoType.RELOAD, time);
@ -39,18 +37,13 @@ public class ReloadInfo extends HandlingInfo {
gmInfo = new GamemodeInfo(uuid, time, gm);
}
/**
*
* @param uData
* @return
*/
@Override
public boolean process(UserData uData) {
if (!uData.getUuid().equals(uuid)) {
return false;
}
uData.setPlayTime(uData.getPlayTime() + (time - uData.getLastPlayed()));
uData.setLastPlayed(time);
uData.setLastPlayed(time);
uData.updateBanned(banned);
uData.addIpAddress(ip);
uData.addNickname(nickname);

View File

@ -10,6 +10,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
/**
* Event Listener for AsyncPlayerChatEvents.
*
* @author Rsl1122
*/

View File

@ -9,6 +9,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
/**
* Event Listener for PlayerCommandPreprocessEvents.
*
* @author Rsl1122
*/

View File

@ -14,6 +14,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
/**
* Event Listener for EntityDeathEvents.
*
* @author Rsl1122
*/
@ -23,8 +24,9 @@ public class PlanDeathEventListener implements Listener {
private final DataCacheHandler handler;
/**
* Class Constructor.
*
* @param plugin
* @param plugin Current instance of Plan
*/
public PlanDeathEventListener(Plan plugin) {
this.plugin = plugin;

View File

@ -11,6 +11,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
/**
* Event Listener for PlayerGameModeChangeEvents.
*
* @author Rsl1122
*/
@ -27,7 +28,7 @@ public class PlanGamemodeChangeListener implements Listener {
public PlanGamemodeChangeListener(Plan plugin) {
this.plugin = plugin;
handler = plugin.getHandler();
}
/**

View File

@ -21,6 +21,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
/**
* Event Listener for PlayerJoin, PlayerQuit and PlayerKickEvents.
*
* @author Rsl1122
*/
@ -55,8 +56,8 @@ public class PlanPlayerListener implements Listener {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
handler.startSession(uuid);
Log.debug(uuid+": PlayerJoinEvent");
BukkitTask asyncNewPlayerCheckTask = (new BukkitRunnable() {
Log.debug(uuid + ": PlayerJoinEvent");
BukkitTask asyncNewPlayerCheckTask = new BukkitRunnable() {
@Override
public void run() {
LoginInfo loginInfo = new LoginInfo(uuid, new Date().getTime(), player.getAddress().getAddress(), player.isBanned(), player.getDisplayName(), player.getGameMode(), 1);
@ -68,11 +69,11 @@ public class PlanPlayerListener implements Listener {
} else {
handler.addToPool(loginInfo);
}
Log.debug(uuid+": PlayerJoinEvent_AsyncTask_END, New:"+isNewPlayer);
Log.debug(uuid + ": PlayerJoinEvent_AsyncTask_END, New:" + isNewPlayer);
this.cancel();
}
}).runTaskAsynchronously(plugin);
Log.debug(uuid+": PlayerJoinEvent_END");
}.runTaskAsynchronously(plugin);
Log.debug(uuid + ": PlayerJoinEvent_END");
}
/**
@ -88,10 +89,10 @@ public class PlanPlayerListener implements Listener {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
handler.endSession(uuid);
Log.debug(uuid+": PlayerQuitEvent");
Log.debug(uuid + ": PlayerQuitEvent");
handler.addToPool(new LogoutInfo(uuid, new Date().getTime(), player.isBanned(), player.getGameMode(), handler.getSession(uuid)));
handler.saveCachedData(uuid);
Log.debug(uuid+": PlayerQuitEvent_END");
Log.debug(uuid + ": PlayerQuitEvent_END");
}
/**

View File

@ -10,6 +10,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
/**
* Event Listener for PlayerMoveEvents.
*
* @author Rsl1122
*/

View File

@ -10,6 +10,7 @@ import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
/**
* Abstract class representing a Database.
*
* @author Rsl1122
*/
@ -18,18 +19,22 @@ public abstract class Database {
private final Plan plugin;
/**
* Super constructor.
*
* @param plugin
* @param plugin current instance of Plan.
*/
public Database(Plan plugin) {
this.plugin = plugin;
}
/**
* Initiates the database.
*
* @return
* Default method returns false.
*
* @return Was the initiation successful?
*/
public boolean init(){
public boolean init() {
return false;
}
@ -104,8 +109,7 @@ public abstract class Database {
/**
*
* @return
* @throws SQLException
* @return @throws SQLException
*/
public abstract int getVersion() throws SQLException;
@ -132,8 +136,7 @@ public abstract class Database {
/**
*
* @return
* @throws SQLException
* @return @throws SQLException
*/
public abstract boolean removeAllData() throws SQLException;
@ -147,15 +150,13 @@ public abstract class Database {
/**
*
* @return
* @throws SQLException
* @return @throws SQLException
*/
public abstract Set<UUID> getSavedUUIDs() throws SQLException;
/**
*
* @return
* @throws SQLException
* @return @throws SQLException
*/
public abstract HashMap<String, Integer> getCommandUse() throws SQLException;

View File

@ -136,10 +136,18 @@ public abstract class SQLDB extends Database {
return true;
}
/**
*
* @return
*/
public Table[] getAllTables() {
return new Table[]{usersTable, locationsTable, gmTimesTable, ipsTable, nicknamesTable, sessionsTable, killsTable, commandUseTable};
}
/**
*
* @return
*/
public Table[] getAllTablesInRemoveOrder() {
return new Table[]{locationsTable, gmTimesTable, ipsTable, nicknamesTable, sessionsTable, killsTable, usersTable, commandUseTable};
}
@ -329,6 +337,14 @@ public abstract class SQLDB extends Database {
return getLocations(Integer.parseInt(userId), worlds);
}
/**
*
* @param userId
* @param worlds
* @return
* @throws SQLException
* @deprecated
*/
@Deprecated
public List<Location> getLocations(int userId, HashMap<String, World> worlds) throws SQLException {
return locationsTable.getLocations(userId, worlds);
@ -535,34 +551,66 @@ public abstract class SQLDB extends Database {
return connection;
}
/**
*
* @return
*/
public UsersTable getUsersTable() {
return usersTable;
}
/**
*
* @return
*/
public SessionsTable getSessionsTable() {
return sessionsTable;
}
/**
*
* @return
*/
public GMTimesTable getGmTimesTable() {
return gmTimesTable;
}
/**
*
* @return
*/
public KillsTable getKillsTable() {
return killsTable;
}
/**
*
* @return
*/
public LocationsTable getLocationsTable() {
return locationsTable;
}
/**
*
* @return
*/
public IPsTable getIpsTable() {
return ipsTable;
}
/**
*
* @return
*/
public NicknamesTable getNicknamesTable() {
return nicknamesTable;
}
/**
*
* @return
*/
public CommandUseTable getCommandUseTable() {
return commandUseTable;
}

View File

@ -16,12 +16,21 @@ public class CommandUseTable extends Table {
private final String columnCommand;
private final String columnTimesUsed;
/**
*
* @param db
* @param usingMySQL
*/
public CommandUseTable(SQLDB db, boolean usingMySQL) {
super("plan_commandusages", db, usingMySQL);
columnCommand = "command";
columnTimesUsed = "times_used";
}
/**
*
* @return
*/
@Override
public boolean createTable() {
try {
@ -37,6 +46,11 @@ public class CommandUseTable extends Table {
}
}
/**
*
* @return
* @throws SQLException
*/
public HashMap<String, Integer> getCommandUse() throws SQLException {
HashMap<String, Integer> commandUse = new HashMap<>();
PreparedStatement statement = null;
@ -54,6 +68,12 @@ public class CommandUseTable extends Table {
}
}
/**
*
* @param data
* @throws SQLException
* @throws NullPointerException
*/
public void saveCommandUse(HashMap<String, Integer> data) throws SQLException, NullPointerException {
if (data.isEmpty()) {
return;

View File

@ -21,6 +21,11 @@ public class GMTimesTable extends Table {
private final String columnAdventureTime;
private final String columnSpectatorTime;
/**
*
* @param db
* @param usingMySQL
*/
public GMTimesTable(SQLDB db, boolean usingMySQL) {
super("plan_gamemodetimes", db, usingMySQL);
columnUserID = "user_id";
@ -30,6 +35,10 @@ public class GMTimesTable extends Table {
columnSpectatorTime = "spectator";
}
/**
*
* @return
*/
@Override
public boolean createTable() {
UsersTable usersTable = db.getUsersTable();
@ -50,6 +59,11 @@ public class GMTimesTable extends Table {
}
}
/**
*
* @param userId
* @return
*/
public boolean removeUserGMTimes(int userId) {
PreparedStatement statement = null;
try {
@ -65,6 +79,12 @@ public class GMTimesTable extends Table {
}
}
/**
*
* @param userId
* @return
* @throws SQLException
*/
public HashMap<GameMode, Long> getGMTimes(int userId) throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
@ -89,6 +109,12 @@ public class GMTimesTable extends Table {
}
}
/**
*
* @param userId
* @param gamemodeTimes
* @throws SQLException
*/
public void saveGMTimes(int userId, Map<GameMode, Long> gamemodeTimes) throws SQLException {
if (gamemodeTimes == null || gamemodeTimes.isEmpty()) {
return;

View File

@ -20,12 +20,21 @@ public class IPsTable extends Table {
private final String columnUserID;
private final String columnIP;
/**
*
* @param db
* @param usingMySQL
*/
public IPsTable(SQLDB db, boolean usingMySQL) {
super("plan_ips", db, usingMySQL);
columnUserID = "user_id";
columnIP = "ip";
}
/**
*
* @return
*/
@Override
public boolean createTable() {
UsersTable usersTable = db.getUsersTable();
@ -43,6 +52,11 @@ public class IPsTable extends Table {
}
}
/**
*
* @param userId
* @return
*/
public boolean removeUserIps(int userId) {
PreparedStatement statement = null;
try {
@ -58,6 +72,12 @@ public class IPsTable extends Table {
}
}
/**
*
* @param userId
* @return
* @throws SQLException
*/
public List<InetAddress> getIPAddresses(int userId) throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
@ -79,6 +99,12 @@ public class IPsTable extends Table {
}
}
/**
*
* @param userId
* @param ips
* @throws SQLException
*/
public void saveIPList(int userId, Set<InetAddress> ips) throws SQLException {
if (ips == null) {
return;

View File

@ -21,6 +21,11 @@ public class KillsTable extends Table {
private final String columnWeapon;
private final String columnDate;
/**
*
* @param db
* @param usingMySQL
*/
public KillsTable(SQLDB db, boolean usingMySQL) {
super("plan_kills", db, usingMySQL);
columnWeapon = "weapon";
@ -29,6 +34,10 @@ public class KillsTable extends Table {
columnVictimUserID = "victim_id";
}
/**
*
* @return
*/
@Override
public boolean createTable() {
UsersTable usersTable = db.getUsersTable();
@ -49,6 +58,11 @@ public class KillsTable extends Table {
}
}
/**
*
* @param userId
* @return
*/
public boolean removeUserKillsAndVictims(int userId) {
PreparedStatement statement = null;
try {
@ -65,6 +79,12 @@ public class KillsTable extends Table {
}
}
/**
*
* @param userId
* @return
* @throws SQLException
*/
public List<KillData> getPlayerKills(int userId) throws SQLException {
UsersTable usersTable = db.getUsersTable();
PreparedStatement statement = null;
@ -86,6 +106,12 @@ public class KillsTable extends Table {
}
}
/**
*
* @param userId
* @param kills
* @throws SQLException
*/
public void savePlayerKills(int userId, List<KillData> kills) throws SQLException {
if (kills == null) {
return;

View File

@ -23,6 +23,11 @@ public class LocationsTable extends Table {
private final String columnCoordinatesZ;
private final String columnWorld;
/**
*
* @param db
* @param usingMySQL
*/
public LocationsTable(SQLDB db, boolean usingMySQL) {
super("plan_locations", db, usingMySQL);
columnID = "id";
@ -32,6 +37,10 @@ public class LocationsTable extends Table {
columnWorld = "world_name";
}
/**
*
* @return
*/
@Override
public boolean createTable() {
UsersTable usersTable = db.getUsersTable();
@ -53,6 +62,11 @@ public class LocationsTable extends Table {
}
}
/**
*
* @param userId
* @return
*/
public boolean removeUserLocations(int userId) {
PreparedStatement statement = null;
try {
@ -68,6 +82,13 @@ public class LocationsTable extends Table {
}
}
/**
*
* @param userId
* @param worlds
* @return
* @throws SQLException
*/
public List<Location> getLocations(int userId, HashMap<String, World> worlds) throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
@ -86,6 +107,12 @@ public class LocationsTable extends Table {
}
}
/**
*
* @param userId
* @param locations
* @throws SQLException
*/
public void saveAdditionalLocationsList(int userId, List<Location> locations) throws SQLException {
if (locations == null || locations.isEmpty()) {
return;

View File

@ -19,6 +19,11 @@ public class NicknamesTable extends Table {
private final String columnNick;
private final String columnCurrent;
/**
*
* @param db
* @param usingMySQL
*/
public NicknamesTable(SQLDB db, boolean usingMySQL) {
super("plan_nicknames", db, usingMySQL);
columnUserID = "user_id";
@ -26,6 +31,10 @@ public class NicknamesTable extends Table {
columnCurrent = "current_nick";
}
/**
*
* @return
*/
@Override
public boolean createTable() {
UsersTable usersTable = db.getUsersTable();
@ -61,6 +70,11 @@ public class NicknamesTable extends Table {
}
}
/**
*
* @param userId
* @return
*/
public boolean removeUserNicknames(int userId) {
PreparedStatement statement = null;
try {
@ -76,6 +90,12 @@ public class NicknamesTable extends Table {
}
}
/**
*
* @param userId
* @return
* @throws SQLException
*/
public List<String> getNicknames(int userId) throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
@ -106,6 +126,13 @@ public class NicknamesTable extends Table {
}
}
/**
*
* @param userId
* @param names
* @param lastNick
* @throws SQLException
*/
public void saveNickList(int userId, Set<String> names, String lastNick) throws SQLException {
if (names == null || names.isEmpty()) {
return;

View File

@ -19,6 +19,11 @@ public class SessionsTable extends Table {
private final String columnSessionStart;
private final String columnSessionEnd;
/**
*
* @param db
* @param usingMySQL
*/
public SessionsTable(SQLDB db, boolean usingMySQL) {
super("plan_sessions", db, usingMySQL);
columnUserID = "user_id";
@ -26,6 +31,10 @@ public class SessionsTable extends Table {
columnSessionEnd = "session_end";
}
/**
*
* @return
*/
@Override
public boolean createTable() {
try {
@ -44,6 +53,12 @@ public class SessionsTable extends Table {
}
}
/**
*
* @param userId
* @return
* @throws SQLException
*/
public List<SessionData> getSessionData(int userId) throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
@ -64,6 +79,11 @@ public class SessionsTable extends Table {
}
}
/**
*
* @param userId
* @return
*/
public boolean removeUserSessions(int userId) {
PreparedStatement statement = null;
try {
@ -79,6 +99,12 @@ public class SessionsTable extends Table {
}
}
/**
*
* @param userId
* @param sessions
* @throws SQLException
*/
public void saveSessionData(int userId, List<SessionData> sessions) throws SQLException {
if (sessions == null) {
return;

View File

@ -12,18 +12,44 @@ import main.java.com.djrapitops.plan.database.databases.SQLDB;
*/
public abstract class Table {
/**
*
*/
protected String tableName;
/**
*
*/
protected SQLDB db;
/**
*
*/
protected boolean usingMySQL;
/**
*
* @param name
* @param db
* @param usingMySQL
*/
public Table(String name, SQLDB db, boolean usingMySQL) {
this.tableName = name;
this.db = db;
this.usingMySQL = usingMySQL;
}
/**
*
* @return
*/
public abstract boolean createTable();
/**
*
* @return
* @throws SQLException
*/
protected Connection getConnection() throws SQLException {
Connection connection = db.getConnection();
if (connection == null || connection.isClosed()) {
@ -32,20 +58,41 @@ public abstract class Table {
return connection;
}
/**
*
* @return
* @throws SQLException
*/
public int getVersion() throws SQLException {
return db.getVersion();
}
/**
*
* @param sql
* @return
* @throws SQLException
*/
protected boolean execute(String sql) throws SQLException {
Connection connection = getConnection();
boolean success = connection.createStatement().execute(sql);
return success;
}
/**
*
* @param sql
* @return
* @throws SQLException
*/
protected PreparedStatement prepareStatement(String sql) throws SQLException {
return getConnection().prepareStatement(sql);
}
/**
*
* @param toClose
*/
protected void close(AutoCloseable toClose) {
if (toClose != null) {
try {
@ -55,10 +102,18 @@ public abstract class Table {
}
}
/**
*
* @return
*/
public String getTableName() {
return tableName;
}
/**
*
* @return
*/
public boolean removeAllData() {
try {
execute("DELETE FROM " + tableName);

View File

@ -35,6 +35,11 @@ public class UsersTable extends Table {
private final String columnDeaths;
private final String columnMobKills;
/**
*
* @param db
* @param usingMySQL
*/
public UsersTable(SQLDB db, boolean usingMySQL) {
super("plan_users", db, usingMySQL);
columnID = "id";
@ -52,6 +57,10 @@ public class UsersTable extends Table {
columnDeaths = "deaths";
}
/**
*
* @return
*/
@Override
public boolean createTable() {
try {
@ -103,10 +112,22 @@ public class UsersTable extends Table {
}
}
/**
*
* @param uuid
* @return
* @throws SQLException
*/
public int getUserId(UUID uuid) throws SQLException {
return getUserId(uuid.toString());
}
/**
*
* @param uuid
* @return
* @throws SQLException
*/
public int getUserId(String uuid) throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
@ -125,6 +146,12 @@ public class UsersTable extends Table {
}
}
/**
*
* @param userID
* @return
* @throws SQLException
*/
public UUID getUserUUID(String userID) throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
@ -143,6 +170,11 @@ public class UsersTable extends Table {
}
}
/**
*
* @return
* @throws SQLException
*/
public Set<UUID> getSavedUUIDs() throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
@ -164,10 +196,20 @@ public class UsersTable extends Table {
}
}
/**
*
* @param uuid
* @return
*/
public boolean removeUser(UUID uuid) {
return removeUser(uuid.toString());
}
/**
*
* @param uuid
* @return
*/
public boolean removeUser(String uuid) {
PreparedStatement statement = null;
try {
@ -182,6 +224,11 @@ public class UsersTable extends Table {
}
}
/**
*
* @param data
* @throws SQLException
*/
public void addUserInformationToUserData(UserData data) throws SQLException {
PreparedStatement statement = null;
ResultSet set = null;
@ -207,6 +254,11 @@ public class UsersTable extends Table {
}
}
/**
*
* @param data
* @throws SQLException
*/
public void saveUserDataInformation(UserData data) throws SQLException {
PreparedStatement statement = null;
try {
@ -285,6 +337,12 @@ public class UsersTable extends Table {
}
}
/**
*
* @param data
* @return
* @throws SQLException
*/
public List<UserData> saveUserDataInformationBatch(List<UserData> data) throws SQLException {
PreparedStatement statement = null;
try {
@ -360,6 +418,10 @@ public class UsersTable extends Table {
}
}
/**
*
* @return
*/
public String getColumnID() {
return columnID;
}

View File

@ -12,10 +12,19 @@ import main.java.com.djrapitops.plan.database.databases.SQLDB;
*/
public class VersionTable extends Table {
/**
*
* @param db
* @param usingMySQL
*/
public VersionTable(SQLDB db, boolean usingMySQL) {
super("plan_version", db, usingMySQL);
}
/**
*
* @return
*/
@Override
public boolean createTable() {
try {
@ -30,6 +39,11 @@ public class VersionTable extends Table {
}
}
/**
*
* @return
* @throws SQLException
*/
@Override
public int getVersion() throws SQLException {
PreparedStatement statement = null;
@ -48,6 +62,11 @@ public class VersionTable extends Table {
}
}
/**
*
* @param version
* @throws SQLException
*/
public void setVersion(int version) throws SQLException {
removeAllData();
PreparedStatement statement = null;

View File

@ -89,8 +89,8 @@ public enum Html {
TABLE_START_4("<table class=\"sortable table\"><thead><tr><th>REPLACE0</th><th>REPLACE1</th><th>REPLACE2</th><th>REPLACE3</th></tr></thead><tbody>"),
TABLE_SESSIONS_START(TABLE_START_3.parse("Session Started", "Session Ended", "Session Length")),
TABLE_KILLS_START(TABLE_START_3.parse("Date", "Killed", "With")),
TABLE_FACTIONS_START(TABLE_START_4.parse(FONT_AWESOME_ICON.parse("flag")+" Faction", FONT_AWESOME_ICON.parse("bolt")+" Power", FONT_AWESOME_ICON.parse("map-o")+" Land", FONT_AWESOME_ICON.parse("user")+" Leader")),
TABLE_TOWNS_START(TABLE_START_4.parse(FONT_AWESOME_ICON.parse("bank")+" Town", FONT_AWESOME_ICON.parse("users")+" Residents", FONT_AWESOME_ICON.parse("map-o")+" Land", FONT_AWESOME_ICON.parse("user")+" Mayor")),
TABLE_FACTIONS_START(TABLE_START_4.parse(FONT_AWESOME_ICON.parse("flag") + " Faction", FONT_AWESOME_ICON.parse("bolt") + " Power", FONT_AWESOME_ICON.parse("map-o") + " Land", FONT_AWESOME_ICON.parse("user") + " Leader")),
TABLE_TOWNS_START(TABLE_START_4.parse(FONT_AWESOME_ICON.parse("bank") + " Town", FONT_AWESOME_ICON.parse("users") + " Residents", FONT_AWESOME_ICON.parse("map-o") + " Land", FONT_AWESOME_ICON.parse("user") + " Mayor")),
TABLELINE_2("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td></tr>"),
TABLELINE_3("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td><td>REPLACE2</td></tr>"),
TABLELINE_4("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td><td>REPLACE2</td><td>REPLACE3</td></tr>"),

Some files were not shown because too many files have changed in this diff Show More