[3.0.0] Release

- Updated javadocs partially complete
- Fixed possible memory leaks from the queues
- Fixed a bug where new player didn't save to the cache.
- Stable enough for release.
This commit is contained in:
Rsl1122 2017-05-08 13:28:19 +03:00
parent ccb2498d38
commit 0cacc495ad
56 changed files with 840 additions and 730 deletions

6
.gitignore vendored
View File

@ -1,11 +1,9 @@
/dist/
/build/
/nbproject/
/Plan Lite/build/
/Plan Lite/dist/
/Plan Lite/nbproject/private/
/Plan/nbproject/
/Plan/target/
/Plan/temporaryTestFolder/
/Debugger/nbproject/private/
/PlanDebugger/nbproject/private/
/PlanDebugger/
/Plan Lite/

View File

@ -9,13 +9,15 @@ import java.util.Date;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
/**
* This class manages the messages going to the Bukkit's Logger.
*
* @author Rsl1122
* @since 3.0.0
*/
public class Log {
/**
* Logs the message to the console.
* Logs the message to the console as INFO.
*
* @param message "Message" will show up as [INFO][Plan]: Message
*/
@ -27,17 +29,22 @@ public class Log {
}
/**
* Logs an error message to the console.
* Logs an error message to the console as ERROR.
*
* @param message "Message" will show up as [ERROR][Plan]: Message
*/
public static void errorMsg(String message) {
public static void error(String message) {
Plan instance = Plan.getInstance();
if (instance != null) {
instance.getLogger().severe(message);
}
}
/**
* Logs a debug message to the console as INFO if Settings.Debug is true.
*
* @param message "Message" will show up as [INFO][Plan]: [DEBUG] Message
*/
public static void debug(String message) {
if (Settings.DEBUG.isTrue()) {
info("[DEBUG] " + message);
@ -51,7 +58,7 @@ public class Log {
* @param e Throwable, eg NullPointerException
*/
public static void toLog(String source, Throwable e) {
errorMsg(Phrase.ERROR_LOGGED.parse(e.toString()));
error(Phrase.ERROR_LOGGED.parse(e.toString()));
toLog(source + " Caught " + e);
for (StackTraceElement x : e.getStackTrace()) {
toLog(" " + x);

View File

@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
* Permissions class is used easily check every permission node.
*
* @author Rsl1122
* @since 3.0.0
*/
public enum Permissions {

View File

@ -14,6 +14,7 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
* or ChatColor.
*
* @author Rsl1122
* @since 2.0.0
*/
public enum Phrase {
REPLACE0("REPLACE0"),

View File

@ -22,11 +22,9 @@ package main.java.com.djrapitops.plan;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URL;
import java.util.Collection;
import java.util.Date;
@ -42,7 +40,6 @@ import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.*;
import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.ui.webserver.WebSocketServer;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
@ -56,6 +53,7 @@ import org.bukkit.scheduler.BukkitTask;
* the Bukkit console & various get methods.
*
* @author Rsl1122
* @since 1.0.0
*/
public class Plan extends JavaPlugin {
@ -99,7 +97,7 @@ public class Plan extends JavaPlugin {
if (initDatabase()) {
Log.info(Phrase.DB_ESTABLISHED.parse(db.getConfigName()));
} else {
Log.errorMsg(Phrase.DB_FAILURE_DISABLE.toString());
Log.error(Phrase.DB_FAILURE_DISABLE.toString());
getServer().getPluginManager().disablePlugin(this);
return;
}
@ -179,7 +177,7 @@ public class Plan extends JavaPlugin {
*/
@Deprecated
public void logError(String message) {
Log.errorMsg(message);
Log.error(message);
}
/**

View File

@ -1,12 +1,11 @@
package main.java.com.djrapitops.plan;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/**
* This enum contains all of the config settings used by the plugin for easier
* access.
*
* @author Rsl1122
* @since 2.3.2
*/
public enum Settings {
// Boolean
@ -70,7 +69,7 @@ public enum Settings {
* @return Boolean value of the config setting, false if not boolean.
*/
public boolean isTrue() {
return getPlugin(Plan.class).getConfig().getBoolean(configPath);
return Plan.getInstance().getConfig().getBoolean(configPath);
}
/**
@ -80,7 +79,7 @@ public enum Settings {
*/
@Override
public String toString() {
return getPlugin(Plan.class).getConfig().getString(configPath);
return Plan.getInstance().getConfig().getString(configPath);
}
/**
@ -89,7 +88,7 @@ public enum Settings {
* @return Integer value of the config setting
*/
public int getNumber() {
return getPlugin(Plan.class).getConfig().getInt(configPath);
return Plan.getInstance().getConfig().getInt(configPath);
}
/**

View File

@ -11,8 +11,12 @@ import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
/**
* This class contains the API methods.
* <p>
* Revamp incoming in 3.1.0
*
* @author Rsl1122
* @since 2.0.0
*/
public class API {
@ -102,8 +106,9 @@ public class API {
* Returns the ip:port/player/playername html as a string so it can be
* integrated into other webserver plugins.
*
* Should use cacheUserDataToInspectCache(UUID uuid) before using this method.
*
* Should use cacheUserDataToInspectCache(UUID uuid) before using this
* method.
*
* If UserData of the specified player is not in the Cache returns <h1>404
* Data was not found in cache</h1>
*
@ -134,7 +139,7 @@ public class API {
* other webserver plugins.
*
* Should use updateAnalysisCache() before using this method.
*
*
* If AnalysisData is not in the AnalysisCache: returns <h1>404 Data was not
* found in cache</h1>
*

View File

@ -4,6 +4,7 @@ package main.java.com.djrapitops.plan.api;
* This class contains Genders used by the plugin.
*
* @author Rsl1122
* @since 2.0.0
*/
public enum Gender {
MALE, FEMALE, OTHER, UNKNOWN;

View File

@ -7,6 +7,7 @@ package main.java.com.djrapitops.plan.command;
* CONSOLE_WITH_ARGUMENTS can be used always, except with arguments on console.
*
* @author Rsl1122
* @since 1.0.0
*/
public enum CommandType {
CONSOLE,

View File

@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
* CommandExecutor for the /plan command, and all subcommands.
*
* @author Rsl1122
* @since 1.0.0
*/
public class PlanCommand implements CommandExecutor {

View File

@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
* command.
*
* @author Rsl1122
* @since 1.0.0
*/
public abstract class SubCommand {

View File

@ -22,6 +22,7 @@ import org.bukkit.scheduler.BukkitTask;
* This subcommand is used to run the analysis and access the /server link.
*
* @author Rsl1122
* @since 2.0.0
*/
public class AnalyzeCommand extends SubCommand {

View File

@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
* This subcommand is used to view the subcommands.
*
* @author Rsl1122
* @since 1.0.0
*/
public class HelpCommand extends SubCommand {

View File

@ -14,6 +14,7 @@ import org.bukkit.command.CommandSender;
* This subcommand is used to view the version & the database type in use.
*
* @author Rsl1122
* @since 2.0.0
*/
public class InfoCommand extends SubCommand {

View File

@ -24,6 +24,7 @@ import org.bukkit.scheduler.BukkitTask;
* This command is used to cache UserData to InspectCache and display the link.
*
* @author Rsl1122
* @since 1.0.0
*/
public class InspectCommand extends SubCommand {

View File

@ -14,8 +14,12 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* This command is used to manage the database of the plugin.
* <p>
* No arguments will run ManageHelpCommand. Contains subcommands.
*
* @author Rsl1122
* @since 2.3.0
*/
public class ManageCommand extends SubCommand {
@ -28,7 +32,7 @@ public class ManageCommand extends SubCommand {
* @param plugin Current instance of Plan
*/
public ManageCommand(Plan plugin) {
super("manage, m", Permissions.MANAGE, Phrase.CMD_USG_MANAGE+"", CommandType.CONSOLE, "");
super("manage, m", Permissions.MANAGE, Phrase.CMD_USG_MANAGE + "", CommandType.CONSOLE, "");
this.plugin = plugin;
commands = new ArrayList<>();
commands.add(new ManageHelpCommand(plugin, this));
@ -39,10 +43,12 @@ public class ManageCommand extends SubCommand {
commands.add(new ManageStatusCommand(plugin));
commands.add(new ManageImportCommand(plugin));
commands.add(new ManageRemoveCommand(plugin));
commands.add(new ManageClearCommand(plugin));
commands.add(new ManageClearCommand(plugin));
}
/**
* Used to get the list of manage subcommands.
*
* @return Initialized SubCommands
*/
public List<SubCommand> getCommands() {
@ -105,7 +111,7 @@ public class ManageCommand extends SubCommand {
}
if (console && args.length < 2 && command.getCommandType() == CommandType.CONSOLE_WITH_ARGUMENTS) {
sender.sendMessage("" + Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_MANAGE+""));
sender.sendMessage("" + Phrase.COMMAND_REQUIRES_ARGUMENTS.parse(Phrase.USE_MANAGE + ""));
return true;
}

View File

@ -4,24 +4,21 @@ import java.util.Date;
import main.java.com.djrapitops.plan.Permissions;
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.command.CommandType;
import main.java.com.djrapitops.plan.command.SubCommand;
import main.java.com.djrapitops.plan.data.cache.AnalysisCacheHandler;
import main.java.com.djrapitops.plan.ui.TextUI;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
/**
* This subcommand is used to run the analysis and access the /server link.
* This subcommand is used to run the analysis and to view some of the data in
* game.
*
* @author Rsl1122
* @since 3.0.0
*/
public class QuickAnalyzeCommand extends SubCommand {
@ -71,7 +68,7 @@ public class QuickAnalyzeCommand extends SubCommand {
public void run() {
timesrun++;
if (analysisCache.isCached()) {
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER + "");
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER + "");
sender.sendMessage(TextUI.getAnalysisMessages());
sender.sendMessage(Phrase.CMD_FOOTER + "");
this.cancel();

View File

@ -9,21 +9,21 @@ import main.java.com.djrapitops.plan.command.CommandType;
import main.java.com.djrapitops.plan.command.SubCommand;
import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
import main.java.com.djrapitops.plan.ui.TextUI;
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
/**
* This command is used to cache UserData to InspectCache and display the link.
* This command is used to cache UserData to InspectCache and to view some of
* the data in game.
*
* @author Rsl1122
* @since 3.0.0
*/
public class QuickInspectCommand extends SubCommand {

View File

@ -9,8 +9,10 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
/**
* This subcommand is used to reload the plugin.
*
* @author Rsl1122
* @since 2.0.0
*/
public class ReloadCommand extends SubCommand {
@ -33,7 +35,6 @@ public class ReloadCommand extends SubCommand {
plugin.onDisable();
plugin.onEnable();
sender.sendMessage(Phrase.RELOAD_COMPLETE + "");
return true;
}

View File

@ -22,8 +22,10 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
/**
* This subcommand is used to search for a user, and to view all matches' data.
*
* @author Rsl1122
* @since 2.0.0
*/
public class SearchCommand extends SubCommand {
@ -44,7 +46,7 @@ public class SearchCommand extends SubCommand {
/**
* Subcommand search.
*
* Searches database for matching playernames and caches matching PlayerData
* Searches database for matching playernames and caches matching UserData
* to InspectCache. Shows all links to matching players data.
*
* @param sender
@ -110,10 +112,10 @@ public class SearchCommand extends SubCommand {
Bukkit.getServer().dispatchCommand(
Bukkit.getConsoleSender(),
"tellraw " + player.getName() + " [\"\",{\"text\":\"Click Me\",\"underlined\":true,"
+ "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}}]");
+ "\"clickEvent\":{\"action\":\"open_url\",\"value\":\"" + url + "\"}}]");
}
}.runTask(plugin);
}
}
}

View File

@ -12,8 +12,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
/**
* This manage subcommand is used to backup a database to a .db file.
*
* @author Rsl1122
* @since 2.3.0
*/
public class ManageBackupCommand extends SubCommand {
@ -36,7 +38,7 @@ public class ManageBackupCommand extends SubCommand {
* @param sender
* @param cmd
* @param commandLabel
* @param args Player's name or nothing - if empty sender's name is used.
* @param args mysql or sqlite, -a to confirm.
* @return true in all cases.
*/
@Override

View File

@ -13,11 +13,13 @@ import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
/**
* This manage subcommand is used to clear a database of all data.
*
* @author Rsl1122
* @since 2.3.0
*/
public class ManageClearCommand extends SubCommand {
private final Plan plugin;
/**
@ -27,7 +29,7 @@ public class ManageClearCommand extends SubCommand {
*/
public ManageClearCommand(Plan plugin) {
super("clear", Permissions.MANAGE, Phrase.CMD_USG_MANAGE_CLEAR + "", CommandType.CONSOLE_WITH_ARGUMENTS, "<DB> [-a]");
this.plugin = plugin;
}
@ -59,7 +61,7 @@ public class ManageClearCommand extends SubCommand {
sender.sendMessage(Phrase.COMMAND_ADD_CONFIRMATION_ARGUMENT.parse(Phrase.WARN_REMOVE.parse(args[0])));
return true;
}
Database clearDB = null;
for (Database database : plugin.getDatabases()) {
if (dbToClear.equalsIgnoreCase(database.getConfigName())) {
@ -72,7 +74,7 @@ public class ManageClearCommand extends SubCommand {
plugin.logError(dbToClear + " was null!");
return true;
}
final Database clearThisDB = clearDB;
(new BukkitRunnable() {
@Override

View File

@ -12,8 +12,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* This manage subcommand is used to view all other manage subcommands.
*
* @author Rsl1122
* @since 2.3.0
*/
public class ManageHelpCommand extends SubCommand {
@ -34,7 +36,7 @@ public class ManageHelpCommand extends SubCommand {
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
public boolean onCommand(CommandSender sender, Command c, String commandLabel, String[] args) {
ChatColor oColor = Phrase.COLOR_MAIN.color();
ChatColor tColor = Phrase.COLOR_SEC.color();
@ -43,21 +45,21 @@ public class ManageHelpCommand extends SubCommand {
// Header
sender.sendMessage(Phrase.CMD_MANAGE_HELP_HEADER + "");
// Help results
for (SubCommand command : this.command.getCommands()) {
if (command.getName().equalsIgnoreCase(getName())) {
for (SubCommand cmd : this.command.getCommands()) {
if (cmd.getName().equalsIgnoreCase(getName())) {
continue;
}
if (!command.getPermission().userHasThisPermission(sender)) {
if (!cmd.getPermission().userHasThisPermission(sender)) {
continue;
}
if (!(sender instanceof Player) && command.getCommandType() == CommandType.PLAYER) {
if (!(sender instanceof Player) && cmd.getCommandType() == CommandType.PLAYER) {
continue;
}
sender.sendMessage(tColor + " " + Phrase.BALL.toString() + oColor
+ " /plan manage " + command.getFirstName() + " " + command.getArguments() + tColor + " - " + command.getUsage());
+ " /plan manage " + cmd.getFirstName() + " " + cmd.getArguments() + tColor + " - " + cmd.getUsage());
}
// Footer
sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString());

View File

@ -11,8 +11,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
/**
* This manage subcommand is used to swap to a different database and reload the
* plugin if the connection to the new database can be established.
*
* @author Rsl1122
* @since 2.3.0
*/
public class ManageHotswapCommand extends SubCommand {

View File

@ -22,8 +22,12 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
/**
*
* This manage subcommand is used to import data from 3rd party plugins.
*
* Supported plugins (v3.0.0) : OnTime
*
* @author Rsl1122
* @since 2.3.0
*/
public class ManageImportCommand extends SubCommand {

View File

@ -15,8 +15,12 @@ import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
/**
*
* This manage subcommand is used to move all data from one database to another.
*
* Destination database will be cleared.
*
* @author Rsl1122
* @since 2.3.0
*/
public class ManageMoveCommand extends SubCommand {
@ -32,20 +36,7 @@ public class ManageMoveCommand extends SubCommand {
this.plugin = plugin;
}
/**
* Subcommand inspect.
*
* Adds player's data from DataCache/DB to the InspectCache for amount of
* time specified in the config, and clears the data from Cache with a timer
* task.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args Player's name or nothing - if empty sender's name is used.
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (args.length < 2) {
@ -93,7 +84,7 @@ public class ManageMoveCommand extends SubCommand {
plugin.logError(toDB + " was null!");
return true;
}
final Database moveFromDB = fromDatabase;
final Database moveToDB = toDatabase;
(new BukkitRunnable() {

View File

@ -17,6 +17,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.scheduler.BukkitRunnable;
/**
* This manage subcommand is used to remove a single player's data from the
* database.
*
* @author Rsl1122
*/
@ -35,19 +37,6 @@ public class ManageRemoveCommand extends SubCommand {
this.plugin = plugin;
}
/**
* Subcommand inspect.
*
* Adds player's data from DataCache/DB to the InspectCache for amount of
* time specified in the config, and clears the data from Cache with a timer
* task.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args Player's name or nothing - if empty sender's name is used.
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (args.length == 0) {

View File

@ -18,12 +18,14 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
/**
* This manage subcommand is used to restore a backup.db file in the
* /plugins/Plan folder.
*
* @author Rsl1122
*/
public class ManageRestoreCommand extends SubCommand {
private Plan plugin;
private final Plan plugin;
/**
* Class Constructor.
@ -36,15 +38,6 @@ public class ManageRestoreCommand extends SubCommand {
this.plugin = plugin;
}
/**
* Subcommand Manage backup.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args Player's name or nothing - if empty sender's name is used.
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
try {

View File

@ -10,12 +10,13 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
/**
* This manage subcommand is used to check the status of the database.
*
* @author Rsl1122
*/
public class ManageStatusCommand extends SubCommand {
private Plan plugin;
private final Plan plugin;
/**
* Class Constructor.
@ -28,29 +29,14 @@ public class ManageStatusCommand extends SubCommand {
this.plugin = plugin;
}
/**
* Subcommand inspect.
*
* Adds player's data from DataCache/DB to the InspectCache for amount of
* time specified in the config, and clears the data from Cache with a timer
* task.
*
* @param sender
* @param cmd
* @param commandLabel
* @param args Player's name or nothing - if empty sender's name is used.
* @return true in all cases.
*/
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
ChatColor hColor = Phrase.COLOR_TER.color();
// Header
sender.sendMessage(Phrase.CMD_MANAGE_STATUS_HEADER + "");
sender.sendMessage(Phrase.CMD_MANAGE_STATUS_ACTIVE_DB.parse(plugin.getDB().getConfigName()));
// Footer
sender.sendMessage(hColor + Phrase.ARROWS_RIGHT.toString());
return true;
}

View File

@ -3,10 +3,23 @@ package main.java.com.djrapitops.plan.data;
import java.util.Arrays;
import java.util.Objects;
import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.ui.RecentPlayersButtonsCreator;
import main.java.com.djrapitops.plan.ui.tables.SortableCommandUseTableCreator;
import main.java.com.djrapitops.plan.ui.tables.SortablePlayersTableCreator;
import main.java.com.djrapitops.plan.utilities.Analysis;
import main.java.com.djrapitops.plan.utilities.AnalysisUtils;
import main.java.com.djrapitops.plan.utilities.PlaceholderUtils;
/**
* This class is used to store result data from Analysis at runtime.
*
* Most of the variables need to be set with various set methods, as they are
* not initialized in a constructor.
*
* @author Rsl1122
* @since 2.0.0
* @see Analysis
* @see PlaceholderUtils
*/
public class AnalysisData {
@ -17,7 +30,6 @@ public class AnalysisData {
private double averageAge;
private String commandUseTableHtml;
private long totalCommands;
private String top20ActivePlayers;
private String recentPlayers;
private String sortablePlayersTable;
private String[] playersDataArray;
@ -56,12 +68,11 @@ public class AnalysisData {
/**
* Class constructor.
*
* All data has to be set with setters to avoid NPE.
* All data has to be set with setters to avoid NPEs.
*/
public AnalysisData() {
sortablePlayersTable = Html.ERROR_NOT_SET + "";
commandUseTableHtml = Html.ERROR_NOT_SET + "";
top20ActivePlayers = Html.ERROR_NOT_SET + "";
recentPlayers = Html.ERROR_NOT_SET + "";
geomapCountries = Html.ERROR_NOT_SET + "";
geomapZ = Html.ERROR_NOT_SET + "";
@ -70,7 +81,6 @@ public class AnalysisData {
genderData = new int[]{0, 0, 0};
}
// Getters and setters v---------------------------------v
@Override
public boolean equals(Object obj) {
if (this == obj) {
@ -155,9 +165,6 @@ public class AnalysisData {
if (!Objects.equals(this.commandUseTableHtml, other.commandUseTableHtml)) {
return false;
}
if (!Objects.equals(this.top20ActivePlayers, other.top20ActivePlayers)) {
return false;
}
if (!Objects.equals(this.recentPlayers, other.recentPlayers)) {
return false;
}
@ -183,106 +190,151 @@ public class AnalysisData {
}
/**
* Used to get the toString representation of a String[] containing all
* countries on the Plotly.js Chloropleth map.
*
* @return
* @return ["Finland","Sweden","Etc.."]
*/
public String getGeomapCountries() {
return geomapCountries;
}
/**
* Used to set the toString representation of a String[] containing all
* countries on the Plotly.js Chloropleth map.
*
* @param geomapCountries
* Incorrect value will break the Chloropleth map on analysis.html page.
*
* @param geomapCountries ["Finland","Sweden","Etc.."]
*/
public void setGeomapCountries(String geomapCountries) {
this.geomapCountries = geomapCountries;
}
/**
* Used to get the toString representation of a int[] containing all player
* amounts on the Plotly.js Chloropleth map.
*
* @return
* Must contain same amount of numbers as countries in GeomapCountries.
*
* @return [0,0,0,3,0,Etc..]
*/
public String getGeomapZ() {
return geomapZ;
}
/**
* Used to set the toString representation of a int[] containing all player
* amounts on the Plotly.js Chloropleth map.
*
* @param geomapZ
* Must contain same amount of numbers as countries in GeomapCountries.
* Incorrect amount will break the Chloropleth map on analysis.html page.
*
* @param geomapZ [0,0,0,3,0,Etc..]
*/
public void setGeomapZ(String geomapZ) {
this.geomapZ = geomapZ;
}
/**
* Used to get the toString representation of a String[] containing all
* country codes on the Plotly.js Chloropleth map.
*
* @return
* Must contain same amount of numbers as countries in GeomapCountries.
*
* @return ["PNG","KHM","KAZ","PRY","SYR","SLB","MLI","Etc.."]
*/
public String getGeomapCodes() {
return geomapCodes;
}
/**
* Used to set the toString representation of a String[] containing all
* country codes on the Plotly.js Chloropleth map.
*
* @param geomapCodes
* Must contain same amount of numbers as countries in GeomapCountries.
*
* @param geomapCodes ["PNG","KHM","KAZ","PRY","SYR","SLB","MLI","Etc.."]
*/
public void setGeomapCodes(String geomapCodes) {
this.geomapCodes = geomapCodes;
}
/**
* Used to get the html for players table.
*
* @return
* @return Html string.
* @see SortablePlayersTableCreator
*/
public String getSortablePlayersTable() {
return sortablePlayersTable;
}
/**
* Used to set the html for players table.
*
* @param sortablePlayersTable
* @param sortablePlayersTable Html string.
* @see SortablePlayersTableCreator
*/
public void setSortablePlayersTable(String sortablePlayersTable) {
this.sortablePlayersTable = sortablePlayersTable;
}
/**
* @return 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
*/
public int getJoinleaver() {
return joinleaver;
}
/**
* @param joinleaver The Amount of players who have joined only once
* Used to set the amount of players who have joined only once.
*
* No check for correct value.
*
* @param joinleaver Number from 0 to Integer.MAX
*/
public void setJoinleaver(int joinleaver) {
this.joinleaver = joinleaver;
}
/**
* @return HTML String of the Top50CommandsList
* Used to get the html for the commands table.
*
* @return Html string.
* @see SortableCommandUseTableCreator
*/
public String getCommandUseListHtml() {
return commandUseTableHtml;
}
/**
* @param top50CommandsListHtml HTML String of the Top50CommandsList
* Used to get the html for the commands table.
*
* @param commandsTableHtml Html string.
* @see SortableCommandUseTableCreator
*/
public void setCommandUseTableHtml(String top50CommandsListHtml) {
this.commandUseTableHtml = top50CommandsListHtml;
public void setCommandUseTableHtml(String commandsTableHtml) {
this.commandUseTableHtml = commandsTableHtml;
}
/**
* @return Amount of banned players
* Used to get the amount of banned players.
*
* @return 0 to Integer.MAX
*/
public int getBanned() {
return banned;
}
/**
* @param banned Amount of banned players
* Used to set the amount of banned players.
*
* No check for correct value.
*
* @param banned 0 to Integer.MAX
*/
public void setBanned(int banned) {
this.banned = banned;
@ -294,6 +346,7 @@ public class AnalysisData {
* Activity is determined by AnalysisUtils.isActive()
*
* @return Amount of active players
* @see AnalysisUtils
*/
public int getActive() {
return active;
@ -305,166 +358,233 @@ public class AnalysisData {
* Activity is determined by AnalysisUtils.isActive()
*
* @param active Amount of active players
* @see AnalysisUtils
*/
public void setActive(int active) {
this.active = active;
}
/**
* Set the amount of inactive players.
*
* Activity is determined by AnalysisUtils.isActive()
*
* @return Amount of inactive players
* @see AnalysisUtils
*/
public int getInactive() {
return inactive;
}
/**
* Set the amount of inactive players.
*
* Activity is determined by AnalysisUtils.isActive()
*
* @param inactive Amount of inactive players
* @see AnalysisUtils
*/
public void setInactive(int inactive) {
this.inactive = inactive;
}
/**
* @return Total Amount of players used to calculate activity
* Get the total amount of players used to calculate activity.
*
* @return 0 to Integer.MAX
*/
public int getTotal() {
return total;
}
/**
* @param total Total Amount of players used to calculate activity
* Set the total amount of players used to calculate activity.
*
* No check for correct value.
*
* @param total 0 to Integer.MAX
*/
public void setTotal(int total) {
this.total = total;
}
/**
* @return Percentage of Gamemode usage time as a whole
* Get percentage of Gamemode usage time as a whole.
*
* @return 0.0 to 1.0
*/
public double getGm0Perc() {
return gm0Perc;
}
/**
* @param gm0Perc Percentage of Gamemode usage time as a whole
* Set percentage of Gamemode usage time as a whole.
*
* No check for correct value.
*
* @param gm0Perc 0.0 to 1.0
*/
public void setGm0Perc(double gm0Perc) {
this.gm0Perc = gm0Perc;
}
/**
* @return Percentage of Gamemode usage time as a whole
* Get percentage of Gamemode usage time as a whole.
*
* @return 0.0 to 1.0
*/
public double getGm1Perc() {
return gm1Perc;
}
/**
* @param gm1Perc Percentage of Gamemode usage time as a whole
* Set percentage of Gamemode usage time as a whole.
*
* No check for correct value.
*
* @param gm1Perc 0.0 to 1.0
*/
public void setGm1Perc(double gm1Perc) {
this.gm1Perc = gm1Perc;
}
/**
* @return Percentage of Gamemode usage time as a whole
* Get percentage of Gamemode usage time as a whole.
*
* @return 0.0 to 1.0
*/
public double getGm2Perc() {
return gm2Perc;
}
/**
* @param gm2Perc Percentage of Gamemode usage time as a whole
* Set percentage of Gamemode usage time as a whole.
*
* No check for correct value.
*
* @param gm2Perc 0.0 to 1.0
*/
public void setGm2Perc(double gm2Perc) {
this.gm2Perc = gm2Perc;
}
/**
* @return Percentage of Gamemode usage time as a whole
* Get percentage of Gamemode usage time as a whole.
*
* @return 0.0 to 1.0
*/
public double getGm3Perc() {
return gm3Perc;
}
/**
* @param gm3Perc Percentage of Gamemode usage time as a whole
* Set percentage of Gamemode usage time as a whole.
*
* No check for correct value.
*
* @param gm3Perc 0.0 to 1.0
*/
public void setGm3Perc(double gm3Perc) {
this.gm3Perc = gm3Perc;
}
/**
* @return Total number of players according to bukkit's data.
* Get percentage of Gamemode usage time as a whole.
*
* @return 0.0 to 1.0
*/
public int getTotalPlayers() {
return totalPlayers;
}
/**
* @param totalPlayers Total number of players according to bukkit's data.
* Get the Total number of players according to bukkit's data.
*
* @param totalPlayers 0 to Integer.MAX
*/
public void setTotalPlayers(int totalPlayers) {
this.totalPlayers = totalPlayers;
}
/**
* @return How long has been played, long in ms.
* Get how long time has been played, long in ms.
*
* @return 0 to Long.MAX
*/
public long getTotalPlayTime() {
return totalPlayTime;
}
/**
* @param totalPlayTime How long has been played, long in ms.
* Set how long time has been played, long in ms.
*
* No check for correct value.
*
* @param totalPlayTime 0 to Long.MAX
*/
public void setTotalPlayTime(long totalPlayTime) {
this.totalPlayTime = totalPlayTime;
}
/**
* @return Last Analysis Refresh, long in ms.
* Retrieve the refresh Epoch millisecond this object's data was calculated.
*
* @return the refresh Epoch millisecond.
*/
public long getRefreshDate() {
return refreshDate;
}
/**
* @return How long has been played on average, long in ms.
* Get How long players have played on average.
*
* @return long in ms.
*/
public long getAveragePlayTime() {
return averagePlayTime;
}
/**
* @return Average age of the players whose age has been gathered.
* Get the average age of the players whose age has been gathered.
*
* -1 if none have been gathered.
*
* @return -1 or from 1.0 to 99.0
*/
public double getAverageAge() {
return averageAge;
}
/**
* @return How many times players have joined.
* Get How many times players have joined in total.
*
* @return 0 to Long.MAX
*/
public long getTotalLoginTimes() {
return totalLoginTimes;
}
/**
* @return How many operators are on the server.
* Get How many operators are on the server.
*
* @return 0 to Integer.MAX
*/
public int getOps() {
return ops;
}
/**
* @param refreshDate Last Analysis Refresh, long in ms.
* Set the refresh Epoch millisecond this object's data was calculated.
*
* @param refreshDate Epoch millisecond.
*/
public void setRefreshDate(long refreshDate) {
this.refreshDate = refreshDate;
}
/**
* Set the average playtime of all players.
*
* @param averagePlayTime long in ms.
*/
public void setAveragePlayTime(long averagePlayTime) {
@ -472,147 +592,167 @@ public class AnalysisData {
}
/**
* @param averageAge Average age of the players whose age has been gathered.
* Set the average age of the players whose age has been gathered.
*
* No check for correct value.
*
* @param averageAge 1.0 to 99.0 or -1 if none have been gathered.
*/
public void setAverageAge(double averageAge) {
this.averageAge = averageAge;
}
/**
* @param totalLoginTimes How many times playes have logged in
* Set How many times playes have logged in.
*
* @param totalLoginTimes 0 to Long.MAX
*/
public void setTotalLoginTimes(long totalLoginTimes) {
this.totalLoginTimes = totalLoginTimes;
}
/**
* @param ops Amount of operators.
* Set the amount of operators.
*
* @param ops 0 to Integer.MAX
*/
public void setOps(int ops) {
this.ops = ops;
}
/**
* Get the html for Recent player buttons.
*
* @return
*/
public String getTop20ActivePlayers() {
return top20ActivePlayers;
}
/**
*
* @param top20ActivePlayers
*/
public void setTop20ActivePlayers(String top20ActivePlayers) {
this.top20ActivePlayers = top20ActivePlayers;
}
/**
*
* @return
* @return html string.
* @see RecentPlayersButtonsCreator
*/
public String getRecentPlayers() {
return recentPlayers;
}
/**
* Set the html for Recent player buttons.
*
* @param recentPlayers
* @param recentPlayers html string.
* @see RecentPlayersButtonsCreator
*/
public void setRecentPlayers(String recentPlayers) {
this.recentPlayers = recentPlayers;
}
/**
* Get the amount of registered players in last 30 days.
*
* @return
* @return 0 to Integer.MAX
*/
public int getNewPlayersMonth() {
return newPlayersMonth;
}
/**
* Set the amount of registered players in last 30 days.
*
* @param newPlayersMonth
* No check for correct value.
*
* @param newPlayersMonth 0 to Integer.MAX
*/
public void setNewPlayersMonth(int newPlayersMonth) {
this.newPlayersMonth = newPlayersMonth;
}
/**
* Get the amount of registered players in last 7 days.
*
* @return
* @return 0 to Integer.MAX
*/
public int getNewPlayersWeek() {
return newPlayersWeek;
}
/**
* Set the amount of registered players in last 7 days.
*
* @param newPlayersWeek
* No check for correct value.
*
* @param newPlayersWeek 0 to Integer.MAX
*/
public void setNewPlayersWeek(int newPlayersWeek) {
this.newPlayersWeek = newPlayersWeek;
}
/**
* Get the amount of registered players in last 24 hours.
*
* @return
* @return 0 to Integer.MAX
*/
public int getNewPlayersDay() {
return newPlayersDay;
}
/**
* Set the amount of registered players in last 24 hours.
*
* @param newPlayersDay
* No check for correct value.
*
* @param newPlayersDay 0 to Integer.MAX
*/
public void setNewPlayersDay(int newPlayersDay) {
this.newPlayersDay = newPlayersDay;
}
/**
* Get the amount of times players have killed each other.
*
* @return
* @return 0 to Long.MAX
*/
public long getTotalPlayerKills() {
return totalkills;
}
/**
* Get the amount of mob kills the players have.
*
* @return
* @return 0 to Long.MAX
*/
public long getTotalMobKills() {
return totalmobkills;
}
/**
* Get how many times the playes have died.
*
* @return
* @return 0 to Long.MAX
*/
public long getTotalDeaths() {
return totaldeaths;
}
/**
* Set the amount of times players have killed each other.
*
* @param totalkills
* No check for correct value.
*
* @param totalkills 0 to Long.MAX
*/
public void setTotalkills(long totalkills) {
this.totalkills = totalkills;
}
/**
* Set the amount of mob kills the players have.
*
* @param totalmobkills
* No check for correct value.
*
* @param totalmobkills 0 to Long.MAX
*/
public void setTotalmobkills(long totalmobkills) {
this.totalmobkills = totalmobkills;
}
/**
* Set how many times the playes have died.
*
* No check for correct value.
*
* @param totaldeaths
*/
@ -621,56 +761,83 @@ public class AnalysisData {
}
/**
* Used to store all arrays created in
* Analysis#createPlayerActivityGraphs().
*
* @return
* 0, 2, 4 contain data. 1, 3, 5 contain labels.
*
* 0, 1 day; 2, 3 week; 4, 5 month
*
* @return String array containing multiple toString representations of
* number & label arrays.
* @see PlayersActivityGraphCreator
* @see Analysis
*/
public String[] getPlayersDataArray() {
return playersDataArray;
}
/**
* Used to store all arrays created in
* Analysis#createPlayerActivityGraphs().
*
* @param playersDataArray
* 0, 2, 4 contain data. 1, 3, 5 contain labels.
*
* 0, 1 day; 2, 3 week; 4, 5 month
*
* @param playersDataArray String array containing multiple toString
* representations of number & label arrays.
* @see PlayersActivityGraphCreator
* @see Analysis
*/
public void setPlayersDataArray(String[] playersDataArray) {
this.playersDataArray = playersDataArray;
}
/**
* Set the total number of unique commands.
*
* @param totalCommands
* No check for correct value.
*
* @param totalCommands 0 to Long.MAX
*/
public void setTotalCommands(long totalCommands) {
this.totalCommands = totalCommands;
}
/**
* Get the total number of unique commands.
*
* @return
* @return 0 to Long.MAX
*/
public long getTotalCommands() {
return totalCommands;
}
/**
* Get the average length of every session on the server.
*
* @return
* @return long in ms.
*/
public long getSessionAverage() {
return sessionAverage;
}
/**
* Set the average length of every session on the server.
*
* @param sessionAverage
* @param sessionAverage 0 to Long.MAX
*/
public void setSessionAverage(long sessionAverage) {
this.sessionAverage = sessionAverage;
}
/**
* Get the integer array containing 3 numbers.
*
* @return
* 0 Male, 1 Female, 2 Unknown.
*
* @return for example [0, 4, 5] when 0 male, 4 female and 5 unknown.
*/
public int[] getGenderData() {
return genderData;
@ -678,7 +845,11 @@ public class AnalysisData {
/**
*
* @param genderData
* Set the integer array containing 3 numbers.
*
* 0 Male, 1 Female, 2 Unknown.
*
* @param genderData for example [0, 4, 5]
*/
public void setGenderData(int[] genderData) {
this.genderData = genderData;

View File

@ -2,10 +2,15 @@ package main.java.com.djrapitops.plan.data;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.api.Gender;
import main.java.com.djrapitops.plan.data.handling.LoginHandling;
/**
* This class is used to store Demographics data inside the UserData.
*
* Originally these data points were created by Plade (Player Demographics).
*
* @author Rsl1122
* @since 2.0.0
*/
public class DemographicsData {
@ -16,9 +21,10 @@ public class DemographicsData {
/**
* Creates demographics data object from existing data.
*
* @param age
* @param gender
* @param geoLocation
* @param age Age, -1 if unknown
* @param gender Gender Enum.
* @param geoLocation Name of the geolocation. Phrase.DEM_UNKNOWN if not
* known.
*/
public DemographicsData(int age, Gender gender, String geoLocation) {
this.age = age;
@ -30,17 +36,21 @@ public class DemographicsData {
* Creates new demographics data object with default parameters.
*/
public DemographicsData() {
this(-1, Gender.UNKNOWN, Phrase.DEM_UNKNOWN+"");
this(-1, Gender.UNKNOWN, Phrase.DEM_UNKNOWN + "");
}
/**
* @return Age of the player, -1 if not known
* Get the age of the player.
*
* @return 1 to 99, -1 if not known
*/
public int getAge() {
return age;
}
/**
* Get the gender of the player.
*
* @return Gender Enum of the Player. UNKNOWN if not known
*/
public Gender getGender() {
@ -48,28 +58,40 @@ public class DemographicsData {
}
/**
* @return Geolocation string of the player "Not known" if not known.
* Get the geolocation string.
*
* @return Geolocation string of the player Phrase.DEM_UNKNOWN if not known.
*/
public String getGeoLocation() {
return geoLocation;
}
/**
* @param age
* Set the age of the player.
*
* @param age 0 to 99, -1 if not known.
*/
public void setAge(int age) {
this.age = age;
}
/**
* @param gender
* Set the gender of the player.
*
* @param gender Gender Enum. UNKNOWN if not known.
*/
public void setGender(Gender gender) {
this.gender = gender;
}
/**
* @param geoLocation
* Set the Geolocation of the player.
*
* LoginHandling.updateGeolocation() is used to get the geolocation
* information.
*
* @param geoLocation Country name, eg. Republic of Kongo, the
* @see LoginHandling
*/
public void setGeoLocation(String geoLocation) {
this.geoLocation = geoLocation;
@ -79,6 +101,4 @@ public class DemographicsData {
public String toString() {
return "{" + "age:" + age + "|gender:" + gender + "|geoLocation:" + geoLocation + '}';
}
}

View File

@ -3,6 +3,8 @@ package main.java.com.djrapitops.plan.data;
import java.util.UUID;
/**
* This class is used to store data about a player kill inside the UserData
* object.
*
* @author Rsl1122
*/
@ -14,11 +16,12 @@ public class KillData {
private final String weapon;
/**
* Creates a KillData object with given parameters.
*
* @param victim
* @param victimID
* @param weapon
* @param date
* @param victim UUID of the victim.
* @param victimID ID of the victim, get from the database.
* @param weapon Weapon used.
* @param date Epoch millisecond at which the kill occurrred.
*/
public KillData(UUID victim, int victimID, String weapon, long date) {
this.victim = victim;
@ -28,32 +31,36 @@ public class KillData {
}
/**
* Get the victim's UUID
*
* @return
* @return UUID of the victim.
*/
public UUID getVictim() {
return victim;
}
/**
* Get the Epoch millisecond the kill occurred.
*
* @return
* @return long in ms.
*/
public long getDate() {
return date;
}
/**
* Get the Weapon used as string.
*
* @return
* @return For example DIAMOND_SWORD
*/
public String getWeapon() {
return weapon;
}
/**
* Get the UserID of the victim, found from the database.
*
* @return
* @return For example: 6
*/
public int getVictimUserID() {
return victimUserID;

View File

@ -6,8 +6,11 @@ import java.util.List;
import java.util.Map;
/**
* This class is used for storing combined data of several UserData objects
* during Analysis.
*
* @author Rsl1122
* @since 2.6.0
*/
public class RawAnalysisData {
@ -36,7 +39,7 @@ public class RawAnalysisData {
private int[] genders;
/**
*
* Constructor for a new empty dataset.
*/
public RawAnalysisData() {
gmZero = 0;

View File

@ -1,6 +1,8 @@
package main.java.com.djrapitops.plan.data;
/**
* This class is used for storing start and end of a playsession inside UserData
* object.
*
* @author Rsl1122
*/
@ -10,8 +12,9 @@ public class SessionData {
private long sessionEnd;
/**
* Creates a new session with given start and end of -1.
*
* @param sessionStart
* @param sessionStart Epoch millisecond the session was started.
*/
public SessionData(long sessionStart) {
this.sessionStart = sessionStart;
@ -19,9 +22,10 @@ public class SessionData {
}
/**
* Creates a new session with given start and end.
*
* @param sessionStart
* @param sessionEnd
* @param sessionStart Epoch millisecond the session was started.
* @param sessionEnd Epoch millisecond the session ended.
*/
public SessionData(long sessionStart, long sessionEnd) {
this.sessionStart = sessionStart;
@ -29,45 +33,52 @@ public class SessionData {
}
/**
* Ends the session with given end point.
*
* @param endOfSession
* (Changes the end to the parameter.).
*
* @param endOfSession Epoch millisecond the session ended.
*/
public void endSession(long endOfSession) {
sessionEnd = endOfSession;
}
/**
* Get the start of the session.
*
* @return
* @return Epoch millisecond the session started.
*/
public long getSessionStart() {
return sessionStart;
}
/**
* Get the end of the session.
*
* @return
* @return Epoch millisecond the session ended.
*/
public long getSessionEnd() {
return sessionEnd;
}
/**
* Get the length of the session in milliseconds.
*
* @return
* @return Long in ms.
*/
public long getLength() {
return sessionEnd-sessionStart;
return sessionEnd - sessionStart;
}
@Override
public String toString() {
return "s:" + sessionStart + " e:" + sessionEnd;
}
/**
* Check if the session start was before the end.
*
* @return
* @return Is the length positive?
*/
public boolean isValid() {
return sessionStart <= sessionEnd;
@ -93,6 +104,4 @@ public class SessionData {
}
return true;
}
}

View File

@ -6,18 +6,19 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/**
* This class is used for storing information about a player during runtime.
*
* @author Rsl1122
*/
@ -29,8 +30,8 @@ public class UserData {
private UUID uuid;
private Location location;
private List<Location> locations;
private HashSet<InetAddress> ips;
private HashSet<String> nicknames;
private Set<InetAddress> ips;
private Set<String> nicknames;
private String lastNick;
private long registered;
private long lastPlayed;
@ -39,7 +40,7 @@ public class UserData {
private int timesKicked;
private long lastGmSwapTime;
private GameMode lastGamemode;
private HashMap<GameMode, Long> gmTimes;
private Map<GameMode, Long> gmTimes;
private boolean isOp;
private boolean isBanned;
private DemographicsData demData;
@ -55,15 +56,28 @@ public class UserData {
private List<SessionData> sessions;
/**
* Creates a new UserData object with given values & default values.
*
* @param uuid
* @param reg
* @param loc
* @param op
* @param lastGM
* @param demData
* @param name
* @param online
* Some variables are left uninitialized: isBanned, lastPlayed, playTime,
* loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths &
* currentSession.
*
* These variables need to be set with setters.
*
* All Collections are left empty: locations, nicknames, ips, sessions,
* playerKills. Because nicknames is empty, lastNick is an empty string.
*
* gmTimes Hashmap will contain 4 '0L' values: SURVIVAL, CREATIVE,
* ADVENTURE, SPECTATOR
*
* @param uuid UUID of the player
* @param reg Epoch millisecond the player registered.
* @param loc Current Location in a world.
* @param op Is the player op? (true/false)
* @param lastGM last GameMode the player was seen in.
* @param demData Demographics data.
* @param name Name of the player.
* @param online Is the player online?
*/
public UserData(UUID uuid, long reg, Location loc, boolean op, GameMode lastGM, DemographicsData demData, String name, boolean online) {
accessing = 0;
@ -93,32 +107,60 @@ public class UserData {
}
/**
* Creates a new UserData object with the variables inside a Player object.
*
* @param player
* @param demData
* Some variables are left uninitialized: lastPlayed, playTime, loginTimes,
* timesKicked, lastGmSwapTime, mobKills, deaths & currentSession.
*
* These variables need to be set with setters.
*
* All Collections are left empty: locations, nicknames, ips, sessions,
* playerKills. Because nicknames is empty, lastNick is an empty string.
*
* gmTimes Hashmap will contain 4 '0L' values: SURVIVAL, CREATIVE,
* ADVENTURE, SPECTATOR
*
* @param player Player object.
* @param demData Demographics data.
*/
public UserData(Player player, DemographicsData demData) {
this(player.getUniqueId(), player.getFirstPlayed(), player.getLocation(), player.isOp(), player.getGameMode(), demData, player.getName(), player.isOnline());
try {
isBanned = player.isBanned();
} catch (Exception e) {
Log.errorMsg("Error getting ban date from Bukkit files. " + uuid.toString());
Log.error("Error getting ban date from Bukkit files. " + uuid.toString());
Log.toLog(this.getClass().getName(), e);
isBanned = false;
}
}
/**
* Creates a new UserData object with the variables inside a OfflinePlayer
* object.
*
* @param player
* @param demData
* Some variables are left uninitialized: location, lastPlayed, playTime,
* loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths &
* currentSession.
*
* These variables need to be set with setters.
*
* All Collections are left empty: locations, nicknames, ips, sessions,
* playerKills. Because nicknames is empty, lastNick is an empty string.
*
* gmTimes Hashmap will contain 4 '0L' values: SURVIVAL, CREATIVE,
* ADVENTURE, SPECTATOR
*
* lastGM will be set as SURVIVAL
*
* @param player OfflinePlayer object.
* @param demData Demographics data.
*/
public UserData(OfflinePlayer player, DemographicsData demData) {
this(player.getUniqueId(), player.getFirstPlayed(), null, player.isOp(), GameMode.SURVIVAL, demData, player.getName(), player.isOnline());
try {
isBanned = player.isBanned();
} catch (Exception e) {
Log.errorMsg("Error getting ban date from Bukkit files. " + uuid.toString());
Log.error("Error getting ban date from Bukkit files. " + uuid.toString());
Log.toLog(this.getClass().getName(), e);
isBanned = false;
}
@ -171,18 +213,20 @@ public class UserData {
}
/**
* Adds an to the ips Set if it is not null or the set doesn't contain it.
*
* @param ip
* @param ip InetAddress of the player.
*/
public void addIpAddress(InetAddress ip) {
if (ip != null && !ips.contains(ip)) {
if (ip != null) {
ips.add(ip);
}
}
/**
* Adds multiple ips to the ips set if they're not null.
*
* @param addIps
* @param addIps a Collection of InetAddresses the player has logged from.
*/
public void addIpAddresses(Collection<InetAddress> addIps) {
ips.addAll(addIps.stream().filter(ip -> ip != null).collect(Collectors.toList()));
@ -190,8 +234,11 @@ public class UserData {
}
/**
* Adds a location to the locations list.
*
* @param loc
* null value filtered. loc will be set as the latest location.
*
* @param loc Location of the player.
*/
public void addLocation(Location loc) {
if (loc != null) {
@ -201,8 +248,11 @@ public class UserData {
}
/**
* Adds multiple locations to the locations list.
*
* @param addLocs
* null value filtered.
*
* @param addLocs Collection of Locations.
*/
public void addLocations(Collection<Location> addLocs) {
if (!addLocs.isEmpty()) {
@ -213,35 +263,43 @@ public class UserData {
}
/**
* Adds a nickname to the nicknames Set.
*
* @param nick
* @return
* null or empty values filtered.
*
* lastNick will be set as the given parameter, if accepted.
*
* @param nick Displayname of the player.
* @return was lastNick updated?
*/
public boolean addNickname(String nick) {
if (!nicknames.contains(nick)) {
if (nick != null) {
if (!nick.isEmpty()) {
nicknames.add(nick);
lastNick = nick;
return true;
}
if (nick != null && !nick.isEmpty()) {
boolean isNew = !nicknames.contains(nick);
nicknames.add(nick);
if (isNew) {
lastNick = nick;
}
return isNew;
}
return false;
}
/**
* Adds nicknames to the nicknames Set.
*
* @param addNicks
* null or empty values filtered.
*
* @param addNicks Collection of nicknames.
*/
public void addNicknames(Collection<String> addNicks) {
nicknames.addAll(addNicks.stream().filter(nick -> nick != null).collect(Collectors.toList()));
nicknames.addAll(addNicks.stream().filter(nick -> nick != null && !nick.isEmpty()).collect(Collectors.toList()));
}
/**
* Set a specific GameMode's millisecond value.
*
* @param gm
* @param time
* @param gm GameMode.
* @param time Milliseconds spent in the gamemode.
*/
public void setGMTime(GameMode gm, long time) {
if (gmTimes == null) {
@ -253,11 +311,12 @@ public class UserData {
}
/**
* Set every GameMode's millisecond value.
*
* @param survivalTime
* @param creativeTime
* @param adventureTime
* @param spectatorTime
* @param survivalTime ms spent in SURVIVAL
* @param creativeTime ms spent in CREATIVE
* @param adventureTime ms spent in ADVENTURE
* @param spectatorTime ms spent in SPECTATOR
*/
public void setAllGMTimes(long survivalTime, long creativeTime, long adventureTime, long spectatorTime) {
gmTimes.clear();
@ -271,8 +330,11 @@ public class UserData {
}
/**
* Adds a new SessionData to the sessions list.
*
* @param session
* null and invalid sessions filtered.
*
* @param session SessionData object
*/
public void addSession(SessionData session) {
if (session != null && session.isValid()) {
@ -281,8 +343,11 @@ public class UserData {
}
/**
* Adds SessionData objects to the sessions list.
*
* @param sessions
* null and invalid sessions filtered.
*
* @param sessions Collection of SessionData objects.
*/
public void addSessions(Collection<SessionData> sessions) {
Collection<SessionData> filteredSessions = sessions.stream()
@ -290,143 +355,175 @@ public class UserData {
.filter(session -> session.isValid())
.collect(Collectors.toList());
if (sessions.size() != filteredSessions.size()) {
Log.debug("Some sessions were filtered! "+getUuid()+": Org:"+sessions.size()+" Fil:"+filteredSessions.size());
Log.debug(getUuid() + ": Some sessions were filtered! Org:" + sessions.size() + " Fil:" + filteredSessions.size());
}
this.sessions.addAll(filteredSessions);
}
/**
* Sets the current session.
*
* @param session
* Currently unused.
*
* @param session SessionData object, no restrictions.
*/
public void setCurrentSession(SessionData session) {
currentSession = session;
}
/**
* Gets the current session.
*
* @return
* Currently unused.
*
* @return SessionData object with a recent start.
*/
public SessionData getCurrentSession() {
return currentSession;
}
/**
* Changes the value of isBanned.
*
* @param isBanned
* @param isBanned Is the player banned?
*/
public void updateBanned(boolean isBanned) {
this.isBanned = isBanned;
}
/**
* Checks whether or not the UserData object is accessed by different save
* processes.
*
* @return
* @return true if accessed.
*/
public boolean isAccessed() {
return accessing > 0;
}
/**
*
* Accesses the UserData object to protect it from being cleared.
*/
public void access() {
accessing++;
}
/**
*
* Stops accessing the object so that it can now be cleared.
*/
public void stopAccessing() {
accessing--;
}
// Getters -------------------------------------------------------------
/**
* Used to get the UUID of the player.
*
* @return
* @return UUID.
*/
public UUID getUuid() {
return uuid;
}
/**
* Used to get the latest location.
*
* @return
* NOT INITIALIZED BY CONSTRUCTORS
*
* @return Location.
*/
public Location getLocation() {
return location;
}
/**
* Get the list of all locations inside the UserData object.
*
* @return
* @return a list of Locations.
*/
public List<Location> getLocations() {
return locations;
}
/**
* Get the InetAddress Set.
*
* @return
* @return a HashSet of ips.
*/
public HashSet<InetAddress> getIps() {
public Set<InetAddress> getIps() {
return ips;
}
/**
* Get the nickname String Set
*
* @return
* @return a HashSet of Strings.
*/
public HashSet<String> getNicknames() {
public Set<String> getNicknames() {
return nicknames;
}
/**
* Get the Epoch millisecond the player registered.
*
* @return
* @return long in ms.
*/
public long getRegistered() {
return registered;
}
/**
* Get the Epoch millisecond the player was last seen.
*
* @return
* NOT INITIALIZED BY CONSTRUCTORS. Value is updated periodically by cache
* if the player is online.
*
* @return long in ms.
*/
public long getLastPlayed() {
return lastPlayed;
}
/**
* Get the playtime in milliseconds.
*
* @return
* NOT INITIALIZED BY CONSTRUCTORS. Value is updated periodically by cache
* if the player is online.
*
* @return time in ms.
*/
public long getPlayTime() {
return playTime;
}
/**
* Get how many times the player has logged in.
*
* @return
* NOT INITIALIZED BY CONSTRUCTORS.
*
* @return 0 to Integer.MAX
*/
public int getLoginTimes() {
return loginTimes;
}
/**
* Get how many times the player has been kicked.
*
* @return
* NOT INITIALIZED BY CONSTRUCTORS.
*
* @return 0 to Integer.MAX
*/
public int getTimesKicked() {
return timesKicked;
}
/**
* Get the GMTimes Map.
*
* @return
* @return a GameMode map with 4 keys: SURVIVAL, CREATIVE, ADVENTURE,
* SPECTATOR.
*/
public HashMap<GameMode, Long> getGmTimes() {
public Map<GameMode, Long> getGmTimes() {
if (gmTimes == null) {
gmTimes = new HashMap<>();
}
@ -434,265 +531,325 @@ public class UserData {
}
/**
* Get the last time a Gamemode time was updated.
*
* @return
* @return Epoch millisecond of last GM Time update.
*/
public long getLastGmSwapTime() {
return lastGmSwapTime;
}
/**
* Get the last Gamemode that the user was seen in.
*
* @return
* When player changes to SURVIVAL this is set to SURVIVAL.
*
* @return Gamemode.
*/
public GameMode getLastGamemode() {
return lastGamemode;
}
/**
* Is the user Operator?
*
* @return
* @return opped?
*/
public boolean isOp() {
return isOp;
}
/**
* Is the user Banned?
*
* @return
* @return banned?
*/
public boolean isBanned() {
return isBanned;
}
/**
* Get the DemographicsData of the user.
*
* @return
* @return Demographics data.
*/
public DemographicsData getDemData() {
return demData;
}
/**
* Get the username of the player.
*
* @return
* @return username.
*/
public String getName() {
return name;
}
// Setters -------------------------------------------------------------
/**
* Set the UUID.
*
* @param uuid
* @param uuid UUID
*/
public void setUuid(UUID uuid) {
this.uuid = uuid;
}
/**
* Set the current location.
*
* @param location
* Not in use.
*
* @param location a location in the world.
*/
public void setLocation(Location location) {
this.location = location;
}
/**
* Set the list of locations the user has been in.
*
* @param locations
* Not in use.
*
* @param locations a list of Locations.
*/
public void setLocations(List<Location> locations) {
this.locations = locations;
if (locations != null) {
this.locations = locations;
}
}
/**
* Set the ips set.
*
* @param ips
* @param ips ips of the user.
*/
public void setIps(HashSet<InetAddress> ips) {
this.ips = ips;
public void setIps(Set<InetAddress> ips) {
if (ips != null) {
this.ips = ips;
}
}
/**
* Set the nicknames set.
*
* @param nicknames
* @param nicknames nicknames of the user.
*/
public void setNicknames(HashSet<String> nicknames) {
this.nicknames = nicknames;
public void setNicknames(Set<String> nicknames) {
if (nicknames != null) {
this.nicknames = nicknames;
}
}
/**
* Set the time the user was registered.
*
* @param registered
* @param registered Epoch millisecond of register time.
*/
public void setRegistered(long registered) {
this.registered = registered;
}
/**
* Set the time the user was last seen.
*
* @param lastPlayed
* Affects playtime calculation, playtime should be updated before updating
* this value.
*
* @param lastPlayed Epoch millisecond of last seen moment.
*/
public void setLastPlayed(long lastPlayed) {
this.lastPlayed = lastPlayed;
}
/**
* Set the time the user has been playing.
*
* @param playTime
* @param playTime Time in ms.
*/
public void setPlayTime(long playTime) {
this.playTime = playTime;
}
/**
* Set how many times the user has logged in.
*
* @param loginTimes
* No check for input.
*
* @param loginTimes 0 to Int.MAX
*/
public void setLoginTimes(int loginTimes) {
this.loginTimes = loginTimes;
}
/**
* Set how many times the user has been kicked.
*
* @param timesKicked
* No check for input.
*
* @param timesKicked 0 to Int.MAX
*/
public void setTimesKicked(int timesKicked) {
this.timesKicked = timesKicked;
}
/**
* Set the GM Times map containing playtime in each gamemode.
*
* @param gmTimes
* @param gmTimes Map containing SURVIVAL, CREATIVE, ADVENTURE & SPECTATOR
* (After 1.8) keys.
*/
public void setGmTimes(HashMap<GameMode, Long> gmTimes) {
this.gmTimes = gmTimes;
public void setGmTimes(Map<GameMode, Long> gmTimes) {
if (gmTimes != null) {
this.gmTimes = gmTimes;
}
}
/**
* Set the last time a Gamemode time was updated.
*
* @param lastGmSwapTime
* @param lastGmSwapTime Epoch millisecond a gm time was updated.
*/
public void setLastGmSwapTime(long lastGmSwapTime) {
this.lastGmSwapTime = lastGmSwapTime;
}
/**
* Set the last gamemode the user was seen in.
*
* @param lastGamemode
* @param lastGamemode gamemode.
*/
public void setLastGamemode(GameMode lastGamemode) {
this.lastGamemode = lastGamemode;
}
/**
* Set whether or not player is op.
*
* @param isOp
* @param isOp operator?
*/
public void setIsOp(boolean isOp) {
this.isOp = isOp;
}
/**
* Set the DemographicsData of the user.
*
* @param demData
* @param demData demographics data.
*/
public void setDemData(DemographicsData demData) {
this.demData = demData;
}
/**
* Set the username of the user.
*
* @param name
* @param name username.
*/
public void setName(String name) {
this.name = name;
}
/**
* Is the player online?
*
* @return
* @return true if data is cached to datacache, false if not.
*/
public boolean isOnline() {
return isOnline;
}
/**
* Get how many mob kills the player has.
*
* @return
* @return 0 to Int.MAX
*/
public int getMobKills() {
return mobKills;
}
/**
* Get how many mob kills the player has.
*
* @param mobKills
* @param mobKills 0 to Int.MAX
*/
public void setMobKills(int mobKills) {
this.mobKills = mobKills;
}
/**
* Get the player kills list.
*
* @return
* @return playerkills list.
*/
public List<KillData> getPlayerKills() {
return playerKills;
}
/**
* Set the playerkills list.
*
* @param playerKills
* @param playerKills list of players kills.
*/
public void setPlayerKills(List<KillData> playerKills) {
this.playerKills = playerKills;
if (playerKills != null) {
this.playerKills = playerKills;
}
}
/**
* Add a Killdata to player's kills list.
*
* @param kill
* @param kill KillData representing a player kill.
*/
public void addPlayerKill(KillData kill) {
playerKills.add(kill);
}
/**
* Get how many times the player has died.
*
* @return
* @return 0 to Int.MAX
*/
public int getDeaths() {
return deaths;
}
/**
* Set how many times the player has died.
*
* @param deaths
* @param deaths 0 to Int.MAX
*/
public void setDeaths(int deaths) {
this.deaths = deaths;
}
/**
* Get the sessions of a player.
*
* @return
* @return a list of SessionData.
*/
public List<SessionData> getSessions() {
return sessions;
}
/**
* Get the last nickname the user has set.
*
* @return
* Set when using addNickname(String)
*
* @return last nickname used.
*/
public String getLastNick() {
return lastNick;
}
/**
* Set the last nickname the user has set.
*
* @param lastNick
* Also set when using addNickname(String)
*
* @param lastNick last nickname used.
*/
public void setLastNick(String lastNick) {
this.lastNick = lastNick;
@ -764,10 +921,22 @@ public class UserData {
return true;
}
/**
* Check wether or not the object should be cleared from cache after it has
* been saved.
*
* @return true/false
*/
public boolean shouldClearAfterSave() {
return clearAfterSave;
}
/**
* Set wether or not the object should be cleared from cache after it has
* been saved.
*
* @param clearAfterSave true/false
*/
public void setClearAfterSave(boolean clearAfterSave) {
this.clearAfterSave = clearAfterSave;
}

View File

@ -24,12 +24,12 @@ import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.utilities.NewPlayerCreator;
import main.java.com.djrapitops.plan.utilities.comparators.HandlingInfoTimeComparator;
import org.bukkit.Bukkit;
import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import static org.bukkit.Bukkit.getOfflinePlayer;
/**
*
@ -76,7 +76,7 @@ public class DataCacheHandler extends LocationCache {
commandUse = new HashMap<>();
if (!getCommandUseFromDb()) {
plugin.logError(Phrase.DB_FAILURE_DISABLE + "");
Log.error(Phrase.DB_FAILURE_DISABLE + "");
plugin.getServer().getPluginManager().disablePlugin(plugin);
return;
}
@ -92,7 +92,7 @@ public class DataCacheHandler extends LocationCache {
commandUse = db.getCommandUse();
return true;
} catch (SQLException e) {
plugin.toLog(this.getClass().getName(), e);
Log.toLog(this.getClass().getName(), e);
}
return false;
}
@ -151,14 +151,14 @@ public class DataCacheHandler extends LocationCache {
* of DataCacheHandler
*/
public void getUserDataForProcessing(DBCallableProcessor processor, UUID uuid, boolean cache) {
Log.debug(uuid+": HANDLER getForProcess,"+" Cache:"+cache);
UserData uData = dataCache.get(uuid);
if (uData == null) {
if (cache) {
DBCallableProcessor cacher = new DBCallableProcessor() {
@Override
public void process(UserData data) {
dataCache.put(uuid, data);
Log.info(Phrase.CACHE_ADD.parse(uuid.toString()));
cache(data);
}
};
getTask.scheduleForGet(uuid, cacher, processor);
@ -170,6 +170,11 @@ public class DataCacheHandler extends LocationCache {
}
}
public void cache(UserData data) {
dataCache.put(data.getUuid(), data);
Log.info(Phrase.CACHE_ADD.parse(data.getUuid().toString()));
}
/**
** Uses Database to retrieve the UserData of a matching player Caches the
* data to the HashMap
@ -192,7 +197,7 @@ public class DataCacheHandler extends LocationCache {
try {
db.saveMultipleUserData(data);
} catch (SQLException ex) {
plugin.toLog(this.getClass().getName(), ex);
Log.toLog(this.getClass().getName(), ex);
}
}
@ -201,7 +206,7 @@ public class DataCacheHandler extends LocationCache {
* @param i
*/
public void addToPool(HandlingInfo i) {
Log.debug("Adding to pool, type:" + i.getType().name() + " " + i.getUuid());
Log.debug(i.getUuid()+ ": Adding to pool, type:" + i.getType().name());
processTask.addToPool(i);
}
@ -244,7 +249,7 @@ public class DataCacheHandler extends LocationCache {
db.saveCommandUse(commandUse);
db.close();
} catch (SQLException e) {
plugin.toLog(this.getClass().getName(), e);
Log.toLog(this.getClass().getName(), e);
}
Log.debug("SaveCacheOnDisable_END");
}
@ -273,7 +278,7 @@ public class DataCacheHandler extends LocationCache {
* @param uuid Player's UUID
*/
public void saveCachedData(UUID uuid) {
Log.debug("SaveCachedData: " + uuid);
Log.debug(uuid+": SaveCachedData");
DBCallableProcessor saveProcessor = new DBCallableProcessor() {
@Override
public void process(UserData data) {
@ -298,7 +303,7 @@ public class DataCacheHandler extends LocationCache {
try {
db.saveCommandUse(commandUse);
} catch (SQLException | NullPointerException e) {
plugin.toLog(this.getClass().getName(), e);
Log.toLog(this.getClass().getName(), e);
}
}
@ -330,9 +335,9 @@ public class DataCacheHandler extends LocationCache {
* @param uuid Player's UUID
*/
public void clearFromCache(UUID uuid) {
Log.debug("Clear: " + uuid);
Log.debug(uuid+": Clear");
if (getOfflinePlayer(uuid).isOnline()) {
Log.debug("Online, did not clear: " + uuid);
Log.debug(uuid+": Online, did not clear");
UserData data = dataCache.get(uuid);
if (data != null) {
data.setClearAfterSave(false);
@ -392,6 +397,7 @@ public class DataCacheHandler extends LocationCache {
*/
public void newPlayer(UserData data) {
saveTask.scheduleNewPlayer(data);
cache(data);
}
/**

View File

@ -28,7 +28,7 @@ public class SessionCache {
*/
public void startSession(UUID uuid) {
long now = new Date().getTime();
Log.debug("Starting a session: "+uuid+" "+now);
Log.debug(uuid+": Starting a session: "+now);
SessionData session = new SessionData(now);
activeSessions.put(uuid, session);
}
@ -41,7 +41,7 @@ public class SessionCache {
SessionData currentSession = activeSessions.get(uuid);
if (currentSession != null) {
long now = new Date().getTime();
Log.debug("Ending a session: "+uuid+" "+now);
Log.debug(uuid+": Ending a session: "+now);
currentSession.endSession(now);
}
}

View File

@ -9,8 +9,6 @@ import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
import static org.bukkit.Bukkit.getOfflinePlayer;
/**
*
@ -37,7 +35,7 @@ public class DataCacheClearQueue {
* @param uuid
*/
public void scheduleForClear(UUID uuid) {
Log.debug("Scheduling for clear: " + uuid);
Log.debug(uuid+": Scheduling for clear");
q.add(uuid);
}
@ -53,7 +51,7 @@ public class DataCacheClearQueue {
try {
q.addAll(uuids);
} catch (IllegalStateException e) {
getPlugin(Plan.class).logError(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Clear Queue", Settings.PROCESS_CLEAR_LIMIT.getNumber() + ""));
Log.error(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Clear Queue", Settings.PROCESS_CLEAR_LIMIT.getNumber() + ""));
}
}
@ -61,14 +59,18 @@ public class DataCacheClearQueue {
*
*/
public void stop() {
s.stop();
if (s != null) {
s.stop();
}
s = null;
q.clear();
}
}
class ClearConsumer implements Runnable {
private final BlockingQueue<UUID> queue;
private final DataCacheHandler handler;
private DataCacheHandler handler;
private boolean run;
ClearConsumer(BlockingQueue q, DataCacheHandler handler) {
@ -88,6 +90,9 @@ class ClearConsumer implements Runnable {
}
void consume(UUID uuid) {
if (handler == null) {
return;
}
try {
if (handler.isDataAccessed(uuid)) {
queue.add(uuid);
@ -96,12 +101,15 @@ class ClearConsumer implements Runnable {
}
// if online remove from clear list
} catch (Exception ex) {
getPlugin(Plan.class).toLog(this.getClass().getName(), ex);
Log.toLog(this.getClass().getName(), ex);
}
}
void stop() {
run = false;
if (handler != null) {
handler = null;
}
}
}

View File

@ -14,7 +14,6 @@ import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
import main.java.com.djrapitops.plan.database.Database;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/**
*
@ -41,7 +40,7 @@ public class DataCacheGetQueue {
* @param processors
*/
public void scheduleForGet(UUID uuid, DBCallableProcessor... processors) {
Log.debug("Scheduling for get: "+uuid);
Log.debug(uuid + ": Scheduling for get");
try {
HashMap<UUID, List<DBCallableProcessor>> map = new HashMap<>();
if (map.get(uuid) == null) {
@ -50,7 +49,7 @@ public class DataCacheGetQueue {
map.get(uuid).addAll(Arrays.asList(processors));
q.add(map);
} catch (IllegalStateException e) {
getPlugin(Plan.class).logError(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Get Queue", Settings.PROCESS_GET_LIMIT.getNumber()+""));
Log.error(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Get Queue", Settings.PROCESS_GET_LIMIT.getNumber() + ""));
}
}
@ -58,14 +57,18 @@ public class DataCacheGetQueue {
*
*/
public void stop() {
s.stop();
if (s != null) {
s.stop();
}
s = null;
q.clear();
}
}
class GetConsumer implements Runnable {
private final BlockingQueue<HashMap<UUID, List<DBCallableProcessor>>> queue;
private final Database db;
private Database db;
private boolean run;
GetConsumer(BlockingQueue q, Database db) {
@ -85,6 +88,9 @@ class GetConsumer implements Runnable {
}
void consume(HashMap<UUID, List<DBCallableProcessor>> processors) {
if (db == null) {
return;
}
try {
for (UUID uuid : processors.keySet()) {
if (uuid == null) {
@ -92,7 +98,7 @@ class GetConsumer implements Runnable {
}
List<DBCallableProcessor> processorsList = processors.get(uuid);
if (processorsList != null) {
Log.debug("Get: "+uuid+" For:"+ processorsList.size());
Log.debug(uuid+ ": Get, For:" + processorsList.size());
try {
db.giveUserDataToProcessors(uuid, processorsList);
} catch (SQLException e) {
@ -107,6 +113,9 @@ class GetConsumer implements Runnable {
void stop() {
run = false;
if (db != null) {
db = null;
}
}
}

View File

@ -19,19 +19,17 @@ import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
*/
public class DataCacheProcessQueue {
private BlockingQueue<HandlingInfo> q;
private DataCacheHandler h;
private ProcessSetup s;
private BlockingQueue<HandlingInfo> queue;
private ProcessSetup setup;
/**
*
* @param handler
*/
public DataCacheProcessQueue(DataCacheHandler handler) {
h = handler;
q = new ArrayBlockingQueue(20000);
s = new ProcessSetup();
s.go(q, h);
queue = new ArrayBlockingQueue(20000);
setup = new ProcessSetup();
setup.go(queue, handler);
}
/**
@ -40,7 +38,7 @@ public class DataCacheProcessQueue {
*/
public void addToPool(HandlingInfo info) {
try {
q.add(info);
queue.add(info);
} catch (IllegalStateException e) {
// getPlugin(Plan.class).logError(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber() + ""));
}
@ -52,7 +50,7 @@ public class DataCacheProcessQueue {
*/
public void addToPool(Collection<HandlingInfo> info) {
try {
q.addAll(info);
queue.addAll(info);
} catch (IllegalStateException e) {
// getPlugin(Plan.class).logError(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber() + ""));
}
@ -64,7 +62,7 @@ public class DataCacheProcessQueue {
* @return
*/
public boolean containsUUID(UUID uuid) {
return new ArrayList<>(q).stream().map(d -> d.getUuid()).collect(Collectors.toList()).contains(uuid);
return new ArrayList<>(queue).stream().map(d -> d.getUuid()).collect(Collectors.toList()).contains(uuid);
}
/**
@ -72,14 +70,23 @@ public class DataCacheProcessQueue {
* @return
*/
public List<HandlingInfo> stop() {
return s.stop();
try {
if (setup != null) {
setup.stop();
return new ArrayList<>(queue);
}
return new ArrayList<>();
} finally {
setup = null;
queue.clear();
}
}
}
class ProcessConsumer implements Runnable {
private final BlockingQueue<HandlingInfo> queue;
private final DataCacheHandler handler;
private DataCacheHandler handler;
private boolean run;
ProcessConsumer(BlockingQueue q, DataCacheHandler h) {
@ -99,21 +106,26 @@ class ProcessConsumer implements Runnable {
}
void consume(HandlingInfo info) {
Log.debug("Processing type: " + info.getType().name() + " " + info.getUuid());
if (handler == null) {
return;
}
Log.debug(info.getUuid()+": Processing type: " + info.getType().name());
DBCallableProcessor p = new DBCallableProcessor() {
@Override
public void process(UserData data) {
if (!info.process(data)) {
System.out.println("Attempted to process data for wrong uuid: W:" + data.getUuid() + " | R:" + info.getUuid() + " Type:" + info.getType().name());
Log.error("Attempted to process data for wrong uuid: W:" + data.getUuid() + " | R:" + info.getUuid() + " Type:" + info.getType().name());
}
}
};
handler.getUserDataForProcessing(p, info.getUuid());
}
Collection<HandlingInfo> stop() {
void stop() {
run = false;
return queue;
if (handler != null) {
handler = null;
}
}
}
@ -129,9 +141,8 @@ class ProcessSetup {
new Thread(two).start();
}
List<HandlingInfo> stop() {
List<HandlingInfo> i = new ArrayList<>(one.stop());
i.addAll(two.stop());
return i;
void stop() {
one.stop();
two.stop();
}
}

View File

@ -13,7 +13,6 @@ import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.database.Database;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/**
*
@ -27,6 +26,7 @@ public class DataCacheSaveQueue {
/**
*
* @param plugin
* @param clear
*/
public DataCacheSaveQueue(Plan plugin, DataCacheClearQueue clear) {
q = new ArrayBlockingQueue(Settings.PROCESS_SAVE_LIMIT.getNumber());
@ -39,11 +39,11 @@ public class DataCacheSaveQueue {
* @param data
*/
public void scheduleForSave(UserData data) {
Log.debug("Scheduling for save: "+data.getUuid());
Log.debug(data.getUuid()+": Scheduling for save");
try {
q.add(data);
} catch (IllegalStateException e) {
getPlugin(Plan.class).logError(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber() + ""));
Log.error(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber() + ""));
}
}
@ -56,7 +56,7 @@ public class DataCacheSaveQueue {
try {
q.addAll(data);
} catch (IllegalStateException e) {
getPlugin(Plan.class).logError(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber() + ""));
Log.error(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber() + ""));
}
}
@ -65,11 +65,11 @@ public class DataCacheSaveQueue {
* @param data
*/
public void scheduleNewPlayer(UserData data) {
Log.debug("Scheduling new Player: "+data.getUuid());
Log.debug(data.getUuid()+": Scheduling new Player");
try {
q.add(data);
} catch (IllegalStateException e) {
getPlugin(Plan.class).logError(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber() + ""));
Log.error(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber() + ""));
}
}
@ -86,15 +86,19 @@ public class DataCacheSaveQueue {
*
*/
public void stop() {
s.stop();
if (s != null) {
s.stop();
}
s = null;
q.clear();
}
}
class SaveConsumer implements Runnable {
private final BlockingQueue<UserData> queue;
private final Database db;
private final DataCacheClearQueue clear;
private Database db;
private DataCacheClearQueue clear;
private boolean run;
SaveConsumer(BlockingQueue q, DataCacheClearQueue clear, Database db) {
@ -115,14 +119,19 @@ class SaveConsumer implements Runnable {
}
void consume(UserData data) {
if (db == null) {
return;
}
UUID uuid = data.getUuid();
Log.debug("Saving: "+uuid);
Log.debug(uuid+": Saving: "+uuid);
try {
db.saveUserData(uuid, data);
data.stopAccessing();
Log.debug("Saved! "+uuid);
Log.debug(uuid+": Saved!");
if (data.shouldClearAfterSave()) {
clear.scheduleForClear(uuid);
if (clear != null) {
clear.scheduleForClear(uuid);
}
}
} catch (SQLException ex) {
// queue.add(data);
@ -132,6 +141,12 @@ class SaveConsumer implements Runnable {
void stop() {
run = false;
if (db != null) {
db = null;
}
if (clear != null) {
clear = null;
}
}
}

View File

@ -5,7 +5,7 @@
*/
package main.java.com.djrapitops.plan.data.handling;
import java.util.HashMap;
import java.util.Map;
import main.java.com.djrapitops.plan.data.UserData;
import org.bukkit.GameMode;
@ -31,7 +31,7 @@ public class GamemodeHandling {
data.setLastGamemode(newGM);
}
lastGamemode = data.getLastGamemode();
HashMap<GameMode, Long> times = data.getGmTimes();
Map<GameMode, Long> times = data.getGmTimes();
Long currentGMTime = times.get(lastGamemode);
if (currentGMTime == null) {
currentGMTime = 0L;

View File

@ -1,8 +1,3 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.com.djrapitops.plan.data.handling;
import java.io.BufferedReader;

View File

@ -55,7 +55,7 @@ public class PlanPlayerListener implements Listener {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
handler.startSession(uuid);
Log.debug("PlayerJoinEvent: "+uuid);
Log.debug(uuid+": PlayerJoinEvent");
BukkitTask asyncNewPlayerCheckTask = (new BukkitRunnable() {
@Override
public void run() {
@ -68,11 +68,11 @@ public class PlanPlayerListener implements Listener {
} else {
handler.addToPool(loginInfo);
}
Log.debug("PlayerJoinEvent_AsyncTask_END: "+uuid+" New:"+isNewPlayer);
Log.debug(uuid+": PlayerJoinEvent_AsyncTask_END, New:"+isNewPlayer);
this.cancel();
}
}).runTaskAsynchronously(plugin);
Log.debug("PlayerJoinEvent_END: "+uuid);
Log.debug(uuid+": PlayerJoinEvent_END");
}
/**
@ -88,10 +88,10 @@ public class PlanPlayerListener implements Listener {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
handler.endSession(uuid);
Log.debug("PlayerQuitEvent: "+uuid);
Log.debug(uuid+": PlayerQuitEvent");
handler.addToPool(new LogoutInfo(uuid, new Date().getTime(), player.isBanned(), player.getGameMode(), handler.getSession(uuid)));
handler.saveCachedData(uuid);
Log.debug("PlayerQuitEvent_END: "+uuid);
Log.debug(uuid+": PlayerQuitEvent_END");
}
/**

View File

@ -7,6 +7,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import main.java.com.djrapitops.plan.Log;
@ -21,7 +22,6 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitRunnable;
import static org.bukkit.Bukkit.getOfflinePlayer;
import static org.bukkit.Bukkit.getOfflinePlayer;
/**
*
@ -395,7 +395,7 @@ public abstract class SQLDB extends Database {
}
}
if (!exceptions.isEmpty()) {
Log.errorMsg("SEVERE: MULTIPLE ERRORS OCCURRED: " + exceptions.size());
Log.error("SEVERE: MULTIPLE ERRORS OCCURRED: " + exceptions.size());
Log.toLog(this.getClass().getName(), exceptions);
}
}
@ -444,7 +444,7 @@ public abstract class SQLDB extends Database {
* @throws SQLException
*/
@Deprecated
public void saveNickList(int userId, HashSet<String> names, String lastNick) throws SQLException {
public void saveNickList(int userId, Set<String> names, String lastNick) throws SQLException {
nicknamesTable.saveNickList(userId, names, lastNick);
}
@ -478,7 +478,7 @@ public abstract class SQLDB extends Database {
* @throws SQLException
*/
@Deprecated
public void saveIPList(int userId, HashSet<InetAddress> ips) throws SQLException {
public void saveIPList(int userId, Set<InetAddress> ips) throws SQLException {
ipsTable.saveIPList(userId, ips);
}
@ -489,7 +489,7 @@ public abstract class SQLDB extends Database {
* @throws SQLException
*/
@Deprecated
public void saveGMTimes(int userId, HashMap<GameMode, Long> gamemodeTimes) throws SQLException {
public void saveGMTimes(int userId, Map<GameMode, Long> gamemodeTimes) throws SQLException {
gmTimesTable.saveGMTimes(userId, gamemodeTimes);
}

View File

@ -4,8 +4,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Map;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.database.databases.SQLDB;
import org.bukkit.GameMode;
@ -90,7 +89,7 @@ public class GMTimesTable extends Table {
}
}
public void saveGMTimes(int userId, HashMap<GameMode, Long> gamemodeTimes) throws SQLException {
public void saveGMTimes(int userId, Map<GameMode, Long> gamemodeTimes) throws SQLException {
if (gamemodeTimes == null || gamemodeTimes.isEmpty()) {
return;
}
@ -127,7 +126,7 @@ public class GMTimesTable extends Table {
}
}
private void addNewGMTimesRow(int userId, HashMap<GameMode, Long> gamemodeTimes) throws SQLException {
private void addNewGMTimesRow(int userId, Map<GameMode, Long> gamemodeTimes) throws SQLException {
PreparedStatement statement = null;
GameMode[] gms = new GameMode[]{GameMode.SURVIVAL, GameMode.CREATIVE, GameMode.ADVENTURE, GameMode.SPECTATOR};
try {

View File

@ -6,8 +6,8 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.database.databases.SQLDB;
@ -79,7 +79,7 @@ public class IPsTable extends Table {
}
}
public void saveIPList(int userId, HashSet<InetAddress> ips) throws SQLException {
public void saveIPList(int userId, Set<InetAddress> ips) throws SQLException {
if (ips == null) {
return;
}

View File

@ -4,8 +4,8 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.database.databases.SQLDB;
@ -106,7 +106,7 @@ public class NicknamesTable extends Table {
}
}
public void saveNickList(int userId, HashSet<String> names, String lastNick) throws SQLException {
public void saveNickList(int userId, Set<String> names, String lastNick) throws SQLException {
if (names == null || names.isEmpty()) {
return;
}

View File

@ -14,379 +14,80 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
*/
public enum Html {
/**
*
*/
REPLACE0("REPLACE0"),
/**
*
*/
REPLACE1("REPLACE1"),
/**
*
*/
WARN_INACCURATE("<div class=\"warn\">Data might be inaccurate, player has just registered.</div>"),
/**
*
*/
COLOR_0("<span class=\"black\">"),
/**
*
*/
COLOR_1("<span class=\"darkblue\">"),
/**
*
*/
COLOR_2("<span class=\"darkgreen\">"),
/**
*
*/
COLOR_3("<span class=\"darkaqua\">"),
/**
*
*/
COLOR_4("<span class=\"darkred\">"),
/**
*
*/
COLOR_5("<span class=\"darkpurple\">"),
/**
*
*/
COLOR_6("<span class=\"gold\">"),
/**
*
*/
COLOR_7("<span class=\"gray\">"),
/**
*
*/
COLOR_8("<span class=\"darkgray\">"),
/**
*
*/
COLOR_9("<span class=\"blue\">"),
/**
*
*/
COLOR_a("<span class=\"green\">"),
/**
*
*/
COLOR_b("<span class=\"aqua\">"),
/**
*
*/
COLOR_c("<span class=\"red\">"),
/**
*
*/
COLOR_d("<span class=\"pink\">"),
/**
*
*/
COLOR_e("<span class=\"yellow\">"),
/**
*
*/
COLOR_f("<span class=\"white\">"),
/**
*
*/
SPAN("" + REPLACE0 + "</span>"),
/**
*
*/
BUTTON("<a class=\"button\" href=\"" + REPLACE0 + "\">" + REPLACE1 + "</a>"),
/**
*
*/
BUTTON_CLASS("class=\"button\""),
/**
*
*/
LINK("<a class=\"link\" href=\"" + REPLACE0 + "\">" + REPLACE1 + "</a>"),
/**
*
*/
LINK_CLASS("class=\"link\""),
/**
*
*/
IMG("<img src=\"" + REPLACE0 + "\">"),
/**
*
*/
TOP_TOWNS("<p><b>Top 20 Towns</b></p>"),
/**
*
*/
TOP_FACTIONS("<p><b>Top 20 Factions</b></p>"),
/**
*
*/
TOTAL_BALANCE("<p>Server Total Balance: " + REPLACE0 + "</p>"),
/**
*
*/
TOTAL_VOTES("<p>Players have voted total of " + REPLACE0 + " times.</p>"),
/**
*
*/
PLOT_OPTIONS("<p>Plot options: " + REPLACE0 + "</p>"),
/**
*
*/
FRIENDS("<p>Friends with " + REPLACE0 + "</p>"),
/**
*
*/
BALANCE("<p>Balance: " + REPLACE0 + "</p>"),
/**
*
*/
BANNED("| " + SPAN.parse(COLOR_4.parse() + "Banned")),
/**
*
*/
OPERATOR(", Operator (Op)"),
/**
*
*/
ONLINE("| " + SPAN.parse(COLOR_2.parse() + "Online")),
/**
*
*/
OFFLINE("| " + SPAN.parse(COLOR_4.parse() + "Offline")),
/**
*
*/
ACTIVE("Player is Active"),
/**
*
*/
INACTIVE("Player is inactive"),
/**
*
*/
ERROR_LIST("Error Creating List</p>"),
/**
*
*/
HIDDEN("Hidden (config)"),
/**
*
*/
ERROR_NOT_SET("Error: Replace rule was not set"),
/**
*
*/
FACTION_NOT_FOUND("Faction not found"),
/**
*
*/
FACTION_NO_LEADER("No leader"),
/**
*
*/
FACTION_NO_FACTIONS("No Factions"),
/**
*
*/
WARPS("<br/>Warps: " + REPLACE0),
/**
*
*/
ACHIEVEMENTS("<br/>Achievements: " + REPLACE0 + "/" + REPLACE1),
/**
*
*/
JAILED("| Jailed"),
/**
*
*/
MUTED("| Muted"),
/**
*
*/
VOTES("<br/>Has voted " + REPLACE0 + "times"),
/**
*
*/
FACTION("<br/>Faction: " + REPLACE0 + " | Power: " + REPLACE1 + "/REPLACE2"),
/**
*
*/
TOWN("<br/>Town: " + REPLACE0),
/**
*
*/
TOWN_NO_TOWNS("No Towns"),
/**
*
*/
GRAPH_BANNED("Banned"),
/**
*
*/
GRAPH_UNKNOWN("Unknown"),
/**
*
*/
GRAPH_INACTIVE("Inactive"),
/**
*
*/
GRAPH_ACTIVE("Active"),
/**
*
*/
GRAPH_ONLINE("Players Online"),
/**
*
*/
GRAPH_PLAYERS("Players"),
/**
*
*/
GRAPH_DATE("Date"),
/**
*
*/
TABLE_START_3("<table class=\"sortable table\"><thead><tr><th>REPLACE0</th><th>REPLACE1</th><th>REPLACE2</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_KILLS_START(TABLE_START_3.parse("Date", "Killed", "With")),
/**
*
*/
TABLE_FACTIONS_START(TABLE_START_4.parse("Faction", "Power", "Land", "Leader")),
/**
*
*/
TABLE_TOWNS_START(TABLE_START_4.parse("Town", "Residents", "Land", "Mayor")),
/**
*
*/
TABLELINE_2("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td></tr>"),
/**
*
*/
TABLELINE_3("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td><td>REPLACE2</td></tr>"),
/**
*
*/
TABLELINE_4("<tr><td><b>" + REPLACE0 + "</b></td><td>" + REPLACE1 + "</td><td>REPLACE2</td><td>REPLACE3</td></tr>"),
/**
*
*/
TABLELINE_PLAYERS("<tr><td>REPLACE0</td><td>REPLACE1</td><td sorttable_customkey=\"REPLACE2\">REPLACE3</td><td>REPLACE4</td><td sorttable_customkey=\"REPLACE5\">REPLACE6</td>" + "<td sorttable_customkey=\"REPLACE7\">REPLACE8</td><td>REPLACE9</td></tr>"),
/**
*
*/
TABLELINE_3_CUSTOMKEY("<tr><td sorttable_customkey=\"REPLACE0\">REPLACE1</td><td sorttable_customkey=\"REPLACE2\">REPLACE3</td><td sorttable_customkey=\"REPLACE4\">REPLACE5</td></tr>"),
/**
*
*/
TABLELINE_3_CUSTOMKEY_1("<tr><td sorttable_customkey=\"REPLACE0\">REPLACE1</td><td>REPLACE2</td><td>REPLACE3</td></tr>"),
/**
*
*/
ERROR_TABLE_2(TABLELINE_2.parse("No data", "No data")),
/**
*
*/
TABLE_END("</tbody></table>"),
/**
*
*/
SESSIONDATA_NONE("No Session Data available"),
/**
*
*/
KILLDATA_NONE("No Kills"),;
private String html;

View File

@ -153,7 +153,7 @@ public class Analysis {
// Fill Dataset with userdata.
rawData.stream().forEach((uData) -> {
// try {
HashMap<GameMode, Long> gmTimes = uData.getGmTimes();
Map<GameMode, Long> gmTimes = uData.getGmTimes();
if (gmTimes != null) {
Long survival = gmTimes.get(GameMode.SURVIVAL);
if (survival != null) {

View File

@ -52,7 +52,7 @@ public class NewPlayerCreator {
data.setLastGmSwapTime(zero);
data.setDeaths(0);
data.setMobKills(0);
Log.debug("Created a new UserData object for "+player.getUniqueId());
Log.debug(player.getUniqueId()+": Created a new UserData object.");
return data;
}

View File

@ -4,6 +4,7 @@ import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
@ -51,7 +52,7 @@ public class PlaceholderUtils {
replaceMap.put("%ops%", "" + data.getOps());
replaceMap.put("%refresh%", FormatUtils.formatTimeAmountSinceString("" + data.getRefreshDate(), new Date()));
replaceMap.put("%totallogins%", "" + data.getTotalLoginTimes());
replaceMap.put("%top20mostactive%", data.getTop20ActivePlayers());
replaceMap.put("%top20mostactive%", Html.ERROR_NOT_SET.parse());
replaceMap.put("%recentlogins%", data.getRecentPlayers());
replaceMap.put("%deaths%", data.getTotalDeaths() + "");
replaceMap.put("%playerkills%", data.getTotalPlayerKills() + "");
@ -133,7 +134,7 @@ public class PlaceholderUtils {
int age = data.getDemData().getAge();
replaceMap.put("%age%", (age != -1) ? "" + age : Phrase.DEM_UNKNOWN + "");
replaceMap.put("%gender%", "" + data.getDemData().getGender().name().toLowerCase());
HashMap<GameMode, Long> gmTimes = data.getGmTimes();
Map<GameMode, Long> gmTimes = data.getGmTimes();
long gmThree;
try {
Long gm3 = gmTimes.get(GameMode.SPECTATOR);

View File

@ -11,6 +11,7 @@ import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.DemographicsData;
@ -169,9 +170,9 @@ public class UserDataTest {
test.addNickname(null);
assertTrue("Didn't add 1", test.getNicknames().contains(one));
assertTrue("Didn't add 2", test.getNicknames().contains(two));
assertTrue("1 is new", n);
assertTrue("2 is new", n1);
assertTrue("2 is not new", !n2);
assertTrue("1 is supposed to be new", n);
assertTrue("2 is supposed to be new", n1);
assertTrue("2 is not supposed to be new", !n2);
assertTrue("Added null", !test.getNicknames().contains(null));
assertTrue("Added multiples", test.getNicknames().size() == 2);
assertTrue("Last nickname was not one", test.getLastNick().equals(one));
@ -243,7 +244,7 @@ public class UserDataTest {
gmTimes.put(null, 0L);
test.setGmTimes(gmTimes);
test.setAllGMTimes(1L, 2L, 3L, 4L);
HashMap<GameMode, Long> times = test.getGmTimes();
Map<GameMode, Long> times = test.getGmTimes();
assertTrue("Cleared gmTimes", !times.containsKey(null));
assertTrue("Not equal 0", times.get(GameMode.SURVIVAL) == 1L);
assertTrue("Not equal 1", times.get(GameMode.CREATIVE) == 2L);

View File

@ -152,7 +152,7 @@ public class DataCacheProcessQueueTest {
*
* @throws InterruptedException
*/
@Ignore @Test
@Test
public void testContainsUUID() throws InterruptedException {
DataCacheProcessQueue q = new DataCacheProcessQueue(handler);
UUID uuid = MockUtils.getPlayerUUID();
@ -164,7 +164,6 @@ public class DataCacheProcessQueueTest {
}
};
q.stop();
Thread.sleep(2000);
q.addToPool(h);
assertTrue(q.containsUUID(uuid));
}

View File

@ -58,15 +58,6 @@ public class DataCacheSaveQueueTest {
TestInit t = new TestInit();
assertTrue("Not set up", t.setUp());
plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
calledSaveUserData = false;
calledSaveUserData2 = false;
db = new SQLiteDB(plan, "debug" + new Date().getTime()) {

Binary file not shown.