mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-02 05:21:36 +01:00
Javadocs about 50% complete.
This commit is contained in:
parent
13294cf308
commit
1df9eb1fd8
@ -72,6 +72,20 @@
|
|||||||
<property name='allowEmptyMethods' value='true' />
|
<property name='allowEmptyMethods' value='true' />
|
||||||
</module>
|
</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>
|
</module>
|
||||||
|
|
||||||
<!-- File Length -->
|
<!-- File Length -->
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<actions>
|
<actions>
|
||||||
|
<action>
|
||||||
|
<actionName>CUSTOM-Javadoc</actionName>
|
||||||
|
<displayName>Javadoc</displayName>
|
||||||
|
<goals>
|
||||||
|
<goal>javadoc:javadoc</goal>
|
||||||
|
</goals>
|
||||||
|
</action>
|
||||||
<action>
|
<action>
|
||||||
<actionName>CUSTOM-checkstyle</actionName>
|
<actionName>CUSTOM-checkstyle</actionName>
|
||||||
<displayName>Checkstyle</displayName>
|
<displayName>Checkstyle</displayName>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.djrapitops</groupId>
|
<groupId>com.djrapitops</groupId>
|
||||||
<artifactId>Plan</artifactId>
|
<artifactId>Plan</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>3.1.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<repositories>
|
<repositories>
|
||||||
<!-- <repository>
|
<!-- <repository>
|
||||||
@ -169,6 +169,7 @@
|
|||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
<version>2.17</version>
|
<version>2.17</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<excludes>**/test/**/*</excludes>
|
||||||
<configLocation>checkstyle.xml</configLocation>
|
<configLocation>checkstyle.xml</configLocation>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -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 source Class name the exception was caught in.
|
||||||
* @param e Throwable, eg NullPointerException
|
* @param e Throwable, eg NullPointerException
|
||||||
|
@ -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
|
* @return line of the permission eg. plan.inspect
|
||||||
*/
|
*/
|
||||||
|
@ -202,6 +202,8 @@ public enum Phrase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Used to get the ChatColor of COLOR_ enums.
|
||||||
|
*
|
||||||
* @return Color of the COLOR_ENUM
|
* @return Color of the COLOR_ENUM
|
||||||
*/
|
*/
|
||||||
public ChatColor color() {
|
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) {
|
public void setText(String text) {
|
||||||
this.text = 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) {
|
public void setColor(char colorCode) {
|
||||||
this.color = ChatColor.getByChar(colorCode);
|
this.color = ChatColor.getByChar(colorCode);
|
||||||
|
@ -49,7 +49,7 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Javaplugin class that contains methods for starting the plugin, logging to
|
* 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
|
* @author Rsl1122
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
@ -72,8 +72,9 @@ public class Plan extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* Creates the config file. Checks for new version. Initializes Database.
|
* Creates the config file. Checks for new version. Initializes Database.
|
||||||
* Hooks to Supported plugins. Initializes DataCaches. Registers Listeners.
|
* Hooks to Supported plugins. Initializes DataCaches. Registers Listeners.
|
||||||
* Registers Command /plan and initializes API. Enables Webserver & analysis
|
* Registers Command /plan and initializes API. Enables Webserver and
|
||||||
* tasks if enabled in config. Warns about possible mistakes made in config.
|
* analysis tasks if enabled in config. Warns about possible mistakes made
|
||||||
|
* in config.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -203,7 +204,7 @@ public class Plan extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startAnalysisRefreshTask(int analysisRefreshMinutes) throws IllegalStateException, IllegalArgumentException {
|
private void startAnalysisRefreshTask(int analysisRefreshMinutes) throws IllegalStateException, IllegalArgumentException {
|
||||||
BukkitTask asyncPeriodicalAnalysisTask = (new BukkitRunnable() {
|
BukkitTask asyncPeriodicalAnalysisTask = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!analysisCache.isCached()) {
|
if (!analysisCache.isCached()) {
|
||||||
@ -212,19 +213,19 @@ public class Plan extends JavaPlugin {
|
|||||||
analysisCache.updateCache();
|
analysisCache.updateCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskTimerAsynchronously(this, analysisRefreshMinutes * 60 * 20, analysisRefreshMinutes * 60 * 20);
|
}.runTaskTimerAsynchronously(this, analysisRefreshMinutes * 60 * 20, analysisRefreshMinutes * 60 * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startBootAnalysisTask() throws IllegalStateException, IllegalArgumentException {
|
private void startBootAnalysisTask() throws IllegalStateException, IllegalArgumentException {
|
||||||
Log.info(Phrase.ANALYSIS_BOOT_NOTIFY + "");
|
Log.info(Phrase.ANALYSIS_BOOT_NOTIFY + "");
|
||||||
BukkitTask bootAnalysisTask = (new BukkitRunnable() {
|
BukkitTask bootAnalysisTask = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.info(Phrase.ANALYSIS_BOOT + "");
|
Log.info(Phrase.ANALYSIS_BOOT + "");
|
||||||
analysisCache.updateCache();
|
analysisCache.updateCache();
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
}).runTaskLater(this, 30 * 20);
|
}.runTaskLater(this, 30 * 20);
|
||||||
bootAnalysisTaskID = bootAnalysisTask.getTaskId();
|
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.
|
* #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() {
|
public HashSet<Database> getDatabases() {
|
||||||
return databases;
|
return databases;
|
||||||
@ -375,7 +376,7 @@ public class Plan extends JavaPlugin {
|
|||||||
* Instance is set on the first line of onEnable method.
|
* Instance is set on the first line of onEnable method.
|
||||||
*
|
*
|
||||||
* @return current instance of Plan, Singleton.
|
* @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.
|
* the instance is null.
|
||||||
*/
|
*/
|
||||||
public static Plan getInstance() {
|
public static Plan getInstance() {
|
||||||
@ -400,7 +401,7 @@ public class Plan extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return API of the current instance of Plan.
|
* @return API of the current instance of Plan.
|
||||||
* @throws IllegalStateException If onEnable method has not been called on
|
* @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 {
|
public static API getPlanAPI() throws IllegalStateException {
|
||||||
Plan INSTANCE = PlanHolder.INSTANCE;
|
Plan INSTANCE = PlanHolder.INSTANCE;
|
||||||
@ -411,6 +412,7 @@ public class Plan extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class PlanHolder {
|
private static class PlanHolder {
|
||||||
|
|
||||||
private static Plan INSTANCE = null;
|
private static Plan INSTANCE = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package main.java.com.djrapitops.plan.api;
|
package main.java.com.djrapitops.plan.api;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
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.additional.PluginData;
|
||||||
import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
|
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.data.handling.info.HandlingInfo;
|
||||||
import main.java.com.djrapitops.plan.ui.DataRequestHandler;
|
import main.java.com.djrapitops.plan.ui.DataRequestHandler;
|
||||||
import main.java.com.djrapitops.plan.ui.webserver.WebSocketServer;
|
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.HtmlUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
|
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
|
||||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||||
@ -18,12 +17,16 @@ import org.bukkit.OfflinePlayer;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains the API methods.
|
* 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.
|
* otherwise stated.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
|
* @see PluginData
|
||||||
|
* @see AnalysisType
|
||||||
|
* @see DBCallableProcessor
|
||||||
|
* @see HandlingInfo
|
||||||
*/
|
*/
|
||||||
public class API {
|
public class API {
|
||||||
|
|
||||||
@ -55,7 +58,7 @@ public class API {
|
|||||||
* data source that extends PluginData correctly.
|
* data source that extends PluginData correctly.
|
||||||
*
|
*
|
||||||
* @param dataSource an object that extends PluginData-object, thus allowing
|
* @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
|
* @see PluginData
|
||||||
*/
|
*/
|
||||||
public void addPluginDataSource(PluginData dataSource) {
|
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
|
* Uses cache if data is cached or database if not. Call from an Asyncronous
|
||||||
* thread.
|
* thread.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player.
|
||||||
*/
|
*/
|
||||||
public void cacheUserDataToInspectCache(UUID uuid) {
|
public void cacheUserDataToInspectCache(UUID uuid) {
|
||||||
plugin.getInspectCache().cache(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
|
* @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.
|
* the database.
|
||||||
*
|
*
|
||||||
* Starts a new Asyncronous task to run the analysis.
|
* 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
|
* @param playerName Player's name
|
||||||
* @return UUID of the Player
|
* @return UUID of the Player
|
||||||
@ -239,25 +242,4 @@ public class API {
|
|||||||
public UUID playerNameToUUID(String playerName) throws Exception {
|
public UUID playerNameToUUID(String playerName) throws Exception {
|
||||||
return UUIDFetcher.getUUIDOf(playerName);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class PlanCommand implements CommandExecutor {
|
|||||||
*
|
*
|
||||||
* @param sender source of the command.
|
* @param sender source of the command.
|
||||||
* @param cmd command.
|
* @param cmd command.
|
||||||
* @param commandLabel
|
* @param commandLabel label.
|
||||||
* @param args arguments of the command
|
* @param args arguments of the command
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
@ -113,7 +113,7 @@ public class PlanCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (console && command.getCommandType() == CommandType.PLAYER) {;
|
if (console && command.getCommandType() == CommandType.PLAYER) {
|
||||||
sender.sendMessage("" + Phrase.COMMAND_SENDER_NOT_PLAYER);
|
sender.sendMessage("" + Phrase.COMMAND_SENDER_NOT_PLAYER);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -125,9 +125,7 @@ public class PlanCommand implements CommandExecutor {
|
|||||||
realArgs[i - 1] = args[i];
|
realArgs[i - 1] = args[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command.onCommand(sender, cmd, commandLabel, realArgs)) {
|
command.onCommand(sender, cmd, commandLabel, realArgs);
|
||||||
// Phrase.TRY_COMMAND.sendWithPrefix( sender, parse( commandLabel, command ) );
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package main.java.com.djrapitops.plan.command;
|
|||||||
|
|
||||||
import main.java.com.djrapitops.plan.Permissions;
|
import main.java.com.djrapitops.plan.Permissions;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,11 +94,12 @@ public abstract class SubCommand {
|
|||||||
/**
|
/**
|
||||||
* The Command Execution method.
|
* The Command Execution method.
|
||||||
*
|
*
|
||||||
* @param sender
|
* @param sender Parameter of onCommand in CommandExecutor.
|
||||||
* @param cmd
|
* @param cmd Parameter of onCommand in CommandExecutor.
|
||||||
* @param commandLabel
|
* @param commandLabel Parameter of onCommand in CommandExecutor.
|
||||||
* @param args
|
* @param args Parameter of onCommand in CommandExecutor.
|
||||||
* @return Was the execution successful?
|
* @return Was the execution successful?
|
||||||
|
* @see CommandExecutor
|
||||||
*/
|
*/
|
||||||
public abstract boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args);
|
public abstract boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import main.java.com.djrapitops.plan.ui.TextUI;
|
|||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandException;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -40,18 +39,6 @@ public class AnalyzeCommand extends SubCommand {
|
|||||||
analysisCache = plugin.getAnalysisCache();
|
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
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||||
@ -73,7 +60,7 @@ public class AnalyzeCommand extends SubCommand {
|
|||||||
analysisCache.updateCache();
|
analysisCache.updateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
BukkitTask analysisMessageSenderTask = (new BukkitRunnable() {
|
BukkitTask analysisMessageSenderTask = new BukkitRunnable() {
|
||||||
private int timesrun = 0;
|
private int timesrun = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -88,7 +75,7 @@ public class AnalyzeCommand extends SubCommand {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskTimer(plugin, 1 * 20, 5 * 20);
|
}.runTaskTimer(plugin, 1 * 20, 5 * 20);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,9 +83,8 @@ public class AnalyzeCommand extends SubCommand {
|
|||||||
* Used to send the message after /plan analysis.
|
* Used to send the message after /plan analysis.
|
||||||
*
|
*
|
||||||
* @param sender Command sender.
|
* @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();
|
boolean textUI = Settings.USE_ALTERNATIVE_UI.isTrue();
|
||||||
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER + "");
|
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER + "");
|
||||||
if (textUI) {
|
if (textUI) {
|
||||||
|
@ -11,7 +11,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
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
|
* @author Rsl1122
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
|
@ -43,17 +43,6 @@ public class InspectCommand extends SubCommand {
|
|||||||
inspectCache = plugin.getInspectCache();
|
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
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
final boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
final boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
|
||||||
@ -66,7 +55,7 @@ public class InspectCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String playerName = MiscUtils.getPlayerName(args, sender);
|
String playerName = MiscUtils.getPlayerName(args, sender);
|
||||||
BukkitTask inspectTask = (new BukkitRunnable() {
|
BukkitTask inspectTask = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
@ -98,7 +87,7 @@ public class InspectCommand extends SubCommand {
|
|||||||
configValue = 4;
|
configValue = 4;
|
||||||
}
|
}
|
||||||
final int available = configValue;
|
final int available = configValue;
|
||||||
BukkitTask inspectMessageSenderTask = (new BukkitRunnable() {
|
BukkitTask inspectMessageSenderTask = new BukkitRunnable() {
|
||||||
private int timesrun = 0;
|
private int timesrun = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -134,9 +123,9 @@ public class InspectCommand extends SubCommand {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskTimer(plugin, 1 * 20, 5 * 20);
|
}.runTaskTimer(plugin, 1 * 20, 5 * 20);
|
||||||
}
|
}
|
||||||
}).runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This command is used to manage the database of the plugin.
|
* This command is used to manage the database of the plugin.
|
||||||
* <p>
|
*
|
||||||
* No arguments will run ManageHelpCommand. Contains subcommands.
|
* No arguments will run ManageHelpCommand. Contains subcommands.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
@ -79,16 +79,6 @@ public class ManageCommand extends SubCommand {
|
|||||||
onCommand(sender, cmd, commandLabel, FormatUtils.mergeArrays(new String[]{command}, args));
|
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
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
@ -116,7 +106,7 @@ public class ManageCommand extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (console && command.getCommandType() == CommandType.PLAYER) {;
|
if (console && command.getCommandType() == CommandType.PLAYER) {
|
||||||
sender.sendMessage("" + Phrase.COMMAND_SENDER_NOT_PLAYER);
|
sender.sendMessage("" + Phrase.COMMAND_SENDER_NOT_PLAYER);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -128,8 +118,7 @@ public class ManageCommand extends SubCommand {
|
|||||||
realArgs[i - 1] = args[i];
|
realArgs[i - 1] = args[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command.onCommand(sender, cmd, commandLabel, realArgs)) {
|
command.onCommand(sender, cmd, commandLabel, realArgs);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,18 +36,6 @@ public class QuickAnalyzeCommand extends SubCommand {
|
|||||||
analysisCache = plugin.getAnalysisCache();
|
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
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||||
@ -61,7 +49,7 @@ public class QuickAnalyzeCommand extends SubCommand {
|
|||||||
analysisCache.updateCache();
|
analysisCache.updateCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
BukkitTask analysisMessageSenderTask = (new BukkitRunnable() {
|
BukkitTask analysisMessageSenderTask = new BukkitRunnable() {
|
||||||
private int timesrun = 0;
|
private int timesrun = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -78,7 +66,7 @@ public class QuickAnalyzeCommand extends SubCommand {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskTimer(plugin, 1 * 20, 5 * 20);
|
}.runTaskTimer(plugin, 1 * 20, 5 * 20);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,21 +42,10 @@ public class QuickInspectCommand extends SubCommand {
|
|||||||
inspectCache = plugin.getInspectCache();
|
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
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.QUICK_INSPECT_OTHER);
|
String playerName = MiscUtils.getPlayerName(args, sender, Permissions.QUICK_INSPECT_OTHER);
|
||||||
BukkitTask inspectTask = (new BukkitRunnable() {
|
BukkitTask inspectTask = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
@ -88,7 +77,7 @@ public class QuickInspectCommand extends SubCommand {
|
|||||||
configValue = 4;
|
configValue = 4;
|
||||||
}
|
}
|
||||||
final int available = configValue;
|
final int available = configValue;
|
||||||
BukkitTask inspectMessageSenderTask = (new BukkitRunnable() {
|
BukkitTask inspectMessageSenderTask = new BukkitRunnable() {
|
||||||
private int timesrun = 0;
|
private int timesrun = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,9 +94,9 @@ public class QuickInspectCommand extends SubCommand {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).runTaskTimer(plugin, 1 * 20, 5 * 20);
|
}.runTaskTimer(plugin, 1 * 20, 5 * 20);
|
||||||
}
|
}
|
||||||
}).runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,18 +43,6 @@ public class SearchCommand extends SubCommand {
|
|||||||
inspectCache = plugin.getInspectCache();
|
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
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
if (!Settings.WEBSERVER_ENABLED.isTrue()) {
|
||||||
@ -68,7 +56,7 @@ public class SearchCommand extends SubCommand {
|
|||||||
|
|
||||||
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
sender.sendMessage(Phrase.GRABBING_DATA_MESSAGE + "");
|
||||||
Set<OfflinePlayer> matches = MiscUtils.getMatchingDisplaynames(args[0]);
|
Set<OfflinePlayer> matches = MiscUtils.getMatchingDisplaynames(args[0]);
|
||||||
BukkitTask searchTask = (new BukkitRunnable() {
|
BukkitTask searchTask = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Set<UUID> uuids = new HashSet<>();
|
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_RESULTS_AVAILABLE.parse(available + ""));
|
||||||
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
||||||
}
|
}
|
||||||
}).runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,15 +33,6 @@ public class ManageBackupCommand extends SubCommand {
|
|||||||
this.plugin = plugin;
|
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
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
try {
|
try {
|
||||||
|
@ -34,19 +34,6 @@ public class ManageClearCommand extends SubCommand {
|
|||||||
this.plugin = plugin;
|
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
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
|
@ -33,16 +33,6 @@ public class ManageHotswapCommand extends SubCommand {
|
|||||||
this.plugin = plugin;
|
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
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
|
@ -43,19 +43,6 @@ public class ManageImportCommand extends SubCommand {
|
|||||||
this.plugin = plugin;
|
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
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
|
|
||||||
@ -90,7 +77,7 @@ public class ManageImportCommand extends SubCommand {
|
|||||||
uuids.add(p.getUniqueId());
|
uuids.add(p.getUniqueId());
|
||||||
}
|
}
|
||||||
HashMap<UUID, Long> numbericData = importPlugins.get(importFromPlugin).grabNumericData(uuids);
|
HashMap<UUID, Long> numbericData = importPlugins.get(importFromPlugin).grabNumericData(uuids);
|
||||||
BukkitTask asyncImportTask = (new BukkitRunnable() {
|
BukkitTask asyncImportTask = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (importFromPlugin.equals("ontime")) {
|
if (importFromPlugin.equals("ontime")) {
|
||||||
@ -100,7 +87,7 @@ public class ManageImportCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
}).runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class ManageRestoreCommand extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final Database copyToDB = database;
|
final Database copyToDB = database;
|
||||||
BukkitTask asyncRestoreTask = (new BukkitRunnable() {
|
BukkitTask asyncRestoreTask = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String backupDBName = args[0];
|
String backupDBName = args[0];
|
||||||
@ -105,7 +105,7 @@ public class ManageRestoreCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
}).runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
|
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import main.java.com.djrapitops.plan.ui.Html;
|
import main.java.com.djrapitops.plan.ui.Html;
|
||||||
import main.java.com.djrapitops.plan.ui.RecentPlayersButtonsCreator;
|
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.SortableCommandUseTableCreator;
|
||||||
import main.java.com.djrapitops.plan.ui.tables.SortablePlayersTableCreator;
|
import main.java.com.djrapitops.plan.ui.tables.SortablePlayersTableCreator;
|
||||||
import main.java.com.djrapitops.plan.utilities.Analysis;
|
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
|
* @return Number from 0 to Integer.MAX
|
||||||
*/
|
*/
|
||||||
@ -777,7 +778,7 @@ public class AnalysisData {
|
|||||||
*
|
*
|
||||||
* No check for correct value.
|
* No check for correct value.
|
||||||
*
|
*
|
||||||
* @param totaldeaths
|
* @param totaldeaths 0 to Long.MAX
|
||||||
*/
|
*/
|
||||||
public void setTotaldeaths(long totaldeaths) {
|
public void setTotaldeaths(long totaldeaths) {
|
||||||
this.totaldeaths = totaldeaths;
|
this.totaldeaths = totaldeaths;
|
||||||
@ -792,8 +793,8 @@ public class AnalysisData {
|
|||||||
* 0, 1 day; 2, 3 week; 4, 5 month
|
* 0, 1 day; 2, 3 week; 4, 5 month
|
||||||
*
|
*
|
||||||
* @return String array containing multiple toString representations of
|
* @return String array containing multiple toString representations of
|
||||||
* number & label arrays.
|
* number and label arrays.
|
||||||
* @see PlayersActivityGraphCreator
|
* @see PlayerActivityGraphCreator
|
||||||
* @see Analysis
|
* @see Analysis
|
||||||
*/
|
*/
|
||||||
public String[] getPlayersDataArray() {
|
public String[] getPlayersDataArray() {
|
||||||
@ -809,8 +810,8 @@ public class AnalysisData {
|
|||||||
* 0, 1 day; 2, 3 week; 4, 5 month
|
* 0, 1 day; 2, 3 week; 4, 5 month
|
||||||
*
|
*
|
||||||
* @param playersDataArray String array containing multiple toString
|
* @param playersDataArray String array containing multiple toString
|
||||||
* representations of number & label arrays.
|
* representations of number and label arrays.
|
||||||
* @see PlayersActivityGraphCreator
|
* @see PlayerActivityGraphCreator
|
||||||
* @see Analysis
|
* @see Analysis
|
||||||
*/
|
*/
|
||||||
public void setPlayersDataArray(String[] playersDataArray) {
|
public void setPlayersDataArray(String[] playersDataArray) {
|
||||||
|
@ -31,7 +31,7 @@ public class KillData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the victim's UUID
|
* Get the victim's UUID.
|
||||||
*
|
*
|
||||||
* @return UUID of the victim.
|
* @return UUID of the victim.
|
||||||
*/
|
*/
|
||||||
|
@ -4,13 +4,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import main.java.com.djrapitops.plan.utilities.Analysis;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used for storing combined data of several UserData objects
|
* This class is used for storing combined data of several UserData objects
|
||||||
* during Analysis.
|
* during Analysis and thus is not documented.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 2.6.0
|
* @since 2.6.0
|
||||||
|
* @see Analysis
|
||||||
*/
|
*/
|
||||||
public class RawAnalysisData {
|
public class RawAnalysisData {
|
||||||
|
|
||||||
@ -370,7 +372,7 @@ public class RawAnalysisData {
|
|||||||
*
|
*
|
||||||
* @param commandUse
|
* @param commandUse
|
||||||
*/
|
*/
|
||||||
public void setCommandUse(HashMap<String, Integer> commandUse) {
|
public void setCommandUse(Map<String, Integer> commandUse) {
|
||||||
this.commandUse = commandUse;
|
this.commandUse = commandUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,10 +56,10 @@ public class UserData {
|
|||||||
private List<SessionData> sessions;
|
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,
|
* Some variables are left uninitialized: isBanned, lastPlayed, playTime,
|
||||||
* loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths &
|
* loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths and
|
||||||
* currentSession.
|
* currentSession.
|
||||||
*
|
*
|
||||||
* These variables need to be set with setters.
|
* 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.
|
* Creates a new UserData object with the variables inside a Player object.
|
||||||
*
|
*
|
||||||
* Some variables are left uninitialized: lastPlayed, playTime, loginTimes,
|
* 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.
|
* These variables need to be set with setters.
|
||||||
*
|
*
|
||||||
@ -139,7 +139,7 @@ public class UserData {
|
|||||||
* object.
|
* object.
|
||||||
*
|
*
|
||||||
* Some variables are left uninitialized: location, lastPlayed, playTime,
|
* Some variables are left uninitialized: location, lastPlayed, playTime,
|
||||||
* loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths &
|
* loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths and
|
||||||
* currentSession.
|
* currentSession.
|
||||||
*
|
*
|
||||||
* These variables need to be set with setters.
|
* 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.
|
* @return a HashSet of Strings.
|
||||||
*/
|
*/
|
||||||
@ -696,7 +696,7 @@ public class UserData {
|
|||||||
/**
|
/**
|
||||||
* Set the GM Times map containing playtime in each gamemode.
|
* 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.
|
* (After 1.8) keys.
|
||||||
*/
|
*/
|
||||||
public void setGmTimes(Map<GameMode, Long> gmTimes) {
|
public void setGmTimes(Map<GameMode, Long> gmTimes) {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package main.java.com.djrapitops.plan.data.additional;
|
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.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.factions.FactionsTable;
|
||||||
import main.java.com.djrapitops.plan.data.additional.towny.TownyTable;
|
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.
|
* Refer to the documentation on github for additional information.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
public enum AnalysisType {
|
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.
|
* calculated.
|
||||||
*
|
*
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -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.
|
* calculated.
|
||||||
*
|
*
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -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.
|
* calculated.
|
||||||
*
|
*
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
DOUBLE_AVG("avgDouble_", "Average "),
|
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.
|
* calculated.
|
||||||
*
|
*
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
INT_TOTAL("totalInt_"),
|
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.
|
* calculated.
|
||||||
*
|
*
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
LONG_TOTAL("totalLong_"),
|
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.
|
* calculated.
|
||||||
*
|
*
|
||||||
* -1 values will be disregarded from the calculation (size will not grow).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
@ -63,24 +62,24 @@ public enum AnalysisType {
|
|||||||
DOUBLE_TOTAL("totalDouble_"),
|
DOUBLE_TOTAL("totalDouble_"),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns an amount of milliseconds as long
|
* 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).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
LONG_TIME_MS_AVG("avgTimeMs_", "Average "),
|
LONG_TIME_MS_AVG("avgTimeMs_", "Average "),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns an amount of milliseconds as long
|
* 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).
|
* -1 values will be disregarded from the calculation (size will not grow).
|
||||||
*/
|
*/
|
||||||
LONG_TIME_MS_TOTAL("totalTimeMs_"),
|
LONG_TIME_MS_TOTAL("totalTimeMs_"),
|
||||||
/**
|
/**
|
||||||
* Used when the getValue() method returns an Epoch Millisecond as long &
|
* Used when the getValue() method returns an Epoch Millisecond as long and
|
||||||
* average of differences between the millisecond & current millisecond
|
* average of differences between the millisecond and current millisecond
|
||||||
* should be calculated.
|
* 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
|
* that was 5s (5000ms) ago. Now you want to calculate the average
|
||||||
* time-since for all players. Then you use this one.
|
* 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().
|
* 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
|
* Used to calculate number of true values for the returned boolean values
|
||||||
* of getValue().
|
* of getValue().
|
||||||
@ -101,7 +100,7 @@ public enum AnalysisType {
|
|||||||
/**
|
/**
|
||||||
* Used to add html tags to the plugins tab.
|
* 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.
|
* elements.
|
||||||
*
|
*
|
||||||
* @see AdvancedAchievementsTable
|
* @see AdvancedAchievementsTable
|
||||||
@ -140,6 +139,11 @@ public enum AnalysisType {
|
|||||||
return modifier;
|
return modifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to get the Placeholder modifier.
|
||||||
|
*
|
||||||
|
* @return for example "_total"
|
||||||
|
*/
|
||||||
public String getPlaceholderModifier() {
|
public String getPlaceholderModifier() {
|
||||||
return placeholderModifier;
|
return placeholderModifier;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
|||||||
* Abstract class for easy hooking of plugins.
|
* Abstract class for easy hooking of plugins.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 2.6.0
|
||||||
*/
|
*/
|
||||||
public abstract class Hook {
|
public abstract class Hook {
|
||||||
|
|
||||||
@ -35,4 +36,13 @@ public abstract class Hook {
|
|||||||
public Hook() {
|
public Hook() {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the hooked plugin is enabled.
|
||||||
|
*
|
||||||
|
* @return true/false
|
||||||
|
*/
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,11 @@ import main.java.com.djrapitops.plan.data.additional.vault.VaultHook;
|
|||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class responsible for hooking to other plugins & managing the %plugins%
|
* Class responsible for hooking to other plugins and managing the %plugins%
|
||||||
* placeholder on Analysis & Inspect pages.
|
* placeholder on Analysis and Inspect pages.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 2.6.0
|
||||||
*/
|
*/
|
||||||
public class HookHandler {
|
public class HookHandler {
|
||||||
|
|
||||||
|
@ -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
|
* 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
|
* API-section of documentation has examples on the usage of this class and how
|
||||||
* register objects extending this class.
|
* to register objects extending this class.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
public abstract class PluginData {
|
public abstract class PluginData {
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ public abstract class PluginData {
|
|||||||
* Placeholder string, for example "stepsTaken". This will be used when
|
* Placeholder string, for example "stepsTaken". This will be used when
|
||||||
* building the structure of the Plugins tab.
|
* 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.
|
* run, a modifier.
|
||||||
*
|
*
|
||||||
* Second parameter of any super constructor.
|
* Second parameter of any super constructor.
|
||||||
@ -78,7 +79,7 @@ public abstract class PluginData {
|
|||||||
*
|
*
|
||||||
* Defaults analysisOnly to true.
|
* 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 sourcePlugin Name of the plugin the data is coming from
|
||||||
* @param placeholder Placeholder string, for example "stepsTaken"
|
* @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 sourcePlugin Name of the plugin the data is coming from
|
||||||
* @param placeholder Placeholder string, for example "stepsTaken"
|
* @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
|
* This method should be used with the return values of
|
||||||
* getHtmlReplaceValue(String, UUID).
|
* 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 ",
|
* Modifier is for example, if calculating AnalysisType.INT_AVG "Average ",
|
||||||
* it is a text that helps user understand that a calculation has been made.
|
* it is a text that helps user understand that a calculation has been made.
|
||||||
*
|
*
|
||||||
@ -147,13 +148,13 @@ public abstract class PluginData {
|
|||||||
* @see AnalysisType
|
* @see AnalysisType
|
||||||
*/
|
*/
|
||||||
public final String parseContainer(String modifier, String contents) {
|
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 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.
|
* other plugins.
|
||||||
*
|
*
|
||||||
* @param modifier Modifier determined by AnalysisType's
|
* @param modifier Modifier determined by AnalysisType's
|
||||||
@ -178,7 +179,7 @@ public abstract class PluginData {
|
|||||||
* Used to get the string for the html page.
|
* Used to get the string for the html page.
|
||||||
*
|
*
|
||||||
* parseContainer(modifierPrefix, value); should be used for all return
|
* 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
|
* This method is used when AnalysisType.HTML is set, or while getting the
|
||||||
* value for the inspect page.
|
* 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
|
* AnalysisType you have specified. If the AnalysisType's name has a BOOLEAN
|
||||||
* in it, Analysis will expect boolean values etc.
|
* 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.
|
* 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.
|
* 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.
|
* @param uuid UUID of the player the value belongs to.
|
||||||
* @return Long, Integer, Double, Boolean or String, return -1 if the player
|
* @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/
|
* @param iconName Icon's name http://fontawesome.io/icons/
|
||||||
*/
|
*/
|
||||||
public final void setIcon(String iconName) {
|
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.
|
* Used to get the prefix.
|
||||||
|
*
|
||||||
* @return example: "Steps Taken "
|
* @return example: "Steps Taken "
|
||||||
*/
|
*/
|
||||||
public final String getPrefix() {
|
public final String getPrefix() {
|
||||||
@ -269,6 +271,7 @@ public abstract class PluginData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to get the suffix.
|
* Used to get the suffix.
|
||||||
|
*
|
||||||
* @return example: " steps"
|
* @return example: " steps"
|
||||||
*/
|
*/
|
||||||
public final String getSuffix() {
|
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.
|
* analysisTypes, it is considired equal.
|
||||||
*
|
*
|
||||||
* @param obj Another Object.
|
* @param obj Another Object.
|
||||||
|
@ -7,13 +7,25 @@ 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.additional.PluginData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for AdvancedAchievements-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by AdvancedAchievementsHook.
|
||||||
|
*
|
||||||
|
* Gives the amount of achievements as value.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see AdvancedAchievementsHook
|
||||||
*/
|
*/
|
||||||
public class AdvancedAchievementsAchievements extends PluginData {
|
public class AdvancedAchievementsAchievements extends PluginData {
|
||||||
|
|
||||||
private AdvancedAchievementsAPI aaAPI;
|
private AdvancedAchievementsAPI aaAPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*
|
||||||
|
* @param aaAPI AdvancedAchievementsAPI given by AdvancedAchievementsHook
|
||||||
|
*/
|
||||||
public AdvancedAchievementsAchievements(AdvancedAchievementsAPI aaAPI) {
|
public AdvancedAchievementsAchievements(AdvancedAchievementsAPI aaAPI) {
|
||||||
super("AdvancedAchievements", "achievements", new AnalysisType[]{AnalysisType.INT_TOTAL, AnalysisType.INT_AVG});
|
super("AdvancedAchievements", "achievements", new AnalysisType[]{AnalysisType.INT_TOTAL, AnalysisType.INT_AVG});
|
||||||
this.aaAPI = aaAPI;
|
this.aaAPI = aaAPI;
|
||||||
|
@ -4,19 +4,29 @@ import main.java.com.djrapitops.plan.data.additional.Hook;
|
|||||||
import com.hm.achievement.AdvancedAchievements;
|
import com.hm.achievement.AdvancedAchievements;
|
||||||
import com.hm.achievement.api.AdvancedAchievementsAPI;
|
import com.hm.achievement.api.AdvancedAchievementsAPI;
|
||||||
import com.hm.achievement.api.AdvancedAchievementsBukkitAPI;
|
import com.hm.achievement.api.AdvancedAchievementsBukkitAPI;
|
||||||
|
import main.java.com.djrapitops.plan.api.API;
|
||||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A Class responsible for hooking to AdvancedAchievements and registering 2 data
|
||||||
|
* sources.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
public class AdvancedAchievementsHook extends Hook {
|
public class AdvancedAchievementsHook extends Hook {
|
||||||
|
|
||||||
private AdvancedAchievements aa;
|
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 {
|
public AdvancedAchievementsHook(HookHandler hookH) throws NoClassDefFoundError {
|
||||||
super("com.hm.achievement.AdvancedAchievements");
|
super("com.hm.achievement.AdvancedAchievements");
|
||||||
|
@ -14,13 +14,28 @@ import static org.bukkit.Bukkit.getOfflinePlayers;
|
|||||||
import org.bukkit.OfflinePlayer;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see AdvancedAchievementsHook
|
||||||
*/
|
*/
|
||||||
public class AdvancedAchievementsTable extends PluginData {
|
public class AdvancedAchievementsTable extends PluginData {
|
||||||
|
|
||||||
private AdvancedAchievementsAPI aaAPI;
|
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) {
|
public AdvancedAchievementsTable(AdvancedAchievementsAPI aaAPI) {
|
||||||
super("AdvancedAchievements", "achievementstable", AnalysisType.HTML);
|
super("AdvancedAchievements", "achievementstable", AnalysisType.HTML);
|
||||||
this.aaAPI = aaAPI;
|
this.aaAPI = aaAPI;
|
||||||
@ -36,7 +51,7 @@ public class AdvancedAchievementsTable extends PluginData {
|
|||||||
StringBuilder html = new StringBuilder();
|
StringBuilder html = new StringBuilder();
|
||||||
List<OfflinePlayer> offlinePlayers = Arrays.stream(getOfflinePlayers()).filter(p -> p.hasPlayedBefore()).collect(Collectors.toList());
|
List<OfflinePlayer> offlinePlayers = Arrays.stream(getOfflinePlayers()).filter(p -> p.hasPlayedBefore()).collect(Collectors.toList());
|
||||||
if (offlinePlayers.isEmpty()) {
|
if (offlinePlayers.isEmpty()) {
|
||||||
html.append(Html.TABLELINE_2.parse("No Players.",""));
|
html.append(Html.TABLELINE_2.parse("No Players.", ""));
|
||||||
} else {
|
} else {
|
||||||
for (OfflinePlayer p : offlinePlayers) {
|
for (OfflinePlayer p : offlinePlayers) {
|
||||||
String inspectUrl = HtmlUtils.getInspectUrl(p.getName());
|
String inspectUrl = HtmlUtils.getInspectUrl(p.getName());
|
||||||
|
@ -2,20 +2,28 @@ package main.java.com.djrapitops.plan.data.additional.essentials;
|
|||||||
|
|
||||||
import main.java.com.djrapitops.plan.data.additional.Hook;
|
import main.java.com.djrapitops.plan.data.additional.Hook;
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import main.java.com.djrapitops.plan.api.API;
|
||||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||||
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A Class responsible for hooking to Essentials and registering 3 data sources.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
public class EssentialsHook extends Hook {
|
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");
|
super("com.earth2me.essentials.Essentials");
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
Essentials ess = getPlugin(Essentials.class);
|
Essentials ess = getPlugin(Essentials.class);
|
||||||
|
@ -8,13 +8,25 @@ 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.additional.PluginData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Essentials-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by EssentialsHook
|
||||||
|
*
|
||||||
|
* Gives Jailed boolean value.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see EssentialsHook
|
||||||
*/
|
*/
|
||||||
public class EssentialsJailed extends PluginData {
|
public class EssentialsJailed extends PluginData {
|
||||||
|
|
||||||
private Essentials essentials;
|
private Essentials essentials;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*
|
||||||
|
* @param essentials Instance of Essentials plugin.
|
||||||
|
*/
|
||||||
public EssentialsJailed(Essentials essentials) {
|
public EssentialsJailed(Essentials essentials) {
|
||||||
super("Essentials", "jailed", AnalysisType.BOOLEAN_PERCENTAGE, AnalysisType.BOOLEAN_TOTAL);
|
super("Essentials", "jailed", AnalysisType.BOOLEAN_PERCENTAGE, AnalysisType.BOOLEAN_TOTAL);
|
||||||
this.essentials = essentials;
|
this.essentials = essentials;
|
||||||
@ -37,5 +49,5 @@ public class EssentialsJailed extends PluginData {
|
|||||||
User user = essentials.getUser(uuid);
|
User user = essentials.getUser(uuid);
|
||||||
return user != null && user.isJailed();
|
return user != null && user.isJailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,25 @@ 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.additional.PluginData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Essentials-plugin.
|
||||||
*
|
*
|
||||||
|
* Registered to the plugin by EssentialsHook
|
||||||
|
*
|
||||||
|
* Gives Muted boolean value.
|
||||||
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see EssentialsHook
|
||||||
*/
|
*/
|
||||||
public class EssentialsMuted extends PluginData {
|
public class EssentialsMuted extends PluginData {
|
||||||
|
|
||||||
private Essentials essentials;
|
private Essentials essentials;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*
|
||||||
|
* @param essentials Instance of Essentials plugin.
|
||||||
|
*/
|
||||||
public EssentialsMuted(Essentials essentials) {
|
public EssentialsMuted(Essentials essentials) {
|
||||||
super("Essentials", "muted", AnalysisType.BOOLEAN_PERCENTAGE, AnalysisType.BOOLEAN_TOTAL);
|
super("Essentials", "muted", AnalysisType.BOOLEAN_PERCENTAGE, AnalysisType.BOOLEAN_TOTAL);
|
||||||
this.essentials = essentials;
|
this.essentials = essentials;
|
||||||
@ -27,7 +39,7 @@ public class EssentialsMuted extends PluginData {
|
|||||||
public String getHtmlReplaceValue(String modifier, UUID uuid) {
|
public String getHtmlReplaceValue(String modifier, UUID uuid) {
|
||||||
User user = essentials.getUser(uuid);
|
User user = essentials.getUser(uuid);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
return parseContainer("", user.isMuted()? "Yes" : "No");
|
return parseContainer("", user.isMuted() ? "Yes" : "No");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -37,5 +49,5 @@ public class EssentialsMuted extends PluginData {
|
|||||||
User user = essentials.getUser(uuid);
|
User user = essentials.getUser(uuid);
|
||||||
return user != null && user.isMuted();
|
return user != null && user.isMuted();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,25 @@ 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.additional.PluginData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Essentials-plugin.
|
||||||
*
|
*
|
||||||
|
* Registered to the plugin by EssentialsHook
|
||||||
|
*
|
||||||
|
* Gives a list of warps as a String value.
|
||||||
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see EssentialsHook
|
||||||
*/
|
*/
|
||||||
public class EssentialsWarps extends PluginData {
|
public class EssentialsWarps extends PluginData {
|
||||||
|
|
||||||
private Essentials essentials;
|
private Essentials essentials;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*
|
||||||
|
* @param essentials Instance of Essentials plugin.
|
||||||
|
*/
|
||||||
public EssentialsWarps(Essentials essentials) {
|
public EssentialsWarps(Essentials essentials) {
|
||||||
super("Essentials", "warps", AnalysisType.HTML);
|
super("Essentials", "warps", AnalysisType.HTML);
|
||||||
this.essentials = essentials;
|
this.essentials = essentials;
|
||||||
|
@ -4,13 +4,18 @@ import com.massivecraft.factions.entity.Faction;
|
|||||||
import java.util.Comparator;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see FactionsHook
|
||||||
*/
|
*/
|
||||||
public class FactionComparator implements Comparator<Faction> {
|
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
|
@Override
|
||||||
public int compare(Faction fac1, Faction fac2) {
|
public int compare(Faction fac1, Faction fac2) {
|
||||||
if (fac1.getPower() > fac2.getPower()) {
|
if (fac1.getPower() > fac2.getPower()) {
|
||||||
|
@ -6,11 +6,21 @@ import java.util.UUID;
|
|||||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see FactionsHook
|
||||||
*/
|
*/
|
||||||
public class FactionsFaction extends PluginData {
|
public class FactionsFaction extends PluginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*/
|
||||||
public FactionsFaction() {
|
public FactionsFaction() {
|
||||||
super("Factions", "faction");
|
super("Factions", "faction");
|
||||||
super.setIcon("flag");
|
super.setIcon("flag");
|
||||||
|
@ -8,21 +8,28 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
import main.java.com.djrapitops.plan.Settings;
|
||||||
|
import main.java.com.djrapitops.plan.api.API;
|
||||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A Class responsible for hooking to Factions and registering 4 data sources.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
public class FactionsHook extends Hook {
|
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) {
|
public FactionsHook(HookHandler hookH) {
|
||||||
super("com.massivecraft.factions.Factions");
|
super("com.massivecraft.factions.Factions");
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
hookH.addPluginDataSource(new FactionsFaction());
|
hookH.addPluginDataSource(new FactionsFaction());
|
||||||
hookH.addPluginDataSource(new FactionsPower());
|
hookH.addPluginDataSource(new FactionsPower());
|
||||||
hookH.addPluginDataSource(new FactionsMaxPower());
|
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() {
|
public List<Faction> getTopFactions() {
|
||||||
List<Faction> topFactions = new ArrayList<>();
|
List<Faction> topFactions = new ArrayList<>();
|
||||||
|
@ -3,16 +3,25 @@ package main.java.com.djrapitops.plan.data.additional.factions;
|
|||||||
import com.massivecraft.factions.entity.MPlayer;
|
import com.massivecraft.factions.entity.MPlayer;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.UUID;
|
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.data.additional.PluginData;
|
||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see FactionsHook
|
||||||
*/
|
*/
|
||||||
public class FactionsMaxPower extends PluginData {
|
public class FactionsMaxPower extends PluginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*/
|
||||||
public FactionsMaxPower() {
|
public FactionsMaxPower() {
|
||||||
super("Factions", "maxpower");
|
super("Factions", "maxpower");
|
||||||
super.setPrefix("Max Power: ");
|
super.setPrefix("Max Power: ");
|
||||||
|
@ -8,11 +8,21 @@ import main.java.com.djrapitops.plan.data.additional.PluginData;
|
|||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see FactionsHook
|
||||||
*/
|
*/
|
||||||
public class FactionsPower extends PluginData {
|
public class FactionsPower extends PluginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*/
|
||||||
public FactionsPower() {
|
public FactionsPower() {
|
||||||
super("Factions", "power", AnalysisType.DOUBLE_AVG);
|
super("Factions", "power", AnalysisType.DOUBLE_AVG);
|
||||||
super.setAnalysisOnly(false);
|
super.setAnalysisOnly(false);
|
||||||
|
@ -12,13 +12,27 @@ import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
|||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Factions-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by FactionsHook
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see FactionsHook
|
||||||
*/
|
*/
|
||||||
public class FactionsTable extends PluginData {
|
public class FactionsTable extends PluginData {
|
||||||
|
|
||||||
private List<Faction> factions;
|
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) {
|
public FactionsTable(List<Faction> factions) {
|
||||||
super("Factions", "factionstable", AnalysisType.HTML);
|
super("Factions", "factionstable", AnalysisType.HTML);
|
||||||
this.factions = factions;
|
this.factions = factions;
|
||||||
|
@ -1,17 +1,25 @@
|
|||||||
package main.java.com.djrapitops.plan.data.additional.ontime;
|
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.Hook;
|
||||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A Class responsible for hooking to OnTime and registering 6 data sources.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
public class OnTimeHook extends Hook {
|
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 {
|
public OnTimeHook(HookHandler hookH) throws NoClassDefFoundError {
|
||||||
super("me.edge209.OnTime.OnTime");
|
super("me.edge209.OnTime.OnTime");
|
||||||
|
@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Ontime-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by OnTimeHook
|
||||||
|
*
|
||||||
|
* Gives Total Referral Integer as value.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see OnTimeHook
|
||||||
*/
|
*/
|
||||||
public class OntimeRefer extends PluginData {
|
public class OntimeRefer extends PluginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*/
|
||||||
public OntimeRefer() {
|
public OntimeRefer() {
|
||||||
super("OnTime", "refer", AnalysisType.INT_TOTAL, AnalysisType.INT_AVG);
|
super("OnTime", "refer", AnalysisType.INT_TOTAL, AnalysisType.INT_AVG);
|
||||||
super.setAnalysisOnly(false);
|
super.setAnalysisOnly(false);
|
||||||
|
@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Ontime-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by OnTimeHook
|
||||||
|
*
|
||||||
|
* Gives Months Referral Integer as value.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see OnTimeHook
|
||||||
*/
|
*/
|
||||||
public class OntimeReferMonth extends PluginData {
|
public class OntimeReferMonth extends PluginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*/
|
||||||
public OntimeReferMonth() {
|
public OntimeReferMonth() {
|
||||||
super("OnTime", "refer_30d", AnalysisType.INT_TOTAL);
|
super("OnTime", "refer_30d", AnalysisType.INT_TOTAL);
|
||||||
super.setAnalysisOnly(false);
|
super.setAnalysisOnly(false);
|
||||||
|
@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Ontime-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by OnTimeHook
|
||||||
|
*
|
||||||
|
* Gives Week's Referral Integer as value.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see OnTimeHook
|
||||||
*/
|
*/
|
||||||
public class OntimeReferWeek extends PluginData {
|
public class OntimeReferWeek extends PluginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*/
|
||||||
public OntimeReferWeek() {
|
public OntimeReferWeek() {
|
||||||
super("OnTime", "refer_7d", AnalysisType.INT_TOTAL);
|
super("OnTime", "refer_7d", AnalysisType.INT_TOTAL);
|
||||||
super.setAnalysisOnly(false);
|
super.setAnalysisOnly(false);
|
||||||
|
@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Ontime-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by OnTimeHook
|
||||||
|
*
|
||||||
|
* Gives Total Votes Integer as value.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see OnTimeHook
|
||||||
*/
|
*/
|
||||||
public class OntimeVotes extends PluginData {
|
public class OntimeVotes extends PluginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*/
|
||||||
public OntimeVotes() {
|
public OntimeVotes() {
|
||||||
super("OnTime", "votes", AnalysisType.INT_TOTAL, AnalysisType.INT_AVG);
|
super("OnTime", "votes", AnalysisType.INT_TOTAL, AnalysisType.INT_AVG);
|
||||||
super.setAnalysisOnly(false);
|
super.setAnalysisOnly(false);
|
||||||
|
@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Ontime-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by OnTimeHook
|
||||||
|
*
|
||||||
|
* Gives Month's Votes Integer as value.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see OnTimeHook
|
||||||
*/
|
*/
|
||||||
public class OntimeVotesMonth extends PluginData {
|
public class OntimeVotesMonth extends PluginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*/
|
||||||
public OntimeVotesMonth() {
|
public OntimeVotesMonth() {
|
||||||
super("OnTime", "votes_30d", AnalysisType.INT_TOTAL);
|
super("OnTime", "votes_30d", AnalysisType.INT_TOTAL);
|
||||||
super.setAnalysisOnly(false);
|
super.setAnalysisOnly(false);
|
||||||
|
@ -9,11 +9,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Ontime-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by OnTimeHook
|
||||||
|
*
|
||||||
|
* Gives Week's Votes Integer as value.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see OnTimeHook
|
||||||
*/
|
*/
|
||||||
public class OntimeVotesWeek extends PluginData {
|
public class OntimeVotesWeek extends PluginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*/
|
||||||
public OntimeVotesWeek() {
|
public OntimeVotesWeek() {
|
||||||
super("OnTime", "votes_7d", AnalysisType.INT_TOTAL);
|
super("OnTime", "votes_7d", AnalysisType.INT_TOTAL);
|
||||||
super.setAnalysisOnly(false);
|
super.setAnalysisOnly(false);
|
||||||
|
@ -4,8 +4,15 @@ import com.palmergames.bukkit.towny.object.Town;
|
|||||||
import java.util.Comparator;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see TownyHook
|
||||||
*/
|
*/
|
||||||
public class TownComparator implements Comparator<Town> {
|
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
|
* Note: this comparator imposes orderings that are inconsistent with
|
||||||
* equals.
|
* equals.
|
||||||
*
|
* @param tow1 Town 1
|
||||||
|
* @param tow2 Town 2
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int compare(Town tow1, Town tow2) {
|
public int compare(Town tow1, Town tow2) {
|
||||||
|
@ -7,30 +7,40 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import main.java.com.djrapitops.plan.Settings;
|
import main.java.com.djrapitops.plan.Settings;
|
||||||
|
import main.java.com.djrapitops.plan.api.API;
|
||||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A Class responsible for hooking to Towny and registering 2 data sources.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
public class TownyHook extends Hook {
|
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 {
|
public TownyHook(HookHandler hookH) throws NoClassDefFoundError {
|
||||||
super("com.palmergames.bukkit.towny.Towny");
|
super("com.palmergames.bukkit.towny.Towny");
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
hookH.addPluginDataSource(new TownyTable(getTopTowns()));
|
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();
|
List<Town> topTowns = TownyUniverse.getDataSource().getTowns();
|
||||||
Collections.sort(topTowns, new TownComparator());
|
Collections.sort(topTowns, new TownComparator());
|
||||||
List<String> hide = Settings.HIDE_TOWNS.getStringList();
|
List<String> hide = Settings.HIDE_TOWNS.getStringList();
|
||||||
|
@ -11,13 +11,27 @@ import main.java.com.djrapitops.plan.ui.Html;
|
|||||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Towny-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by TownyHook
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see TownyHook
|
||||||
*/
|
*/
|
||||||
public class TownyTable extends PluginData {
|
public class TownyTable extends PluginData {
|
||||||
|
|
||||||
private List<Town> towns;
|
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) {
|
public TownyTable(List<Town> towns) {
|
||||||
super("Towny", "townstable", AnalysisType.HTML);
|
super("Towny", "townstable", AnalysisType.HTML);
|
||||||
this.towns = towns;
|
this.towns = towns;
|
||||||
|
@ -11,11 +11,21 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Towny-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by TownyHook
|
||||||
|
*
|
||||||
|
* Gives Town name as String.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see TownyHook
|
||||||
*/
|
*/
|
||||||
public class TownyTown extends PluginData {
|
public class TownyTown extends PluginData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*/
|
||||||
public TownyTown() {
|
public TownyTown() {
|
||||||
super("Towny", "town");
|
super("Towny", "town");
|
||||||
super.setAnalysisOnly(false);
|
super.setAnalysisOnly(false);
|
||||||
|
@ -10,27 +10,39 @@ import static org.bukkit.Bukkit.getOfflinePlayer;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* PluginData class for Vault-plugin.
|
||||||
|
*
|
||||||
|
* Registered to the plugin by VaultHook
|
||||||
|
*
|
||||||
|
* Gives Total Balance Double as value.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
|
* @see VaultHook
|
||||||
*/
|
*/
|
||||||
public class EconomyBalance extends PluginData {
|
public class EconomyBalance extends PluginData {
|
||||||
|
|
||||||
private Economy econ;
|
private Economy econ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Constructor, sets the parameters of the PluginData object.
|
||||||
|
*
|
||||||
|
* @param econ Economy given by Vault.
|
||||||
|
*/
|
||||||
public EconomyBalance(Economy econ) {
|
public EconomyBalance(Economy econ) {
|
||||||
super("Vault", "balance", AnalysisType.DOUBLE_TOTAL, AnalysisType.DOUBLE_AVG);
|
super("Vault", "balance", AnalysisType.DOUBLE_TOTAL, AnalysisType.DOUBLE_AVG);
|
||||||
this.econ = econ;
|
this.econ = econ;
|
||||||
super.setAnalysisOnly(false);
|
super.setAnalysisOnly(false);
|
||||||
super.setIcon("money");
|
super.setIcon("money");
|
||||||
super.setPrefix("Balance: ");
|
super.setPrefix("Balance: ");
|
||||||
super.setSuffix(" "+FormatUtils.removeNumbers(econ.format(0)));
|
super.setSuffix(" " + FormatUtils.removeNumbers(econ.format(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||||
OfflinePlayer p = getOfflinePlayer(uuid);
|
OfflinePlayer p = getOfflinePlayer(uuid);
|
||||||
if (p.hasPlayedBefore()) {
|
if (p.hasPlayedBefore()) {
|
||||||
parseContainer(modifierPrefix, this.econ.getBalance(p)+"");
|
parseContainer(modifierPrefix, this.econ.getBalance(p) + "");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -1,39 +1,47 @@
|
|||||||
package main.java.com.djrapitops.plan.data.additional.vault;
|
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.Hook;
|
||||||
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
import main.java.com.djrapitops.plan.data.additional.HookHandler;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import static org.bukkit.Bukkit.getServer;
|
import static org.bukkit.Bukkit.getServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A Class responsible for hooking to Vault and registering 1 data source.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.1.0
|
||||||
*/
|
*/
|
||||||
public class VaultHook extends Hook {
|
public class VaultHook extends Hook {
|
||||||
|
|
||||||
private Economy econ;
|
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 {
|
public VaultHook(HookHandler hookH) throws NoClassDefFoundError {
|
||||||
super("net.milkbowl.vault.Vault");
|
super("net.milkbowl.vault.Vault");
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
|
this.econ = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
|
||||||
enabled = true;
|
enabled = true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hookH.addPluginDataSource(new EconomyBalance(econ));
|
hookH.addPluginDataSource(new EconomyBalance(econ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,11 @@ import main.java.com.djrapitops.plan.data.AnalysisData;
|
|||||||
import main.java.com.djrapitops.plan.utilities.Analysis;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public class AnalysisCacheHandler {
|
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.
|
* @return true if there is data in the cache.
|
||||||
*/
|
*/
|
||||||
public boolean isCached() {
|
public boolean isCached() {
|
||||||
|
@ -1,17 +1,25 @@
|
|||||||
|
|
||||||
package main.java.com.djrapitops.plan.data.cache;
|
package main.java.com.djrapitops.plan.data.cache;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 2.6.0
|
||||||
*/
|
*/
|
||||||
public abstract class DBCallableProcessor {
|
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);
|
public abstract void process(UserData data);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import java.util.Collections;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.Phrase;
|
import main.java.com.djrapitops.plan.Phrase;
|
||||||
@ -31,8 +32,18 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public class DataCacheHandler extends LocationCache {
|
public class DataCacheHandler extends LocationCache {
|
||||||
|
|
||||||
@ -57,8 +68,8 @@ public class DataCacheHandler extends LocationCache {
|
|||||||
/**
|
/**
|
||||||
* Class Constructor.
|
* Class Constructor.
|
||||||
*
|
*
|
||||||
* Creates the set of Handlers that will be used to modify UserData. Gets
|
* Gets the Database from the plugin. Starts the queues. Registers
|
||||||
* the Database from the plugin. Registers Asyncronous Periodic Save Task
|
* Asyncronous Periodic Save Task
|
||||||
*
|
*
|
||||||
* @param plugin Current instance of Plan
|
* @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() {
|
public boolean getCommandUseFromDb() {
|
||||||
try {
|
try {
|
||||||
commandUse = db.getCommandUse();
|
commandUse = db.getCommandUse();
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Used to start all processing Queue Threads.
|
||||||
*/
|
*/
|
||||||
public void startQueues() {
|
public void startQueues() {
|
||||||
clearTask = new DataCacheClearQueue(plugin, this);
|
clearTask = new DataCacheClearQueue(this);
|
||||||
saveTask = new DataCacheSaveQueue(plugin, clearTask);
|
saveTask = new DataCacheSaveQueue(plugin, clearTask);
|
||||||
getTask = new DataCacheGetQueue(plugin);
|
getTask = new DataCacheGetQueue(plugin);
|
||||||
processTask = new DataCacheProcessQueue(this);
|
processTask = new DataCacheProcessQueue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Used to start the Asyncronous Save Task.
|
||||||
*
|
*
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException BukkitRunnable was given wrong
|
||||||
* @throws IllegalStateException
|
* parameters.
|
||||||
|
* @throws IllegalStateException BukkitScheduler is in a wrong state.
|
||||||
*/
|
*/
|
||||||
public void startAsyncPeriodicSaveTask() throws IllegalArgumentException, IllegalStateException {
|
public void startAsyncPeriodicSaveTask() throws IllegalArgumentException, IllegalStateException {
|
||||||
int minutes = Settings.SAVE_CACHE_MIN.getNumber();
|
int minutes = Settings.SAVE_CACHE_MIN.getNumber();
|
||||||
@ -123,7 +137,7 @@ public class DataCacheHandler extends LocationCache {
|
|||||||
} else {
|
} else {
|
||||||
clearAfterXsaves = configValue;
|
clearAfterXsaves = configValue;
|
||||||
}
|
}
|
||||||
BukkitTask asyncPeriodicCacheSaveTask = (new BukkitRunnable() {
|
BukkitTask asyncPeriodicCacheSaveTask = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DataCacheHandler handler = Plan.getInstance().getHandler();
|
DataCacheHandler handler = Plan.getInstance().getHandler();
|
||||||
@ -135,22 +149,22 @@ public class DataCacheHandler extends LocationCache {
|
|||||||
saveCommandUse();
|
saveCommandUse();
|
||||||
timesSaved++;
|
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
|
* @param processor DBCallableProcessor Object used to process the data
|
||||||
* after it was retrieved
|
* after it was retrieved
|
||||||
* @param uuid Player's UUID
|
* @param uuid Player's UUID
|
||||||
* @param cache Wether or not the UserData will be Cached in this instance
|
* @param cache Whether or not the UserData will be Cached in this instance
|
||||||
* of DataCacheHandler
|
* of DataCacheHandler after it has been fetched (if not already fetched)
|
||||||
*/
|
*/
|
||||||
public void getUserDataForProcessing(DBCallableProcessor processor, UUID uuid, boolean cache) {
|
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);
|
UserData uData = dataCache.get(uuid);
|
||||||
if (uData == null) {
|
if (uData == null) {
|
||||||
if (cache) {
|
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) {
|
public void cache(UserData data) {
|
||||||
dataCache.put(data.getUuid(), data);
|
dataCache.put(data.getUuid(), data);
|
||||||
Log.info(Phrase.CACHE_ADD.parse(data.getUuid().toString()));
|
Log.info(Phrase.CACHE_ADD.parse(data.getUuid().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** Uses Database to retrieve the UserData of a matching player Caches the
|
* Uses Database or Cache to retrieve the UserData of a matching player.
|
||||||
* data to the HashMap
|
*
|
||||||
|
* Always Caches the data after retrieval (unless already cached)
|
||||||
*
|
*
|
||||||
* @param processor DBCallableProcessor Object used to process the data
|
* @param processor DBCallableProcessor Object used to process the data
|
||||||
* after it was retrieved
|
* 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
|
* Saves all UserData in the cache to Database.
|
||||||
* thread
|
*
|
||||||
|
* ATTENTION: TODO - Doesn't save the Locations in the locationCache.
|
||||||
|
*
|
||||||
|
* Should only be called from Async thread
|
||||||
*/
|
*/
|
||||||
public void saveCachedUserData() {
|
public void saveCachedUserData() {
|
||||||
List<UserData> data = new ArrayList<>();
|
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) {
|
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);
|
processTask.addToPool(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves all data in the cache to Database and closes the database down.
|
* 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() {
|
public void saveCacheOnDisable() {
|
||||||
long time = new Date().getTime();
|
long time = new Date().getTime();
|
||||||
@ -226,22 +257,16 @@ public class DataCacheHandler extends LocationCache {
|
|||||||
for (Player p : onlinePlayers) {
|
for (Player p : onlinePlayers) {
|
||||||
UUID uuid = p.getUniqueId();
|
UUID uuid = p.getUniqueId();
|
||||||
endSession(uuid);
|
endSession(uuid);
|
||||||
|
if (dataCache.containsKey(uuid)) {
|
||||||
|
dataCache.get(uuid).addLocations(getLocationsForSaving(uuid));
|
||||||
|
}
|
||||||
toProcess.add(new LogoutInfo(uuid, time, p.isBanned(), p.getGameMode(), getSession(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());
|
Log.debug("ToProcess size_AFTER: " + toProcess.size() + " DataCache size: " + dataCache.keySet().size());
|
||||||
Collections.sort(toProcess, new HandlingInfoTimeComparator());
|
Collections.sort(toProcess, new HandlingInfoTimeComparator());
|
||||||
processUnprocessedHandlingInfo(toProcess);
|
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<>();
|
List<UserData> data = new ArrayList<>();
|
||||||
data.addAll(dataCache.values());
|
data.addAll(dataCache.values());
|
||||||
// data.parallelStream()
|
|
||||||
// .forEach((userData) -> {
|
|
||||||
// addSession(userData);
|
|
||||||
// });
|
|
||||||
Log.debug("SAVING, DataCache size: " + dataCache.keySet().size());
|
Log.debug("SAVING, DataCache size: " + dataCache.keySet().size());
|
||||||
try {
|
try {
|
||||||
db.saveMultipleUserData(data);
|
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
|
* @param uuid Player's UUID
|
||||||
*/
|
*/
|
||||||
public void saveCachedData(UUID uuid) {
|
public void saveCachedData(UUID uuid) {
|
||||||
Log.debug(uuid+": SaveCachedData");
|
Log.debug(uuid + ": SaveCachedData");
|
||||||
DBCallableProcessor saveProcessor = new DBCallableProcessor() {
|
DBCallableProcessor saveProcessor = new DBCallableProcessor() {
|
||||||
@Override
|
@Override
|
||||||
public void process(UserData data) {
|
public void process(UserData data) {
|
||||||
data.addLocations(getLocationsForSaving(uuid));
|
data.addLocations(getLocationsForSaving(uuid));
|
||||||
clearLocations(uuid);
|
clearLocations(uuid);
|
||||||
// addSession(data);
|
|
||||||
data.access();
|
data.access();
|
||||||
data.setClearAfterSave(true);
|
data.setClearAfterSave(true);
|
||||||
saveTask.scheduleForSave(data);
|
saveTask.scheduleForSave(data);
|
||||||
// scheludeForClear(uuid);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
getUserDataForProcessing(saveProcessor, 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() {
|
public void saveCommandUse() {
|
||||||
try {
|
try {
|
||||||
@ -307,7 +330,7 @@ public class DataCacheHandler extends LocationCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Refreshes the calculations for all online players with ReloadInfo.
|
||||||
*/
|
*/
|
||||||
public void saveHandlerDataToCache() {
|
public void saveHandlerDataToCache() {
|
||||||
Bukkit.getServer().getOnlinePlayers().parallelStream().forEach((p) -> {
|
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() {
|
public void clearCache() {
|
||||||
clearTask.scheduleForClear(dataCache.keySet());
|
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
|
* @param uuid Player's UUID
|
||||||
*/
|
*/
|
||||||
public void clearFromCache(UUID uuid) {
|
public void clearFromCache(UUID uuid) {
|
||||||
Log.debug(uuid+": Clear");
|
Log.debug(uuid + ": Clear");
|
||||||
if (getOfflinePlayer(uuid).isOnline()) {
|
if (getOfflinePlayer(uuid).isOnline()) {
|
||||||
Log.debug(uuid+": Online, did not clear");
|
Log.debug(uuid + ": Online, did not clear");
|
||||||
UserData data = dataCache.get(uuid);
|
UserData data = dataCache.get(uuid);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
data.setClearAfterSave(false);
|
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) {
|
public void scheludeForClear(UUID uuid) {
|
||||||
clearTask.scheduleForClear(uuid);
|
clearTask.scheduleForClear(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Check whether or not the UserData object is being accessed by save or
|
||||||
|
* process tasks.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid Player's UUID
|
||||||
* @return
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public boolean isDataAccessed(UUID uuid) {
|
public boolean isDataAccessed(UUID uuid) {
|
||||||
UserData userData = dataCache.get(uuid);
|
UserData userData = dataCache.get(uuid);
|
||||||
if (userData == null) {
|
if (userData == null) {
|
||||||
return false;
|
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);
|
boolean isAccessed = (userData.isAccessed()) || saveTask.containsUUID(uuid) || processTask.containsUUID(uuid);
|
||||||
if (isAccessed) {
|
if (isAccessed) {
|
||||||
userData.setClearAfterSave(false);
|
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
|
* @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) {
|
public void newPlayer(OfflinePlayer player) {
|
||||||
newPlayer(NewPlayerCreator.createNewPlayer(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) {
|
public void newPlayer(UserData data) {
|
||||||
saveTask.scheduleNewPlayer(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
|
* @return The HashMap containing all Cached UserData
|
||||||
*/
|
*/
|
||||||
public HashMap<UUID, UserData> getDataCache() {
|
public HashMap<UUID, UserData> getDataCache() {
|
||||||
@ -407,28 +436,14 @@ public class DataCacheHandler extends LocationCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Current instance of the LocationHandler
|
* Used to get the cached commandUse.
|
||||||
*/
|
|
||||||
public LocationCache getLocationHandler() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
*
|
||||||
* @return
|
* @return Map with key:value - "/command":4
|
||||||
*/
|
*/
|
||||||
public HashMap<String, Integer> getCommandUse() {
|
public Map<String, Integer> getCommandUse() {
|
||||||
return commandUse;
|
return commandUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public SessionCache getSessionCache() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If /reload is run this treats every online player as a new login.
|
* 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) {
|
public void handleCommand(String command) {
|
||||||
if (!commandUse.containsKey(command)) {
|
if (!commandUse.containsKey(command)) {
|
||||||
|
@ -6,8 +6,10 @@ import main.java.com.djrapitops.plan.Plan;
|
|||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This class stores UserData objects used for displaying the Html pages.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public class InspectCacheHandler {
|
public class InspectCacheHandler {
|
||||||
|
|
||||||
@ -16,7 +18,7 @@ public class InspectCacheHandler {
|
|||||||
private HashMap<UUID, UserData> cache;
|
private HashMap<UUID, UserData> cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor.
|
||||||
*
|
*
|
||||||
* @param plugin Current instance of Plan.class
|
* @param plugin Current instance of Plan.class
|
||||||
*/
|
*/
|
||||||
@ -25,10 +27,14 @@ public class InspectCacheHandler {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.cache = new HashMap<>();
|
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) {
|
public void cache(UUID uuid) {
|
||||||
DBCallableProcessor cacher = new DBCallableProcessor() {
|
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
|
* @param uuid UUID of the Player
|
||||||
* @return UserData that matches the player, null if not cached.
|
* @return UserData that matches the player, null if not cached.
|
||||||
|
@ -8,16 +8,19 @@ import java.util.UUID;
|
|||||||
import org.bukkit.Location;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class LocationCache extends SessionCache{
|
public class LocationCache extends SessionCache {
|
||||||
|
|
||||||
private HashMap<UUID, List<Location>> locations;
|
private HashMap<UUID, List<Location>> locations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Constructor.
|
* Class Constructor.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public LocationCache() {
|
public LocationCache() {
|
||||||
super();
|
super();
|
||||||
@ -25,9 +28,10 @@ public class LocationCache extends SessionCache{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Add a location for a player to the list.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player.
|
||||||
* @param loc
|
* @param loc Location the player moved to.
|
||||||
*/
|
*/
|
||||||
public void addLocation(UUID uuid, Location loc) {
|
public void addLocation(UUID uuid, Location loc) {
|
||||||
if (!locations.containsKey(uuid)) {
|
if (!locations.containsKey(uuid)) {
|
||||||
@ -37,9 +41,10 @@ public class LocationCache extends SessionCache{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Add multiple locations to the list.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player.
|
||||||
* @param locs
|
* @param locs Locations the player moved to.
|
||||||
*/
|
*/
|
||||||
public void addLocations(UUID uuid, Collection<Location> locs) {
|
public void addLocations(UUID uuid, Collection<Location> locs) {
|
||||||
if (!locations.containsKey(uuid)) {
|
if (!locations.containsKey(uuid)) {
|
||||||
@ -47,11 +52,13 @@ public class LocationCache extends SessionCache{
|
|||||||
}
|
}
|
||||||
locations.get(uuid).addAll(locs);
|
locations.get(uuid).addAll(locs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the list of locations in the cache for saving the UserData object to
|
||||||
|
* Database.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player.
|
||||||
* @return
|
* @return List of locations the player has been at.
|
||||||
*/
|
*/
|
||||||
public List<Location> getLocationsForSaving(UUID uuid) {
|
public List<Location> getLocationsForSaving(UUID uuid) {
|
||||||
if (!locations.containsKey(uuid)) {
|
if (!locations.containsKey(uuid)) {
|
||||||
@ -59,10 +66,11 @@ public class LocationCache extends SessionCache{
|
|||||||
}
|
}
|
||||||
return locations.get(uuid);
|
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) {
|
public void clearLocations(UUID uuid) {
|
||||||
locations.remove(uuid);
|
locations.remove(uuid);
|
||||||
|
@ -1,68 +1,75 @@
|
|||||||
|
|
||||||
package main.java.com.djrapitops.plan.data.cache;
|
package main.java.com.djrapitops.plan.data.cache;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.data.SessionData;
|
import main.java.com.djrapitops.plan.data.SessionData;
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This class is used to store active sessions of players in memory.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class SessionCache {
|
public class SessionCache {
|
||||||
|
|
||||||
private final HashMap<UUID, SessionData> activeSessions;
|
private final HashMap<UUID, SessionData> activeSessions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class Constructor.
|
||||||
*/
|
*/
|
||||||
public SessionCache() {
|
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) {
|
public void startSession(UUID uuid) {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
Log.debug(uuid+": Starting a session: "+now);
|
Log.debug(uuid + ": Starting a session: " + now);
|
||||||
SessionData session = new SessionData(now);
|
SessionData session = new SessionData(now);
|
||||||
activeSessions.put(uuid, session);
|
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) {
|
public void endSession(UUID uuid) {
|
||||||
SessionData currentSession = activeSessions.get(uuid);
|
SessionData currentSession = activeSessions.get(uuid);
|
||||||
if (currentSession != null) {
|
if (currentSession != null) {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
Log.debug(uuid+": Ending a session: "+now);
|
Log.debug(uuid + ": Ending a session: " + now);
|
||||||
currentSession.endSession(now);
|
currentSession.endSession(now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Used to get the SessionData of the player in the sessionCache.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUId of the player.
|
||||||
* @return
|
* @return SessionData or null if not cached.
|
||||||
*/
|
*/
|
||||||
public SessionData getSession(UUID uuid) {
|
public SessionData getSession(UUID uuid) {
|
||||||
return activeSessions.get(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) {
|
public void addSession(UserData data) {
|
||||||
UUID uuid = data.getUuid();
|
UUID uuid = data.getUuid();
|
||||||
SessionData currentSession = activeSessions.get(uuid);
|
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)) {
|
if (currentSession != null && currentSession.isValid() && !data.getSessions().contains(currentSession)) {
|
||||||
data.addSession(currentSession);
|
data.addSession(currentSession);
|
||||||
activeSessions.remove(uuid);
|
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;
|
return activeSessions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,14 @@ import java.util.concurrent.ArrayBlockingQueue;
|
|||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import main.java.com.djrapitops.plan.Phrase;
|
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.Settings;
|
||||||
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This Class strats the Clear Queue Thread, that clears data from DataCache.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class DataCacheClearQueue {
|
public class DataCacheClearQueue {
|
||||||
|
|
||||||
@ -20,28 +21,30 @@ public class DataCacheClearQueue {
|
|||||||
private ClearSetup s;
|
private ClearSetup s;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class constructor, starts the new Thread for clearing.
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param handler current instance of DataCachehandler.
|
||||||
* @param handler
|
|
||||||
*/
|
*/
|
||||||
public DataCacheClearQueue(Plan plugin, DataCacheHandler handler) {
|
public DataCacheClearQueue(DataCacheHandler handler) {
|
||||||
q = new ArrayBlockingQueue(Settings.PROCESS_CLEAR_LIMIT.getNumber());
|
q = new ArrayBlockingQueue(Settings.PROCESS_CLEAR_LIMIT.getNumber());
|
||||||
s = new ClearSetup();
|
s = new ClearSetup();
|
||||||
s.go(q, handler);
|
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) {
|
public void scheduleForClear(UUID uuid) {
|
||||||
Log.debug(uuid+": Scheduling for clear");
|
Log.debug(uuid + ": Scheduling for clear");
|
||||||
q.add(uuid);
|
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) {
|
public void scheduleForClear(Collection<UUID> uuids) {
|
||||||
if (uuids.isEmpty()) {
|
if (uuids.isEmpty()) {
|
||||||
@ -56,7 +59,7 @@ public class DataCacheClearQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stops all activity and clears the queue.
|
||||||
*/
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
|
@ -16,8 +16,10 @@ import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
|
|||||||
import main.java.com.djrapitops.plan.database.Database;
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This Class is starts the Get Queue Thread, that fetches data from DataCache.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class DataCacheGetQueue {
|
public class DataCacheGetQueue {
|
||||||
|
|
||||||
@ -25,8 +27,9 @@ public class DataCacheGetQueue {
|
|||||||
private GetSetup s;
|
private GetSetup s;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class constructor, starts the new Thread for fetching.
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin current instance of Plan
|
||||||
*/
|
*/
|
||||||
public DataCacheGetQueue(Plan plugin) {
|
public DataCacheGetQueue(Plan plugin) {
|
||||||
q = new ArrayBlockingQueue(Settings.PROCESS_GET_LIMIT.getNumber());
|
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 uuid UUID of the player whose UserData object is fetched.
|
||||||
* @param processors
|
* @param processors Processors which process-method will be called after
|
||||||
|
* fetch is complete, with the UserData object.
|
||||||
*/
|
*/
|
||||||
public void scheduleForGet(UUID uuid, DBCallableProcessor... processors) {
|
public void scheduleForGet(UUID uuid, DBCallableProcessor... processors) {
|
||||||
Log.debug(uuid + ": Scheduling for get");
|
Log.debug(uuid + ": Scheduling for get");
|
||||||
@ -54,7 +59,7 @@ public class DataCacheGetQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Stops the activities and clears the queue.
|
||||||
*/
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
@ -98,7 +103,7 @@ class GetConsumer implements Runnable {
|
|||||||
}
|
}
|
||||||
List<DBCallableProcessor> processorsList = processors.get(uuid);
|
List<DBCallableProcessor> processorsList = processors.get(uuid);
|
||||||
if (processorsList != null) {
|
if (processorsList != null) {
|
||||||
Log.debug(uuid+ ": Get, For:" + processorsList.size());
|
Log.debug(uuid + ": Get, For:" + processorsList.size());
|
||||||
try {
|
try {
|
||||||
db.giveUserDataToProcessors(uuid, processorsList);
|
db.giveUserDataToProcessors(uuid, processorsList);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -14,8 +14,11 @@ import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
|||||||
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This Class is starts the Process Queue Thread, that processes HandlingInfo
|
||||||
|
* objects.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class DataCacheProcessQueue {
|
public class DataCacheProcessQueue {
|
||||||
|
|
||||||
@ -23,8 +26,9 @@ public class DataCacheProcessQueue {
|
|||||||
private ProcessSetup setup;
|
private ProcessSetup setup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class constructor, starts the new Thread for processing.
|
||||||
*
|
*
|
||||||
* @param handler
|
* @param handler current instance of DataCachehandler.
|
||||||
*/
|
*/
|
||||||
public DataCacheProcessQueue(DataCacheHandler handler) {
|
public DataCacheProcessQueue(DataCacheHandler handler) {
|
||||||
queue = new ArrayBlockingQueue(20000);
|
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) {
|
public void addToPool(HandlingInfo info) {
|
||||||
try {
|
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) {
|
public void addToPool(Collection<HandlingInfo> info) {
|
||||||
try {
|
try {
|
||||||
queue.addAll(info);
|
queue.addAll(info);
|
||||||
} catch (IllegalStateException e) {
|
} 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
|
* @param uuid UUID of the player.
|
||||||
* @return
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public boolean containsUUID(UUID uuid) {
|
public boolean containsUUID(UUID uuid) {
|
||||||
return new ArrayList<>(queue).stream().map(d -> d.getUuid()).collect(Collectors.toList()).contains(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() {
|
public List<HandlingInfo> stop() {
|
||||||
try {
|
try {
|
||||||
@ -109,7 +118,7 @@ class ProcessConsumer implements Runnable {
|
|||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.debug(info.getUuid()+": Processing type: " + info.getType().name());
|
Log.debug(info.getUuid() + ": Processing type: " + info.getType().name());
|
||||||
DBCallableProcessor p = new DBCallableProcessor() {
|
DBCallableProcessor p = new DBCallableProcessor() {
|
||||||
@Override
|
@Override
|
||||||
public void process(UserData data) {
|
public void process(UserData data) {
|
||||||
|
@ -15,8 +15,10 @@ import main.java.com.djrapitops.plan.data.UserData;
|
|||||||
import main.java.com.djrapitops.plan.database.Database;
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* This Class is starts the Save Queue Thread, that saves data to the Databse.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class DataCacheSaveQueue {
|
public class DataCacheSaveQueue {
|
||||||
|
|
||||||
@ -24,9 +26,11 @@ public class DataCacheSaveQueue {
|
|||||||
private SaveSetup s;
|
private SaveSetup s;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class constructor, starts the new Thread for saving.
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin current instance of Plan
|
||||||
* @param clear
|
* @param clear current instance of the Clear task to schedule clear if
|
||||||
|
* UserData.clearAfterSave() is true
|
||||||
*/
|
*/
|
||||||
public DataCacheSaveQueue(Plan plugin, DataCacheClearQueue clear) {
|
public DataCacheSaveQueue(Plan plugin, DataCacheClearQueue clear) {
|
||||||
q = new ArrayBlockingQueue(Settings.PROCESS_SAVE_LIMIT.getNumber());
|
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) {
|
public void scheduleForSave(UserData data) {
|
||||||
Log.debug(data.getUuid()+": Scheduling for save");
|
Log.debug(data.getUuid() + ": Scheduling for save");
|
||||||
try {
|
try {
|
||||||
q.add(data);
|
q.add(data);
|
||||||
} catch (IllegalStateException e) {
|
} 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) {
|
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 {
|
try {
|
||||||
q.addAll(data);
|
q.addAll(data);
|
||||||
} catch (IllegalStateException e) {
|
} 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) {
|
public void scheduleNewPlayer(UserData data) {
|
||||||
Log.debug(data.getUuid()+": Scheduling new Player");
|
Log.debug(data.getUuid() + ": Scheduling new Player");
|
||||||
try {
|
try {
|
||||||
q.add(data);
|
q.add(data);
|
||||||
} catch (IllegalStateException e) {
|
} 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
|
* @param uuid UUID of the player.
|
||||||
* @return
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public boolean containsUUID(UUID uuid) {
|
public boolean containsUUID(UUID uuid) {
|
||||||
return new ArrayList<>(q).stream().map(d -> d.getUuid()).collect(Collectors.toList()).contains(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() {
|
public void stop() {
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
@ -123,11 +131,11 @@ class SaveConsumer implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UUID uuid = data.getUuid();
|
UUID uuid = data.getUuid();
|
||||||
Log.debug(uuid+": Saving: "+uuid);
|
Log.debug(uuid + ": Saving: " + uuid);
|
||||||
try {
|
try {
|
||||||
db.saveUserData(uuid, data);
|
db.saveUserData(uuid, data);
|
||||||
data.stopAccessing();
|
data.stopAccessing();
|
||||||
Log.debug(uuid+": Saved!");
|
Log.debug(uuid + ": Saved!");
|
||||||
if (data.shouldClearAfterSave()) {
|
if (data.shouldClearAfterSave()) {
|
||||||
if (clear != null) {
|
if (clear != null) {
|
||||||
clear.scheduleForClear(uuid);
|
clear.scheduleForClear(uuid);
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -12,16 +7,21 @@ import main.java.com.djrapitops.plan.api.Gender;
|
|||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class containing static methods for processing information contained in a
|
||||||
|
* ChatEvent.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class ChatHandling {
|
public class ChatHandling {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Processes the information of the Event and changes UserData object
|
||||||
|
* accordingly.
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data UserData of the player.
|
||||||
* @param nickname
|
* @param nickname Nickname of the player during the event.
|
||||||
* @param msg
|
* @param msg Message sent by the player.
|
||||||
*/
|
*/
|
||||||
public static void processChatInfo(UserData data, String nickname, String msg) {
|
public static void processChatInfo(UserData data, String nickname, String msg) {
|
||||||
data.addNickname(nickname);
|
data.addNickname(nickname);
|
||||||
@ -29,9 +29,10 @@ public class ChatHandling {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Updates Demographics information according to various rules.
|
||||||
*
|
*
|
||||||
* @param msg
|
* @param msg Message sent by the player.
|
||||||
* @param data
|
* @param data UserData of the player.
|
||||||
*/
|
*/
|
||||||
public static void updateDemographicInformation(String msg, UserData data) {
|
public static void updateDemographicInformation(String msg, UserData data) {
|
||||||
List<String> triggers = Arrays.asList(Settings.DEM_TRIGGERS.toString().split(", "));
|
List<String> triggers = Arrays.asList(Settings.DEM_TRIGGERS.toString().split(", "));
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -10,22 +5,27 @@ import main.java.com.djrapitops.plan.data.UserData;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class containing static methods for processing information contained in a
|
||||||
|
* GamemodeChangeEvent.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class GamemodeHandling {
|
public class GamemodeHandling {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Processes the information of the Event and changes UserData object
|
||||||
|
* accordingly.
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data UserData of the player.
|
||||||
* @param time
|
* @param time Epoch ms the event occurred.
|
||||||
* @param newGM
|
* @param newGM The Gamemode the player changed to.
|
||||||
*/
|
*/
|
||||||
public static void processGamemodeInfo(UserData data, long time, GameMode newGM) {
|
public static void processGamemodeInfo(UserData data, long time, GameMode newGM) {
|
||||||
if (newGM == null) {
|
if (newGM == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMode lastGamemode = data.getLastGamemode();
|
GameMode lastGamemode = data.getLastGamemode();
|
||||||
if (lastGamemode == null) {
|
if (lastGamemode == null) {
|
||||||
data.setLastGamemode(newGM);
|
data.setLastGamemode(newGM);
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -15,17 +10,22 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class containing static methods for processing information contained in a
|
||||||
|
* DeathEvent when the killer is a player.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class KillHandling {
|
public class KillHandling {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Processes the information of the Event and changes UserData object
|
||||||
|
* accordingly.
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data UserData of the player.
|
||||||
* @param time
|
* @param time Epoch ms the event occurred.
|
||||||
* @param dead
|
* @param dead Mob or a Player the player killed.
|
||||||
* @param weaponName
|
* @param weaponName The name of the Weapon used.
|
||||||
*/
|
*/
|
||||||
public static void processKillInfo(UserData data, long time, LivingEntity dead, String weaponName) {
|
public static void processKillInfo(UserData data, long time, LivingEntity dead, String weaponName) {
|
||||||
Plan plugin = Plan.getInstance();
|
Plan plugin = Plan.getInstance();
|
||||||
@ -40,7 +40,7 @@ public class KillHandling {
|
|||||||
}
|
}
|
||||||
data.addPlayerKill(new KillData(victimUUID, victimID, weaponName, time));
|
data.addPlayerKill(new KillData(victimUUID, victimID, weaponName, time));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.toLog("main.java.com.djrapitops.plan.KillHandling", e);
|
Log.toLog("main.java.com.djrapitops.plan.KillHandling", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data.setMobKills(data.getMobKills() + 1);
|
data.setMobKills(data.getMobKills() + 1);
|
||||||
|
@ -9,19 +9,24 @@ import main.java.com.djrapitops.plan.data.DemographicsData;
|
|||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class containing static methods for processing information contained in a
|
||||||
|
* JoinEvent.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class LoginHandling {
|
public class LoginHandling {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Processes the information of the Event and changes UserData object
|
||||||
|
* accordingly.
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data UserData of the player.
|
||||||
* @param time
|
* @param time Epoch ms the event occurred.
|
||||||
* @param ip
|
* @param ip IP of the player
|
||||||
* @param banned
|
* @param banned Is the player banned
|
||||||
* @param nickname
|
* @param nickname Nickname of the player
|
||||||
* @param loginTimes
|
* @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) {
|
public static void processLoginInfo(UserData data, long time, InetAddress ip, boolean banned, String nickname, int loginTimes) {
|
||||||
data.setLastPlayed(time);
|
data.setLastPlayed(time);
|
||||||
@ -33,9 +38,12 @@ public class LoginHandling {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Updates the geolocation of the player.
|
||||||
*
|
*
|
||||||
* @param ip
|
* Uses free service of freegeoip.net. 10000 requests can be sent per hour.
|
||||||
* @param data
|
*
|
||||||
|
* @param ip InetAddress used for location.
|
||||||
|
* @param data UserData of the player.
|
||||||
*/
|
*/
|
||||||
public static void updateGeolocation(InetAddress ip, UserData data) {
|
public static void updateGeolocation(InetAddress ip, UserData data) {
|
||||||
DemographicsData demData = data.getDemData();
|
DemographicsData demData = data.getDemData();
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class containing static methods for processing information contained in a
|
||||||
|
* QuitEvent.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class LogoutHandling {
|
public class LogoutHandling {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Processes the information of the Event and changes UserData object
|
||||||
|
* accordingly.
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data UserData of the player.
|
||||||
* @param time
|
* @param time Epoch ms the event occurred.
|
||||||
* @param banned
|
* @param banned Is the player banned?
|
||||||
*/
|
*/
|
||||||
public static void processLogoutInfo(UserData data, long time, boolean banned) {
|
public static void processLogoutInfo(UserData data, long time, boolean banned) {
|
||||||
data.setPlayTime(data.getPlayTime() + (time - data.getLastPlayed()));
|
data.setPlayTime(data.getPlayTime() + (time - data.getLastPlayed()));
|
||||||
data.setLastPlayed(time);
|
data.setLastPlayed(time);
|
||||||
data.updateBanned(banned);
|
data.updateBanned(banned);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,22 @@ import main.java.com.djrapitops.plan.data.UserData;
|
|||||||
import main.java.com.djrapitops.plan.data.handling.ChatHandling;
|
import main.java.com.djrapitops.plan.data.handling.ChatHandling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* HandlingInfo Class for ChatEvent information.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class ChatInfo extends HandlingInfo {
|
public class ChatInfo extends HandlingInfo {
|
||||||
|
|
||||||
private String nickname;
|
private String nickname;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player.
|
||||||
* @param nickname
|
* @param nickname Nickname of the player.
|
||||||
* @param message
|
* @param message Message the player sent.
|
||||||
*/
|
*/
|
||||||
public ChatInfo(UUID uuid, String nickname, String message) {
|
public ChatInfo(UUID uuid, String nickname, String message) {
|
||||||
super(uuid, InfoType.CHAT, 0L);
|
super(uuid, InfoType.CHAT, 0L);
|
||||||
@ -24,27 +28,6 @@ public class ChatInfo extends HandlingInfo {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getNickname() {
|
|
||||||
return nickname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param uData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(UserData uData) {
|
public boolean process(UserData uData) {
|
||||||
if (!uData.getUuid().equals(uuid)) {
|
if (!uData.getUuid().equals(uuid)) {
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* HandlingInfo Class for DeathEvent information.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @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) {
|
public DeathInfo(UUID uuid) {
|
||||||
super(uuid, InfoType.DEATH, 0L);
|
super(uuid, InfoType.DEATH, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param uData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(UserData uData) {
|
public boolean process(UserData uData) {
|
||||||
if (!uData.getUuid().equals(uuid)) {
|
if (!uData.getUuid().equals(uuid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uData.setDeaths(uData.getDeaths()+1);
|
uData.setDeaths(uData.getDeaths() + 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -11,28 +6,27 @@ import main.java.com.djrapitops.plan.data.handling.GamemodeHandling;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* HandlingInfo Class for GamemodeChangeEvent information.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class GamemodeInfo extends HandlingInfo{
|
public class GamemodeInfo extends HandlingInfo {
|
||||||
|
|
||||||
private GameMode currentGamemode;
|
private GameMode currentGamemode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player.
|
||||||
* @param time
|
* @param time Epoch ms of the event.
|
||||||
* @param gm
|
* @param gm Gamemode the player changed to.
|
||||||
*/
|
*/
|
||||||
public GamemodeInfo(UUID uuid, long time, GameMode gm) {
|
public GamemodeInfo(UUID uuid, long time, GameMode gm) {
|
||||||
super(uuid, InfoType.GM, time);
|
super(uuid, InfoType.GM, time);
|
||||||
currentGamemode = gm;
|
currentGamemode = gm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param uData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(UserData uData) {
|
public boolean process(UserData uData) {
|
||||||
if (currentGamemode == null) {
|
if (currentGamemode == null) {
|
||||||
|
@ -4,8 +4,11 @@ import java.util.UUID;
|
|||||||
import main.java.com.djrapitops.plan.data.UserData;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public abstract class HandlingInfo {
|
public abstract class HandlingInfo {
|
||||||
|
|
||||||
@ -14,10 +17,12 @@ public abstract class HandlingInfo {
|
|||||||
long time;
|
long time;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Super Constructor.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player
|
||||||
* @param type
|
* @param type InfoType enum of the event. Only used for debugging different
|
||||||
* @param time
|
* types.
|
||||||
|
* @param time Epoch ms of the event.
|
||||||
*/
|
*/
|
||||||
public HandlingInfo(UUID uuid, InfoType type, long time) {
|
public HandlingInfo(UUID uuid, InfoType type, long time) {
|
||||||
this.uuid = uuid;
|
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() {
|
public UUID getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the InfoType.
|
||||||
*
|
*
|
||||||
* @return
|
* @return InfoType enum.
|
||||||
*/
|
*/
|
||||||
public InfoType getType() {
|
public InfoType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the epoch ms the event occurred.
|
||||||
*
|
*
|
||||||
* @return
|
* @return long in ms.
|
||||||
*/
|
*/
|
||||||
public long getTime() {
|
public long getTime() {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Process the info and modify the UserData object accordingly.
|
||||||
*
|
*
|
||||||
* @param uData
|
* If the UUIDs don't match no change should occur.
|
||||||
* @return
|
*
|
||||||
|
* @param uData UserData object to modify.
|
||||||
|
* @return UUID of the UserData object and HandlingInfo match.
|
||||||
*/
|
*/
|
||||||
public abstract boolean process(UserData uData);
|
public abstract boolean process(UserData uData);
|
||||||
}
|
}
|
||||||
|
@ -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;
|
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
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public enum InfoType {
|
public enum InfoType {
|
||||||
|
|
||||||
|
CHAT,
|
||||||
|
DEATH,
|
||||||
|
KILL,
|
||||||
|
GM,
|
||||||
|
LOGIN,
|
||||||
|
LOGOUT,
|
||||||
|
KICK,
|
||||||
|
RELOAD,
|
||||||
/**
|
/**
|
||||||
|
* Used for events registered with the API.
|
||||||
*
|
*
|
||||||
|
* @since 3.1.1
|
||||||
*/
|
*/
|
||||||
CHAT,
|
OTHER;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
DEATH,
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
KILL,
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
GM,
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
LOGIN,
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
LOGOUT,
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
KICK,
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
RELOAD
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import main.java.com.djrapitops.plan.data.UserData;
|
import main.java.com.djrapitops.plan.data.UserData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* HandlingInfo Class for KickEvent information.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class KickInfo extends HandlingInfo {
|
public class KickInfo extends HandlingInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the kicked player.
|
||||||
*/
|
*/
|
||||||
public KickInfo(UUID uuid) {
|
public KickInfo(UUID uuid) {
|
||||||
super(uuid, InfoType.KICK, 0L);
|
super(uuid, InfoType.KICK, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param uData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(UserData uData) {
|
public boolean process(UserData uData) {
|
||||||
if (!uData.getUuid().equals(uuid)) {
|
if (!uData.getUuid().equals(uuid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uData.setTimesKicked(uData.getTimesKicked()+1);
|
uData.setTimesKicked(uData.getTimesKicked() + 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -11,8 +6,11 @@ import main.java.com.djrapitops.plan.data.handling.KillHandling;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* HandlingInfo Class for DeathEvent information when the dead entity is a
|
||||||
|
* player.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class KillInfo extends HandlingInfo {
|
public class KillInfo extends HandlingInfo {
|
||||||
|
|
||||||
@ -20,11 +18,12 @@ public class KillInfo extends HandlingInfo {
|
|||||||
private String weaponName;
|
private String weaponName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the killer.
|
||||||
* @param time
|
* @param time Epoch ms the event occurred.
|
||||||
* @param dead
|
* @param dead Dead entity (Mob or Player)
|
||||||
* @param weaponName
|
* @param weaponName Weapon used.
|
||||||
*/
|
*/
|
||||||
public KillInfo(UUID uuid, long time, LivingEntity dead, String weaponName) {
|
public KillInfo(UUID uuid, long time, LivingEntity dead, String weaponName) {
|
||||||
super(uuid, InfoType.KILL, time);
|
super(uuid, InfoType.KILL, time);
|
||||||
@ -32,11 +31,6 @@ public class KillInfo extends HandlingInfo {
|
|||||||
this.weaponName = weaponName;
|
this.weaponName = weaponName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param uData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(UserData uData) {
|
public boolean process(UserData uData) {
|
||||||
if (!uData.getUuid().equals(uuid)) {
|
if (!uData.getUuid().equals(uuid)) {
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
@ -12,10 +7,13 @@ import main.java.com.djrapitops.plan.data.handling.LoginHandling;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* HandlingInfo Class for JoinEvent information.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class LoginInfo extends HandlingInfo{
|
public class LoginInfo extends HandlingInfo {
|
||||||
|
|
||||||
private InetAddress ip;
|
private InetAddress ip;
|
||||||
private boolean banned;
|
private boolean banned;
|
||||||
private String nickname;
|
private String nickname;
|
||||||
@ -23,14 +21,15 @@ public class LoginInfo extends HandlingInfo{
|
|||||||
private int loginTimes;
|
private int loginTimes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player.
|
||||||
* @param time
|
* @param time Epoch ms of the event.
|
||||||
* @param ip
|
* @param ip IP of the player
|
||||||
* @param banned
|
* @param banned Is the player banned?
|
||||||
* @param nickname
|
* @param nickname Nickname of the player
|
||||||
* @param gm
|
* @param gm current gamemode of the player
|
||||||
* @param loginTimes
|
* @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) {
|
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm, int loginTimes) {
|
||||||
super(uuid, InfoType.LOGIN, time);
|
super(uuid, InfoType.LOGIN, time);
|
||||||
@ -40,25 +39,21 @@ public class LoginInfo extends HandlingInfo{
|
|||||||
this.gmInfo = new GamemodeInfo(uuid, time, gm);
|
this.gmInfo = new GamemodeInfo(uuid, time, gm);
|
||||||
this.loginTimes = loginTimes;
|
this.loginTimes = loginTimes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor for not incrementing the loginTimes.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player.
|
||||||
* @param time
|
* @param time Epoch ms of the event.
|
||||||
* @param ip
|
* @param ip IP of the player
|
||||||
* @param banned
|
* @param banned Is the player banned?
|
||||||
* @param nickname
|
* @param nickname Nickname of the player
|
||||||
* @param gm
|
* @param gm current gamemode of the player
|
||||||
*/
|
*/
|
||||||
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm) {
|
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm) {
|
||||||
this(uuid, time, ip, banned, nickname, gm, 0);
|
this(uuid, time, ip, banned, nickname, gm, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param uData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(UserData uData) {
|
public boolean process(UserData uData) {
|
||||||
if (!uData.getUuid().equals(uuid)) {
|
if (!uData.getUuid().equals(uuid)) {
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -12,8 +7,10 @@ import main.java.com.djrapitops.plan.data.handling.LogoutHandling;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* HandlingInfo Class for QuitEvent information.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class LogoutInfo extends HandlingInfo {
|
public class LogoutInfo extends HandlingInfo {
|
||||||
|
|
||||||
@ -22,12 +19,14 @@ public class LogoutInfo extends HandlingInfo {
|
|||||||
private GamemodeInfo gmInfo;
|
private GamemodeInfo gmInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player.
|
||||||
* @param time
|
* @param time Epoch ms of the event.
|
||||||
* @param banned
|
* @param banned Is the player banned
|
||||||
* @param gm
|
* @param gm current gamemode of the player
|
||||||
* @param sData
|
* @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) {
|
public LogoutInfo(UUID uuid, long time, boolean banned, GameMode gm, SessionData sData) {
|
||||||
super(uuid, InfoType.LOGOUT, time);
|
super(uuid, InfoType.LOGOUT, time);
|
||||||
@ -36,11 +35,6 @@ public class LogoutInfo extends HandlingInfo {
|
|||||||
this.gmInfo = new GamemodeInfo(uuid, time, gm);
|
this.gmInfo = new GamemodeInfo(uuid, time, gm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param uData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(UserData uData) {
|
public boolean process(UserData uData) {
|
||||||
if (!uData.getUuid().equals(uuid)) {
|
if (!uData.getUuid().equals(uuid)) {
|
||||||
|
@ -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;
|
package main.java.com.djrapitops.plan.data.handling.info;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
@ -12,8 +7,10 @@ import main.java.com.djrapitops.plan.data.handling.LoginHandling;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* HandlingInfo Class for refreshing data in the cache for online players.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class ReloadInfo extends HandlingInfo {
|
public class ReloadInfo extends HandlingInfo {
|
||||||
|
|
||||||
@ -23,13 +20,14 @@ public class ReloadInfo extends HandlingInfo {
|
|||||||
private GamemodeInfo gmInfo;
|
private GamemodeInfo gmInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param uuid
|
* @param uuid UUID of the player.
|
||||||
* @param time
|
* @param time Epoch ms of the event.
|
||||||
* @param ip
|
* @param ip IP of the player
|
||||||
* @param banned
|
* @param banned Is the player banned?
|
||||||
* @param nickname
|
* @param nickname Nickname of the player
|
||||||
* @param gm
|
* @param gm current gamemode of the player
|
||||||
*/
|
*/
|
||||||
public ReloadInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm) {
|
public ReloadInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm) {
|
||||||
super(uuid, InfoType.RELOAD, time);
|
super(uuid, InfoType.RELOAD, time);
|
||||||
@ -39,18 +37,13 @@ public class ReloadInfo extends HandlingInfo {
|
|||||||
gmInfo = new GamemodeInfo(uuid, time, gm);
|
gmInfo = new GamemodeInfo(uuid, time, gm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param uData
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(UserData uData) {
|
public boolean process(UserData uData) {
|
||||||
if (!uData.getUuid().equals(uuid)) {
|
if (!uData.getUuid().equals(uuid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uData.setPlayTime(uData.getPlayTime() + (time - uData.getLastPlayed()));
|
uData.setPlayTime(uData.getPlayTime() + (time - uData.getLastPlayed()));
|
||||||
uData.setLastPlayed(time);
|
uData.setLastPlayed(time);
|
||||||
uData.updateBanned(banned);
|
uData.updateBanned(banned);
|
||||||
uData.addIpAddress(ip);
|
uData.addIpAddress(ip);
|
||||||
uData.addNickname(nickname);
|
uData.addNickname(nickname);
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Event Listener for AsyncPlayerChatEvents.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Event Listener for PlayerCommandPreprocessEvents.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Event Listener for EntityDeathEvents.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@ -23,8 +24,9 @@ public class PlanDeathEventListener implements Listener {
|
|||||||
private final DataCacheHandler handler;
|
private final DataCacheHandler handler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class Constructor.
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin Current instance of Plan
|
||||||
*/
|
*/
|
||||||
public PlanDeathEventListener(Plan plugin) {
|
public PlanDeathEventListener(Plan plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Event Listener for PlayerGameModeChangeEvents.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@ -27,7 +28,7 @@ public class PlanGamemodeChangeListener implements Listener {
|
|||||||
public PlanGamemodeChangeListener(Plan plugin) {
|
public PlanGamemodeChangeListener(Plan plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
handler = plugin.getHandler();
|
handler = plugin.getHandler();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,6 +21,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Event Listener for PlayerJoin, PlayerQuit and PlayerKickEvents.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@ -55,8 +56,8 @@ public class PlanPlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
handler.startSession(uuid);
|
handler.startSession(uuid);
|
||||||
Log.debug(uuid+": PlayerJoinEvent");
|
Log.debug(uuid + ": PlayerJoinEvent");
|
||||||
BukkitTask asyncNewPlayerCheckTask = (new BukkitRunnable() {
|
BukkitTask asyncNewPlayerCheckTask = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
LoginInfo loginInfo = new LoginInfo(uuid, new Date().getTime(), player.getAddress().getAddress(), player.isBanned(), player.getDisplayName(), player.getGameMode(), 1);
|
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 {
|
} else {
|
||||||
handler.addToPool(loginInfo);
|
handler.addToPool(loginInfo);
|
||||||
}
|
}
|
||||||
Log.debug(uuid+": PlayerJoinEvent_AsyncTask_END, New:"+isNewPlayer);
|
Log.debug(uuid + ": PlayerJoinEvent_AsyncTask_END, New:" + isNewPlayer);
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
}).runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
Log.debug(uuid+": PlayerJoinEvent_END");
|
Log.debug(uuid + ": PlayerJoinEvent_END");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,10 +89,10 @@ public class PlanPlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
handler.endSession(uuid);
|
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.addToPool(new LogoutInfo(uuid, new Date().getTime(), player.isBanned(), player.getGameMode(), handler.getSession(uuid)));
|
||||||
handler.saveCachedData(uuid);
|
handler.saveCachedData(uuid);
|
||||||
Log.debug(uuid+": PlayerQuitEvent_END");
|
Log.debug(uuid + ": PlayerQuitEvent_END");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Event Listener for PlayerMoveEvents.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Abstract class representing a Database.
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@ -18,18 +19,22 @@ public abstract class Database {
|
|||||||
private final Plan plugin;
|
private final Plan plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Super constructor.
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin current instance of Plan.
|
||||||
*/
|
*/
|
||||||
public Database(Plan plugin) {
|
public Database(Plan plugin) {
|
||||||
this.plugin = 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +109,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return @throws SQLException
|
||||||
* @throws SQLException
|
|
||||||
*/
|
*/
|
||||||
public abstract int getVersion() throws SQLException;
|
public abstract int getVersion() throws SQLException;
|
||||||
|
|
||||||
@ -132,8 +136,7 @@ public abstract class Database {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return @throws SQLException
|
||||||
* @throws SQLException
|
|
||||||
*/
|
*/
|
||||||
public abstract boolean removeAllData() throws SQLException;
|
public abstract boolean removeAllData() throws SQLException;
|
||||||
|
|
||||||
@ -147,15 +150,13 @@ public abstract class Database {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return @throws SQLException
|
||||||
* @throws SQLException
|
|
||||||
*/
|
*/
|
||||||
public abstract Set<UUID> getSavedUUIDs() throws SQLException;
|
public abstract Set<UUID> getSavedUUIDs() throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return
|
* @return @throws SQLException
|
||||||
* @throws SQLException
|
|
||||||
*/
|
*/
|
||||||
public abstract HashMap<String, Integer> getCommandUse() throws SQLException;
|
public abstract HashMap<String, Integer> getCommandUse() throws SQLException;
|
||||||
|
|
||||||
|
@ -136,10 +136,18 @@ public abstract class SQLDB extends Database {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public Table[] getAllTables() {
|
public Table[] getAllTables() {
|
||||||
return new Table[]{usersTable, locationsTable, gmTimesTable, ipsTable, nicknamesTable, sessionsTable, killsTable, commandUseTable};
|
return new Table[]{usersTable, locationsTable, gmTimesTable, ipsTable, nicknamesTable, sessionsTable, killsTable, commandUseTable};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public Table[] getAllTablesInRemoveOrder() {
|
public Table[] getAllTablesInRemoveOrder() {
|
||||||
return new Table[]{locationsTable, gmTimesTable, ipsTable, nicknamesTable, sessionsTable, killsTable, usersTable, commandUseTable};
|
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);
|
return getLocations(Integer.parseInt(userId), worlds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @param worlds
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public List<Location> getLocations(int userId, HashMap<String, World> worlds) throws SQLException {
|
public List<Location> getLocations(int userId, HashMap<String, World> worlds) throws SQLException {
|
||||||
return locationsTable.getLocations(userId, worlds);
|
return locationsTable.getLocations(userId, worlds);
|
||||||
@ -535,34 +551,66 @@ public abstract class SQLDB extends Database {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public UsersTable getUsersTable() {
|
public UsersTable getUsersTable() {
|
||||||
return usersTable;
|
return usersTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public SessionsTable getSessionsTable() {
|
public SessionsTable getSessionsTable() {
|
||||||
return sessionsTable;
|
return sessionsTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public GMTimesTable getGmTimesTable() {
|
public GMTimesTable getGmTimesTable() {
|
||||||
return gmTimesTable;
|
return gmTimesTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public KillsTable getKillsTable() {
|
public KillsTable getKillsTable() {
|
||||||
return killsTable;
|
return killsTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public LocationsTable getLocationsTable() {
|
public LocationsTable getLocationsTable() {
|
||||||
return locationsTable;
|
return locationsTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public IPsTable getIpsTable() {
|
public IPsTable getIpsTable() {
|
||||||
return ipsTable;
|
return ipsTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public NicknamesTable getNicknamesTable() {
|
public NicknamesTable getNicknamesTable() {
|
||||||
return nicknamesTable;
|
return nicknamesTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public CommandUseTable getCommandUseTable() {
|
public CommandUseTable getCommandUseTable() {
|
||||||
return commandUseTable;
|
return commandUseTable;
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,21 @@ public class CommandUseTable extends Table {
|
|||||||
private final String columnCommand;
|
private final String columnCommand;
|
||||||
private final String columnTimesUsed;
|
private final String columnTimesUsed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param db
|
||||||
|
* @param usingMySQL
|
||||||
|
*/
|
||||||
public CommandUseTable(SQLDB db, boolean usingMySQL) {
|
public CommandUseTable(SQLDB db, boolean usingMySQL) {
|
||||||
super("plan_commandusages", db, usingMySQL);
|
super("plan_commandusages", db, usingMySQL);
|
||||||
columnCommand = "command";
|
columnCommand = "command";
|
||||||
columnTimesUsed = "times_used";
|
columnTimesUsed = "times_used";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createTable() {
|
public boolean createTable() {
|
||||||
try {
|
try {
|
||||||
@ -37,6 +46,11 @@ public class CommandUseTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public HashMap<String, Integer> getCommandUse() throws SQLException {
|
public HashMap<String, Integer> getCommandUse() throws SQLException {
|
||||||
HashMap<String, Integer> commandUse = new HashMap<>();
|
HashMap<String, Integer> commandUse = new HashMap<>();
|
||||||
PreparedStatement statement = null;
|
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 {
|
public void saveCommandUse(HashMap<String, Integer> data) throws SQLException, NullPointerException {
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -21,6 +21,11 @@ public class GMTimesTable extends Table {
|
|||||||
private final String columnAdventureTime;
|
private final String columnAdventureTime;
|
||||||
private final String columnSpectatorTime;
|
private final String columnSpectatorTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param db
|
||||||
|
* @param usingMySQL
|
||||||
|
*/
|
||||||
public GMTimesTable(SQLDB db, boolean usingMySQL) {
|
public GMTimesTable(SQLDB db, boolean usingMySQL) {
|
||||||
super("plan_gamemodetimes", db, usingMySQL);
|
super("plan_gamemodetimes", db, usingMySQL);
|
||||||
columnUserID = "user_id";
|
columnUserID = "user_id";
|
||||||
@ -30,6 +35,10 @@ public class GMTimesTable extends Table {
|
|||||||
columnSpectatorTime = "spectator";
|
columnSpectatorTime = "spectator";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createTable() {
|
public boolean createTable() {
|
||||||
UsersTable usersTable = db.getUsersTable();
|
UsersTable usersTable = db.getUsersTable();
|
||||||
@ -50,6 +59,11 @@ public class GMTimesTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean removeUserGMTimes(int userId) {
|
public boolean removeUserGMTimes(int userId) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -65,6 +79,12 @@ public class GMTimesTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public HashMap<GameMode, Long> getGMTimes(int userId) throws SQLException {
|
public HashMap<GameMode, Long> getGMTimes(int userId) throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = 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 {
|
public void saveGMTimes(int userId, Map<GameMode, Long> gamemodeTimes) throws SQLException {
|
||||||
if (gamemodeTimes == null || gamemodeTimes.isEmpty()) {
|
if (gamemodeTimes == null || gamemodeTimes.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -20,12 +20,21 @@ public class IPsTable extends Table {
|
|||||||
private final String columnUserID;
|
private final String columnUserID;
|
||||||
private final String columnIP;
|
private final String columnIP;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param db
|
||||||
|
* @param usingMySQL
|
||||||
|
*/
|
||||||
public IPsTable(SQLDB db, boolean usingMySQL) {
|
public IPsTable(SQLDB db, boolean usingMySQL) {
|
||||||
super("plan_ips", db, usingMySQL);
|
super("plan_ips", db, usingMySQL);
|
||||||
columnUserID = "user_id";
|
columnUserID = "user_id";
|
||||||
columnIP = "ip";
|
columnIP = "ip";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createTable() {
|
public boolean createTable() {
|
||||||
UsersTable usersTable = db.getUsersTable();
|
UsersTable usersTable = db.getUsersTable();
|
||||||
@ -43,6 +52,11 @@ public class IPsTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean removeUserIps(int userId) {
|
public boolean removeUserIps(int userId) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -58,6 +72,12 @@ public class IPsTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public List<InetAddress> getIPAddresses(int userId) throws SQLException {
|
public List<InetAddress> getIPAddresses(int userId) throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = 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 {
|
public void saveIPList(int userId, Set<InetAddress> ips) throws SQLException {
|
||||||
if (ips == null) {
|
if (ips == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -21,6 +21,11 @@ public class KillsTable extends Table {
|
|||||||
private final String columnWeapon;
|
private final String columnWeapon;
|
||||||
private final String columnDate;
|
private final String columnDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param db
|
||||||
|
* @param usingMySQL
|
||||||
|
*/
|
||||||
public KillsTable(SQLDB db, boolean usingMySQL) {
|
public KillsTable(SQLDB db, boolean usingMySQL) {
|
||||||
super("plan_kills", db, usingMySQL);
|
super("plan_kills", db, usingMySQL);
|
||||||
columnWeapon = "weapon";
|
columnWeapon = "weapon";
|
||||||
@ -29,6 +34,10 @@ public class KillsTable extends Table {
|
|||||||
columnVictimUserID = "victim_id";
|
columnVictimUserID = "victim_id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createTable() {
|
public boolean createTable() {
|
||||||
UsersTable usersTable = db.getUsersTable();
|
UsersTable usersTable = db.getUsersTable();
|
||||||
@ -49,6 +58,11 @@ public class KillsTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean removeUserKillsAndVictims(int userId) {
|
public boolean removeUserKillsAndVictims(int userId) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -65,6 +79,12 @@ public class KillsTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public List<KillData> getPlayerKills(int userId) throws SQLException {
|
public List<KillData> getPlayerKills(int userId) throws SQLException {
|
||||||
UsersTable usersTable = db.getUsersTable();
|
UsersTable usersTable = db.getUsersTable();
|
||||||
PreparedStatement statement = null;
|
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 {
|
public void savePlayerKills(int userId, List<KillData> kills) throws SQLException {
|
||||||
if (kills == null) {
|
if (kills == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -23,6 +23,11 @@ public class LocationsTable extends Table {
|
|||||||
private final String columnCoordinatesZ;
|
private final String columnCoordinatesZ;
|
||||||
private final String columnWorld;
|
private final String columnWorld;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param db
|
||||||
|
* @param usingMySQL
|
||||||
|
*/
|
||||||
public LocationsTable(SQLDB db, boolean usingMySQL) {
|
public LocationsTable(SQLDB db, boolean usingMySQL) {
|
||||||
super("plan_locations", db, usingMySQL);
|
super("plan_locations", db, usingMySQL);
|
||||||
columnID = "id";
|
columnID = "id";
|
||||||
@ -32,6 +37,10 @@ public class LocationsTable extends Table {
|
|||||||
columnWorld = "world_name";
|
columnWorld = "world_name";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createTable() {
|
public boolean createTable() {
|
||||||
UsersTable usersTable = db.getUsersTable();
|
UsersTable usersTable = db.getUsersTable();
|
||||||
@ -53,6 +62,11 @@ public class LocationsTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean removeUserLocations(int userId) {
|
public boolean removeUserLocations(int userId) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
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 {
|
public List<Location> getLocations(int userId, HashMap<String, World> worlds) throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = 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 {
|
public void saveAdditionalLocationsList(int userId, List<Location> locations) throws SQLException {
|
||||||
if (locations == null || locations.isEmpty()) {
|
if (locations == null || locations.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -19,6 +19,11 @@ public class NicknamesTable extends Table {
|
|||||||
private final String columnNick;
|
private final String columnNick;
|
||||||
private final String columnCurrent;
|
private final String columnCurrent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param db
|
||||||
|
* @param usingMySQL
|
||||||
|
*/
|
||||||
public NicknamesTable(SQLDB db, boolean usingMySQL) {
|
public NicknamesTable(SQLDB db, boolean usingMySQL) {
|
||||||
super("plan_nicknames", db, usingMySQL);
|
super("plan_nicknames", db, usingMySQL);
|
||||||
columnUserID = "user_id";
|
columnUserID = "user_id";
|
||||||
@ -26,6 +31,10 @@ public class NicknamesTable extends Table {
|
|||||||
columnCurrent = "current_nick";
|
columnCurrent = "current_nick";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createTable() {
|
public boolean createTable() {
|
||||||
UsersTable usersTable = db.getUsersTable();
|
UsersTable usersTable = db.getUsersTable();
|
||||||
@ -61,6 +70,11 @@ public class NicknamesTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean removeUserNicknames(int userId) {
|
public boolean removeUserNicknames(int userId) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -76,6 +90,12 @@ public class NicknamesTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public List<String> getNicknames(int userId) throws SQLException {
|
public List<String> getNicknames(int userId) throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = 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 {
|
public void saveNickList(int userId, Set<String> names, String lastNick) throws SQLException {
|
||||||
if (names == null || names.isEmpty()) {
|
if (names == null || names.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -19,6 +19,11 @@ public class SessionsTable extends Table {
|
|||||||
private final String columnSessionStart;
|
private final String columnSessionStart;
|
||||||
private final String columnSessionEnd;
|
private final String columnSessionEnd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param db
|
||||||
|
* @param usingMySQL
|
||||||
|
*/
|
||||||
public SessionsTable(SQLDB db, boolean usingMySQL) {
|
public SessionsTable(SQLDB db, boolean usingMySQL) {
|
||||||
super("plan_sessions", db, usingMySQL);
|
super("plan_sessions", db, usingMySQL);
|
||||||
columnUserID = "user_id";
|
columnUserID = "user_id";
|
||||||
@ -26,6 +31,10 @@ public class SessionsTable extends Table {
|
|||||||
columnSessionEnd = "session_end";
|
columnSessionEnd = "session_end";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createTable() {
|
public boolean createTable() {
|
||||||
try {
|
try {
|
||||||
@ -44,6 +53,12 @@ public class SessionsTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public List<SessionData> getSessionData(int userId) throws SQLException {
|
public List<SessionData> getSessionData(int userId) throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
@ -64,6 +79,11 @@ public class SessionsTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean removeUserSessions(int userId) {
|
public boolean removeUserSessions(int userId) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
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 {
|
public void saveSessionData(int userId, List<SessionData> sessions) throws SQLException {
|
||||||
if (sessions == null) {
|
if (sessions == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -12,18 +12,44 @@ import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
|||||||
*/
|
*/
|
||||||
public abstract class Table {
|
public abstract class Table {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected String tableName;
|
protected String tableName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected SQLDB db;
|
protected SQLDB db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected boolean usingMySQL;
|
protected boolean usingMySQL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* @param db
|
||||||
|
* @param usingMySQL
|
||||||
|
*/
|
||||||
public Table(String name, SQLDB db, boolean usingMySQL) {
|
public Table(String name, SQLDB db, boolean usingMySQL) {
|
||||||
this.tableName = name;
|
this.tableName = name;
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.usingMySQL = usingMySQL;
|
this.usingMySQL = usingMySQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public abstract boolean createTable();
|
public abstract boolean createTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
protected Connection getConnection() throws SQLException {
|
protected Connection getConnection() throws SQLException {
|
||||||
Connection connection = db.getConnection();
|
Connection connection = db.getConnection();
|
||||||
if (connection == null || connection.isClosed()) {
|
if (connection == null || connection.isClosed()) {
|
||||||
@ -32,20 +58,41 @@ public abstract class Table {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public int getVersion() throws SQLException {
|
public int getVersion() throws SQLException {
|
||||||
return db.getVersion();
|
return db.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
protected boolean execute(String sql) throws SQLException {
|
protected boolean execute(String sql) throws SQLException {
|
||||||
Connection connection = getConnection();
|
Connection connection = getConnection();
|
||||||
boolean success = connection.createStatement().execute(sql);
|
boolean success = connection.createStatement().execute(sql);
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param sql
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
protected PreparedStatement prepareStatement(String sql) throws SQLException {
|
protected PreparedStatement prepareStatement(String sql) throws SQLException {
|
||||||
return getConnection().prepareStatement(sql);
|
return getConnection().prepareStatement(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param toClose
|
||||||
|
*/
|
||||||
protected void close(AutoCloseable toClose) {
|
protected void close(AutoCloseable toClose) {
|
||||||
if (toClose != null) {
|
if (toClose != null) {
|
||||||
try {
|
try {
|
||||||
@ -55,10 +102,18 @@ public abstract class Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String getTableName() {
|
public String getTableName() {
|
||||||
return tableName;
|
return tableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean removeAllData() {
|
public boolean removeAllData() {
|
||||||
try {
|
try {
|
||||||
execute("DELETE FROM " + tableName);
|
execute("DELETE FROM " + tableName);
|
||||||
|
@ -35,6 +35,11 @@ public class UsersTable extends Table {
|
|||||||
private final String columnDeaths;
|
private final String columnDeaths;
|
||||||
private final String columnMobKills;
|
private final String columnMobKills;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param db
|
||||||
|
* @param usingMySQL
|
||||||
|
*/
|
||||||
public UsersTable(SQLDB db, boolean usingMySQL) {
|
public UsersTable(SQLDB db, boolean usingMySQL) {
|
||||||
super("plan_users", db, usingMySQL);
|
super("plan_users", db, usingMySQL);
|
||||||
columnID = "id";
|
columnID = "id";
|
||||||
@ -52,6 +57,10 @@ public class UsersTable extends Table {
|
|||||||
columnDeaths = "deaths";
|
columnDeaths = "deaths";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createTable() {
|
public boolean createTable() {
|
||||||
try {
|
try {
|
||||||
@ -103,10 +112,22 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param uuid
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public int getUserId(UUID uuid) throws SQLException {
|
public int getUserId(UUID uuid) throws SQLException {
|
||||||
return getUserId(uuid.toString());
|
return getUserId(uuid.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param uuid
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public int getUserId(String uuid) throws SQLException {
|
public int getUserId(String uuid) throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = 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 {
|
public UUID getUserUUID(String userID) throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
@ -143,6 +170,11 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public Set<UUID> getSavedUUIDs() throws SQLException {
|
public Set<UUID> getSavedUUIDs() throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
@ -164,10 +196,20 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param uuid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean removeUser(UUID uuid) {
|
public boolean removeUser(UUID uuid) {
|
||||||
return removeUser(uuid.toString());
|
return removeUser(uuid.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param uuid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean removeUser(String uuid) {
|
public boolean removeUser(String uuid) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -182,6 +224,11 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public void addUserInformationToUserData(UserData data) throws SQLException {
|
public void addUserInformationToUserData(UserData data) throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
@ -207,6 +254,11 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public void saveUserDataInformation(UserData data) throws SQLException {
|
public void saveUserDataInformation(UserData data) throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -285,6 +337,12 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param data
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public List<UserData> saveUserDataInformationBatch(List<UserData> data) throws SQLException {
|
public List<UserData> saveUserDataInformationBatch(List<UserData> data) throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -360,6 +418,10 @@ public class UsersTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String getColumnID() {
|
public String getColumnID() {
|
||||||
return columnID;
|
return columnID;
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,19 @@ import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
|||||||
*/
|
*/
|
||||||
public class VersionTable extends Table {
|
public class VersionTable extends Table {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param db
|
||||||
|
* @param usingMySQL
|
||||||
|
*/
|
||||||
public VersionTable(SQLDB db, boolean usingMySQL) {
|
public VersionTable(SQLDB db, boolean usingMySQL) {
|
||||||
super("plan_version", db, usingMySQL);
|
super("plan_version", db, usingMySQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean createTable() {
|
public boolean createTable() {
|
||||||
try {
|
try {
|
||||||
@ -30,6 +39,11 @@ public class VersionTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() throws SQLException {
|
public int getVersion() throws SQLException {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
@ -48,6 +62,11 @@ public class VersionTable extends Table {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
public void setVersion(int version) throws SQLException {
|
public void setVersion(int version) throws SQLException {
|
||||||
removeAllData();
|
removeAllData();
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
@ -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_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_SESSIONS_START(TABLE_START_3.parse("Session Started", "Session Ended", "Session Length")),
|
||||||
TABLE_KILLS_START(TABLE_START_3.parse("Date", "Killed", "With")),
|
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_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_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_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_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>"),
|
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
Loading…
Reference in New Issue
Block a user