mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-15 20:51:21 +01:00
Merge pull request #466 from Rsl1122/RefactoringBranch
Pull Request for 4.1.3.1
This commit is contained in:
commit
f9c46e4cc5
@ -34,20 +34,19 @@ import com.djrapitops.plugin.settings.ColorScheme;
|
|||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import com.djrapitops.plugin.task.ITask;
|
import com.djrapitops.plugin.task.ITask;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
|
||||||
import main.java.com.djrapitops.plan.api.API;
|
import main.java.com.djrapitops.plan.api.API;
|
||||||
import main.java.com.djrapitops.plan.api.IPlan;
|
import main.java.com.djrapitops.plan.api.IPlan;
|
||||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
|
||||||
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
|
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
|
||||||
import main.java.com.djrapitops.plan.command.PlanCommand;
|
import main.java.com.djrapitops.plan.command.PlanCommand;
|
||||||
import main.java.com.djrapitops.plan.data.plugin.HookHandler;
|
import main.java.com.djrapitops.plan.data.plugin.HookHandler;
|
||||||
import main.java.com.djrapitops.plan.database.Database;
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
import main.java.com.djrapitops.plan.database.databases.MySQLDB;
|
|
||||||
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
|
|
||||||
import main.java.com.djrapitops.plan.settings.Settings;
|
import main.java.com.djrapitops.plan.settings.Settings;
|
||||||
import main.java.com.djrapitops.plan.settings.locale.Locale;
|
import main.java.com.djrapitops.plan.settings.locale.Locale;
|
||||||
import main.java.com.djrapitops.plan.settings.locale.Msg;
|
import main.java.com.djrapitops.plan.settings.locale.Msg;
|
||||||
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
||||||
|
import main.java.com.djrapitops.plan.systems.DatabaseSystem;
|
||||||
|
import main.java.com.djrapitops.plan.systems.FileSystem;
|
||||||
|
import main.java.com.djrapitops.plan.systems.Systems;
|
||||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||||
import main.java.com.djrapitops.plan.systems.cache.GeolocationCache;
|
import main.java.com.djrapitops.plan.systems.cache.GeolocationCache;
|
||||||
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
|
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||||
@ -67,12 +66,9 @@ import main.java.com.djrapitops.plan.utilities.metrics.BStats;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,12 +87,11 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
private Config config;
|
private Config config;
|
||||||
private Theme theme;
|
private Theme theme;
|
||||||
|
|
||||||
|
private Systems systems;
|
||||||
|
|
||||||
private ProcessingQueue processingQueue;
|
private ProcessingQueue processingQueue;
|
||||||
private HookHandler hookHandler; // Manages 3rd party data sources
|
private HookHandler hookHandler; // Manages 3rd party data sources
|
||||||
|
|
||||||
private Database db;
|
|
||||||
private Set<Database> databases;
|
|
||||||
|
|
||||||
private WebServer webServer;
|
private WebServer webServer;
|
||||||
|
|
||||||
private BukkitInformationManager infoManager;
|
private BukkitInformationManager infoManager;
|
||||||
@ -148,10 +143,10 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
try {
|
try {
|
||||||
File dataFolder = getDataFolder();
|
systems = new Systems(this);
|
||||||
dataFolder.mkdirs();
|
FileSystem.getInstance().init();
|
||||||
File configFile = new File(dataFolder, "config.yml");
|
|
||||||
config = new Config(configFile);
|
config = new Config(FileSystem.getConfigFile());
|
||||||
config.copyDefaults(FileUtil.lines(this, "config.yml"));
|
config.copyDefaults(FileUtil.lines(this, "config.yml"));
|
||||||
config.save();
|
config.save();
|
||||||
|
|
||||||
@ -191,10 +186,7 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
serverVariableHolder = new ServerVariableHolder(getServer());
|
serverVariableHolder = new ServerVariableHolder(getServer());
|
||||||
Benchmark.stop("Enable", "Reading server variables");
|
Benchmark.stop("Enable", "Reading server variables");
|
||||||
|
|
||||||
Benchmark.start("Init Database");
|
DatabaseSystem.getInstance().init();
|
||||||
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
|
|
||||||
initDatabase();
|
|
||||||
Benchmark.stop("Enable", "Init Database");
|
|
||||||
|
|
||||||
Benchmark.start("WebServer Initialization");
|
Benchmark.start("WebServer Initialization");
|
||||||
webServer = new WebServer(this);
|
webServer = new WebServer(this);
|
||||||
@ -351,6 +343,9 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
}).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L);
|
}).runTaskLaterAsynchronously(TimeAmount.SECOND.ticks() * 5L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
systems.close();
|
||||||
|
|
||||||
Log.info(Locale.get(Msg.DISABLED).toString());
|
Log.info(Locale.get(Msg.DISABLED).toString());
|
||||||
Benchmark.pluginDisabled(Plan.class);
|
Benchmark.pluginDisabled(Plan.class);
|
||||||
DebugLog.pluginDisabled(Plan.class);
|
DebugLog.pluginDisabled(Plan.class);
|
||||||
@ -382,34 +377,6 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
Benchmark.stop("Enable", "Register Listeners");
|
Benchmark.stop("Enable", "Register Listeners");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the database according to settings in the config.
|
|
||||||
* <p>
|
|
||||||
* If database connection can not be established plugin is disabled.
|
|
||||||
*/
|
|
||||||
private void initDatabase() throws DatabaseInitException {
|
|
||||||
databases = new HashSet<>();
|
|
||||||
databases.add(new MySQLDB(this));
|
|
||||||
databases.add(new SQLiteDB(this));
|
|
||||||
|
|
||||||
String dbType = Settings.DB_TYPE.toString().toLowerCase().trim();
|
|
||||||
|
|
||||||
for (Database database : databases) {
|
|
||||||
String databaseType = database.getConfigName().toLowerCase().trim();
|
|
||||||
if (Verify.equalsIgnoreCase(dbType, databaseType)) {
|
|
||||||
this.db = database;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (db == null) {
|
|
||||||
throw new DatabaseInitException(Locale.get(Msg.ENABLE_FAIL_WRONG_DB).toString() + " " + dbType);
|
|
||||||
}
|
|
||||||
|
|
||||||
db.init();
|
|
||||||
Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to access Cache.
|
* Used to access Cache.
|
||||||
*
|
*
|
||||||
@ -424,8 +391,9 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
*
|
*
|
||||||
* @return the Current Database
|
* @return the Current Database
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public Database getDB() {
|
public Database getDB() {
|
||||||
return db;
|
return DatabaseSystem.getInstance().getActiveDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -446,17 +414,6 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
return hookHandler;
|
return hookHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to get all possible database objects.
|
|
||||||
* <p>
|
|
||||||
* #init() might need to be called in order for the object to function.
|
|
||||||
*
|
|
||||||
* @return Set containing the SqLite and MySQL objects.
|
|
||||||
*/
|
|
||||||
public Set<Database> getDatabases() {
|
|
||||||
return databases;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to get the ID of the BootAnalysisTask, so that it can be disabled.
|
* Used to get the ID of the BootAnalysisTask, so that it can be disabled.
|
||||||
*
|
*
|
||||||
@ -581,4 +538,8 @@ public class Plan extends BukkitPlugin implements IPlan {
|
|||||||
public Theme getTheme() {
|
public Theme getTheme() {
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Systems getSystems() {
|
||||||
|
return systems;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,15 @@ import com.djrapitops.plugin.settings.ColorScheme;
|
|||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
import main.java.com.djrapitops.plan.api.IPlan;
|
import main.java.com.djrapitops.plan.api.IPlan;
|
||||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
|
||||||
import main.java.com.djrapitops.plan.command.PlanBungeeCommand;
|
import main.java.com.djrapitops.plan.command.PlanBungeeCommand;
|
||||||
import main.java.com.djrapitops.plan.database.Database;
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
import main.java.com.djrapitops.plan.database.databases.MySQLDB;
|
|
||||||
import main.java.com.djrapitops.plan.settings.Settings;
|
import main.java.com.djrapitops.plan.settings.Settings;
|
||||||
import main.java.com.djrapitops.plan.settings.locale.Locale;
|
import main.java.com.djrapitops.plan.settings.locale.Locale;
|
||||||
import main.java.com.djrapitops.plan.settings.locale.Msg;
|
import main.java.com.djrapitops.plan.settings.locale.Msg;
|
||||||
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
||||||
|
import main.java.com.djrapitops.plan.systems.DatabaseSystem;
|
||||||
|
import main.java.com.djrapitops.plan.systems.FileSystem;
|
||||||
|
import main.java.com.djrapitops.plan.systems.Systems;
|
||||||
import main.java.com.djrapitops.plan.systems.info.BungeeInformationManager;
|
import main.java.com.djrapitops.plan.systems.info.BungeeInformationManager;
|
||||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||||
import main.java.com.djrapitops.plan.systems.info.server.BungeeServerInfoManager;
|
import main.java.com.djrapitops.plan.systems.info.server.BungeeServerInfoManager;
|
||||||
@ -37,10 +38,8 @@ import main.java.com.djrapitops.plan.utilities.file.FileUtil;
|
|||||||
import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport;
|
import main.java.com.djrapitops.plan.utilities.file.export.HtmlExport;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,8 +52,9 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
|||||||
private Config config;
|
private Config config;
|
||||||
private Theme theme;
|
private Theme theme;
|
||||||
|
|
||||||
|
private Systems systems;
|
||||||
|
|
||||||
private WebServer webServer;
|
private WebServer webServer;
|
||||||
private Database db;
|
|
||||||
private BungeeServerInfoManager serverInfoManager;
|
private BungeeServerInfoManager serverInfoManager;
|
||||||
private BungeeInformationManager infoManager;
|
private BungeeInformationManager infoManager;
|
||||||
private ServerVariableHolder variableHolder;
|
private ServerVariableHolder variableHolder;
|
||||||
@ -65,8 +65,10 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
super.onEnable();
|
super.onEnable();
|
||||||
try {
|
try {
|
||||||
File configFile = new File(getDataFolder(), "config.yml");
|
systems = new Systems(this);
|
||||||
config = new Config(configFile);
|
FileSystem.getInstance().init();
|
||||||
|
|
||||||
|
config = new Config(FileSystem.getConfigFile());
|
||||||
config.copyDefaults(FileUtil.lines(this, "bungeeconfig.yml"));
|
config.copyDefaults(FileUtil.lines(this, "bungeeconfig.yml"));
|
||||||
config.save();
|
config.save();
|
||||||
|
|
||||||
@ -93,8 +95,7 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
|||||||
|
|
||||||
theme = new Theme();
|
theme = new Theme();
|
||||||
|
|
||||||
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
|
DatabaseSystem.getInstance().init();
|
||||||
initDatabase();
|
|
||||||
|
|
||||||
registerCommand("planbungee", new PlanBungeeCommand(this));
|
registerCommand("planbungee", new PlanBungeeCommand(this));
|
||||||
|
|
||||||
@ -168,13 +169,7 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
|||||||
if (webServer != null) {
|
if (webServer != null) {
|
||||||
webServer.stop();
|
webServer.stop();
|
||||||
}
|
}
|
||||||
if (db != null) {
|
systems.close();
|
||||||
try {
|
|
||||||
db.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Log.toLog(this.getClass().getName(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.info(Locale.get(Msg.DISABLED).toString());
|
Log.info(Locale.get(Msg.DISABLED).toString());
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
}
|
}
|
||||||
@ -193,14 +188,10 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDatabase() throws DatabaseInitException {
|
|
||||||
db = new MySQLDB(this);
|
|
||||||
db.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public Database getDB() {
|
public Database getDB() {
|
||||||
return db;
|
return DatabaseSystem.getInstance().getActiveDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BungeeServerInfoManager getServerInfoManager() {
|
public BungeeServerInfoManager getServerInfoManager() {
|
||||||
@ -270,4 +261,9 @@ public class PlanBungee extends BungeePlugin implements IPlan {
|
|||||||
public Theme getTheme() {
|
public Theme getTheme() {
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Systems getSystems() {
|
||||||
|
return systems;
|
||||||
|
}
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ import com.djrapitops.plugin.settings.ColorScheme;
|
|||||||
import main.java.com.djrapitops.plan.ServerVariableHolder;
|
import main.java.com.djrapitops.plan.ServerVariableHolder;
|
||||||
import main.java.com.djrapitops.plan.database.Database;
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
||||||
|
import main.java.com.djrapitops.plan.systems.Systems;
|
||||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||||
import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue;
|
import main.java.com.djrapitops.plan.systems.queue.ProcessingQueue;
|
||||||
@ -48,4 +49,6 @@ public interface IPlan extends IPlugin {
|
|||||||
ColorScheme getColorScheme();
|
ColorScheme getColorScheme();
|
||||||
|
|
||||||
Theme getTheme();
|
Theme getTheme();
|
||||||
|
|
||||||
|
Systems getSystems();
|
||||||
}
|
}
|
@ -54,7 +54,7 @@ public class ManageBackupCommand extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Database database = ManageUtils.getDB(plugin, dbName);
|
final Database database = ManageUtils.getDB(dbName);
|
||||||
|
|
||||||
// If DB is null return
|
// If DB is null return
|
||||||
if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
|
if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
|
||||||
|
@ -71,7 +71,7 @@ public class ManageClearCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Database database = ManageUtils.getDB(plugin, dbName);
|
Database database = ManageUtils.getDB(dbName);
|
||||||
runClearTask(sender, database);
|
runClearTask(sender, database);
|
||||||
} catch (DatabaseInitException e) {
|
} catch (DatabaseInitException e) {
|
||||||
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
|
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
|
||||||
|
@ -66,7 +66,7 @@ public class ManageHotswapCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Database database = ManageUtils.getDB(plugin, dbName);
|
final Database database = ManageUtils.getDB(dbName);
|
||||||
|
|
||||||
// If DB is null return
|
// If DB is null return
|
||||||
if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
|
if (!Condition.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
|
||||||
|
@ -71,8 +71,8 @@ public class ManageMoveCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Database fromDatabase = ManageUtils.getDB(plugin, fromDB);
|
final Database fromDatabase = ManageUtils.getDB(fromDB);
|
||||||
final Database toDatabase = ManageUtils.getDB(plugin, toDB);
|
final Database toDatabase = ManageUtils.getDB(toDB);
|
||||||
|
|
||||||
runMoveTask(fromDatabase, toDatabase, sender);
|
runMoveTask(fromDatabase, toDatabase, sender);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -61,7 +61,7 @@ public class ManageRestoreCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Database database = ManageUtils.getDB(plugin, db);
|
final Database database = ManageUtils.getDB(db);
|
||||||
|
|
||||||
runRestoreTask(args, sender, database);
|
runRestoreTask(args, sender, database);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -87,7 +87,7 @@ public class ManageRestoreCommand extends SubCommand {
|
|||||||
backupDBName = backupDBName.substring(0, backupDBName.length() - 3);
|
backupDBName = backupDBName.substring(0, backupDBName.length() - 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLiteDB backupDB = new SQLiteDB(plugin, backupDBName);
|
SQLiteDB backupDB = new SQLiteDB(backupDBName);
|
||||||
backupDB.init();
|
backupDB.init();
|
||||||
|
|
||||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
|
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
|
||||||
|
@ -18,12 +18,12 @@ import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
|||||||
import main.java.com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
import main.java.com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.ActivityStackGraphCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.ActivityStackGraph;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.PunchCardGraphCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.PunchCardGraph;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.WorldMapCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.WorldMap;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.line.*;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.line.*;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.ActivityPieCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.ActivityPie;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.WorldPieCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator;
|
import main.java.com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.structure.SessionTabStructureCreator;
|
import main.java.com.djrapitops.plan.utilities.html.structure.SessionTabStructureCreator;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.tables.CommandUseTableCreator;
|
import main.java.com.djrapitops.plan.utilities.html.tables.CommandUseTableCreator;
|
||||||
@ -143,8 +143,8 @@ public class AnalysisData extends RawData {
|
|||||||
|
|
||||||
Map<String, Set<UUID>> activityNow = activityData.getOrDefault(now, new HashMap<>());
|
Map<String, Set<UUID>> activityNow = activityData.getOrDefault(now, new HashMap<>());
|
||||||
|
|
||||||
String[] activityStackSeries = ActivityStackGraphCreator.createSeries(activityData);
|
String[] activityStackSeries = ActivityStackGraph.createSeries(activityData);
|
||||||
String activityPieSeries = ActivityPieCreator.createSeriesData(activityNow);
|
String activityPieSeries = ActivityPie.createSeries(activityNow);
|
||||||
|
|
||||||
addValue("activityStackCategories", activityStackSeries[0]);
|
addValue("activityStackCategories", activityStackSeries[0]);
|
||||||
addValue("activityStackSeries", activityStackSeries[1]);
|
addValue("activityStackSeries", activityStackSeries[1]);
|
||||||
@ -170,7 +170,7 @@ public class AnalysisData extends RawData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void geolocationsTab(List<String> geoLocations) {
|
private void geolocationsTab(List<String> geoLocations) {
|
||||||
addValue("geoMapSeries", WorldMapCreator.createDataSeries(geoLocations));
|
addValue("geoMapSeries", WorldMap.createSeries(geoLocations));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onlineActivityNumbers(ServerProfile profile, Map<UUID, List<Session>> sessions, List<PlayerProfile> players) {
|
private void onlineActivityNumbers(ServerProfile profile, Map<UUID, List<Session>> sessions, List<PlayerProfile> players) {
|
||||||
@ -285,7 +285,7 @@ public class AnalysisData extends RawData {
|
|||||||
addValue("tableBodySessions", tables[0]);
|
addValue("tableBodySessions", tables[0]);
|
||||||
addValue("listRecentLogins", tables[1]);
|
addValue("listRecentLogins", tables[1]);
|
||||||
addValue("sessionAverage", FormatUtils.formatTimeAmount(MathUtils.averageLong(allSessions.stream().map(Session::getLength))));
|
addValue("sessionAverage", FormatUtils.formatTimeAmount(MathUtils.averageLong(allSessions.stream().map(Session::getLength))));
|
||||||
addValue("punchCardSeries", PunchCardGraphCreator.createDataSeries(sessionsMonth));
|
addValue("punchCardSeries", PunchCardGraph.createSeries(sessionsMonth));
|
||||||
|
|
||||||
addValue("deaths", ServerProfile.getDeathCount(allSessions));
|
addValue("deaths", ServerProfile.getDeathCount(allSessions));
|
||||||
addValue("mobKillCount", ServerProfile.getMobKillCount(allSessions));
|
addValue("mobKillCount", ServerProfile.getMobKillCount(allSessions));
|
||||||
@ -302,7 +302,7 @@ public class AnalysisData extends RawData {
|
|||||||
Html.TABLE_PLAYERS_FOOTER.parse(playersTableBody)
|
Html.TABLE_PLAYERS_FOOTER.parse(playersTableBody)
|
||||||
: Html.TABLE_PLAYERS.parse(playersTableBody));
|
: Html.TABLE_PLAYERS.parse(playersTableBody));
|
||||||
addValue("worldTotal", FormatUtils.formatTimeAmount(worldTimes.getTotal()));
|
addValue("worldTotal", FormatUtils.formatTimeAmount(worldTimes.getTotal()));
|
||||||
String[] seriesData = WorldPieCreator.createSeriesData(worldTimes);
|
String[] seriesData = WorldPie.createSeries(worldTimes);
|
||||||
addValue("worldSeries", seriesData[0]);
|
addValue("worldSeries", seriesData[0]);
|
||||||
addValue("gmSeries", seriesData[1]);
|
addValue("gmSeries", seriesData[1]);
|
||||||
addValue("lastPeakTime", lastPeak != -1 ? FormatUtils.formatTimeStampYear(lastPeak) : "No Data");
|
addValue("lastPeakTime", lastPeak != -1 ? FormatUtils.formatTimeStampYear(lastPeak) : "No Data");
|
||||||
@ -319,12 +319,12 @@ public class AnalysisData extends RawData {
|
|||||||
addValue("tpsSpikeWeek", value("tpsSpikeWeek"));
|
addValue("tpsSpikeWeek", value("tpsSpikeWeek"));
|
||||||
addValue("tpsSpikeDay", value("tpsSpikeDay"));
|
addValue("tpsSpikeDay", value("tpsSpikeDay"));
|
||||||
|
|
||||||
addValue("playersOnlineSeries", PlayerActivityGraphCreator.buildSeriesDataString(tpsData));
|
addValue("playersOnlineSeries", PlayerActivityGraph.createSeries(tpsData));
|
||||||
addValue("tpsSeries", TPSGraphCreator.buildSeriesDataString(tpsData));
|
addValue("tpsSeries", TPSGraph.createSeries(tpsData));
|
||||||
addValue("cpuSeries", CPUGraphCreator.buildSeriesDataString(tpsData));
|
addValue("cpuSeries", CPUGraph.createSeries(tpsData));
|
||||||
addValue("ramSeries", RamGraphCreator.buildSeriesDataString(tpsData));
|
addValue("ramSeries", RamGraph.createSeries(tpsData));
|
||||||
addValue("entitySeries", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsData));
|
addValue("entitySeries", WorldLoadGraph.createSeriesEntities(tpsData));
|
||||||
addValue("chunkSeries", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsData));
|
addValue("chunkSeries", WorldLoadGraph.createSeriesChunks(tpsData));
|
||||||
|
|
||||||
double averageCPUMonth = MathUtils.averageDouble(tpsDataMonth.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
double averageCPUMonth = MathUtils.averageDouble(tpsDataMonth.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
||||||
double averageCPUWeek = MathUtils.averageDouble(tpsDataWeek.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
double averageCPUWeek = MathUtils.averageDouble(tpsDataWeek.stream().map(TPS::getCPUUsage).filter(i -> i != 0));
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package main.java.com.djrapitops.plan.database;
|
package main.java.com.djrapitops.plan.database;
|
||||||
|
|
||||||
import main.java.com.djrapitops.plan.api.IPlan;
|
|
||||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
||||||
import main.java.com.djrapitops.plan.data.PlayerProfile;
|
import main.java.com.djrapitops.plan.data.PlayerProfile;
|
||||||
import main.java.com.djrapitops.plan.data.ServerProfile;
|
import main.java.com.djrapitops.plan.data.ServerProfile;
|
||||||
@ -23,7 +22,6 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public abstract class Database {
|
public abstract class Database {
|
||||||
|
|
||||||
protected final IPlan plugin;
|
|
||||||
protected UsersTable usersTable;
|
protected UsersTable usersTable;
|
||||||
protected UserInfoTable userInfoTable;
|
protected UserInfoTable userInfoTable;
|
||||||
protected ActionsTable actionsTable;
|
protected ActionsTable actionsTable;
|
||||||
@ -43,11 +41,8 @@ public abstract class Database {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Super constructor.
|
* Super constructor.
|
||||||
*
|
|
||||||
* @param plugin current instance of Plan.
|
|
||||||
*/
|
*/
|
||||||
public Database(IPlan plugin) {
|
public Database() {
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package main.java.com.djrapitops.plan.database.databases;
|
package main.java.com.djrapitops.plan.database.databases;
|
||||||
|
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import main.java.com.djrapitops.plan.api.IPlan;
|
|
||||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
||||||
import main.java.com.djrapitops.plan.settings.Settings;
|
import main.java.com.djrapitops.plan.settings.Settings;
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
@ -16,15 +15,6 @@ public class MySQLDB extends SQLDB {
|
|||||||
|
|
||||||
private BasicDataSource dataSource;
|
private BasicDataSource dataSource;
|
||||||
|
|
||||||
/**
|
|
||||||
* Class Constructor.
|
|
||||||
*
|
|
||||||
* @param plugin Current instance of Plan
|
|
||||||
*/
|
|
||||||
public MySQLDB(IPlan plugin) {
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setups the {@link BasicDataSource}
|
* Setups the {@link BasicDataSource}
|
||||||
*/
|
*/
|
||||||
|
@ -6,7 +6,6 @@ import com.djrapitops.plugin.api.utility.log.Log;
|
|||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import com.djrapitops.plugin.task.ITask;
|
import com.djrapitops.plugin.task.ITask;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
import main.java.com.djrapitops.plan.api.IPlan;
|
|
||||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
||||||
import main.java.com.djrapitops.plan.data.PlayerProfile;
|
import main.java.com.djrapitops.plan.data.PlayerProfile;
|
||||||
import main.java.com.djrapitops.plan.data.ServerProfile;
|
import main.java.com.djrapitops.plan.data.ServerProfile;
|
||||||
@ -33,8 +32,7 @@ public abstract class SQLDB extends Database {
|
|||||||
private boolean open = false;
|
private boolean open = false;
|
||||||
private ITask dbCleanTask;
|
private ITask dbCleanTask;
|
||||||
|
|
||||||
public SQLDB(IPlan plugin) {
|
public SQLDB() {
|
||||||
super(plugin);
|
|
||||||
usingMySQL = getName().equals("MySQL");
|
usingMySQL = getName().equals("MySQL");
|
||||||
|
|
||||||
versionTable = new VersionTable(this, usingMySQL);
|
versionTable = new VersionTable(this, usingMySQL);
|
||||||
|
@ -4,7 +4,6 @@ import com.djrapitops.plugin.api.utility.log.Log;
|
|||||||
import com.djrapitops.plugin.task.AbsRunnable;
|
import com.djrapitops.plugin.task.AbsRunnable;
|
||||||
import com.djrapitops.plugin.task.ITask;
|
import com.djrapitops.plugin.task.ITask;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
|
||||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
||||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
@ -26,15 +25,12 @@ public class SQLiteDB extends SQLDB {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Constructor.
|
* Class Constructor.
|
||||||
*
|
|
||||||
* @param plugin Current instance of Plan
|
|
||||||
*/
|
*/
|
||||||
public SQLiteDB(Plan plugin) {
|
public SQLiteDB() {
|
||||||
this(plugin, "database");
|
this("database");
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQLiteDB(Plan plugin, String dbName) {
|
public SQLiteDB(String dbName) {
|
||||||
super(plugin);
|
|
||||||
this.dbName = dbName;
|
this.dbName = dbName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +55,7 @@ public class SQLiteDB extends SQLDB {
|
|||||||
return null; // Should never happen.
|
return null; // Should never happen.
|
||||||
}
|
}
|
||||||
|
|
||||||
String dbFilePath = new File(plugin.getDataFolder(), dbName + ".db").getAbsolutePath();
|
String dbFilePath = new File(MiscUtils.getIPlan().getDataFolder(), dbName + ".db").getAbsolutePath();
|
||||||
Connection connection;
|
Connection connection;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -0,0 +1,104 @@
|
|||||||
|
/*
|
||||||
|
* Licence is provided in the jar as license.yml also here:
|
||||||
|
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||||
|
*/
|
||||||
|
package main.java.com.djrapitops.plan.systems;
|
||||||
|
|
||||||
|
import com.djrapitops.plugin.api.Benchmark;
|
||||||
|
import com.djrapitops.plugin.api.Check;
|
||||||
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
|
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
||||||
|
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
|
||||||
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
|
import main.java.com.djrapitops.plan.database.databases.MySQLDB;
|
||||||
|
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
|
||||||
|
import main.java.com.djrapitops.plan.settings.Settings;
|
||||||
|
import main.java.com.djrapitops.plan.settings.locale.Locale;
|
||||||
|
import main.java.com.djrapitops.plan.settings.locale.Msg;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //TODO Class Javadoc Comment
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public class DatabaseSystem implements SubSystem {
|
||||||
|
|
||||||
|
private Database db;
|
||||||
|
private Set<Database> databases;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws PlanEnableException {
|
||||||
|
try {
|
||||||
|
Benchmark.start("Init Database");
|
||||||
|
Log.info(Locale.get(Msg.ENABLE_DB_INIT).toString());
|
||||||
|
initDatabase();
|
||||||
|
Log.info(Locale.get(Msg.ENABLE_DB_INFO).parse(db.getConfigName()));
|
||||||
|
Benchmark.stop("Systems", "Init Database");
|
||||||
|
} catch (DatabaseInitException e) {
|
||||||
|
throw new PlanEnableException(db.getConfigName() + "-Database failed to initialize", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initDatabase() throws DatabaseInitException {
|
||||||
|
if (Check.isBungeeAvailable()) {
|
||||||
|
db = new MySQLDB();
|
||||||
|
} else {
|
||||||
|
// Enables database on Bukkit
|
||||||
|
// Bukkit supports SQLite.
|
||||||
|
initPlanDatabase();
|
||||||
|
}
|
||||||
|
db.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initPlanDatabase() throws DatabaseInitException {
|
||||||
|
databases = new HashSet<>();
|
||||||
|
databases.add(new MySQLDB());
|
||||||
|
databases.add(new SQLiteDB());
|
||||||
|
|
||||||
|
String dbType = Settings.DB_TYPE.toString().toLowerCase().trim();
|
||||||
|
db = getActiveDatabase(dbType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Database> getDatabases() {
|
||||||
|
return databases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatabases(Set<Database> databases) {
|
||||||
|
this.databases = databases;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
try {
|
||||||
|
if (db != null) {
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Log.toLog(this.getClass().getName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DatabaseSystem getInstance() {
|
||||||
|
return Systems.getInstance().databaseSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Database getActiveDatabase() {
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Database getActiveDatabase(String dbName) throws DatabaseInitException {
|
||||||
|
for (Database database : DatabaseSystem.getInstance().getDatabases()) {
|
||||||
|
String dbConfigName = database.getConfigName();
|
||||||
|
if (Verify.equalsIgnoreCase(dbName, dbConfigName)) {
|
||||||
|
database.init();
|
||||||
|
return database;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new DatabaseInitException(Locale.get(Msg.ENABLE_FAIL_WRONG_DB) + " " + dbName);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Licence is provided in the jar as license.yml also here:
|
||||||
|
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||||
|
*/
|
||||||
|
package main.java.com.djrapitops.plan.systems;
|
||||||
|
|
||||||
|
import main.java.com.djrapitops.plan.api.IPlan;
|
||||||
|
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //TODO Class Javadoc Comment
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public class FileSystem implements SubSystem {
|
||||||
|
|
||||||
|
private final File dataFolder;
|
||||||
|
private File configFile;
|
||||||
|
|
||||||
|
public FileSystem(IPlan plugin) {
|
||||||
|
dataFolder = plugin.getDataFolder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FileSystem getInstance() {
|
||||||
|
return Systems.getInstance().fileSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getDataFolder() {
|
||||||
|
return getInstance().dataFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getConfigFile() {
|
||||||
|
return getInstance().configFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() throws PlanEnableException {
|
||||||
|
dataFolder.mkdirs();
|
||||||
|
configFile = new File(dataFolder, "config.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Licence is provided in the jar as license.yml also here:
|
||||||
|
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||||
|
*/
|
||||||
|
package main.java.com.djrapitops.plan.systems;
|
||||||
|
|
||||||
|
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //TODO Class Javadoc Comment
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public interface SubSystem {
|
||||||
|
|
||||||
|
void init() throws PlanEnableException;
|
||||||
|
|
||||||
|
void close();
|
||||||
|
|
||||||
|
}
|
44
Plan/src/main/java/com/djrapitops/plan/systems/Systems.java
Normal file
44
Plan/src/main/java/com/djrapitops/plan/systems/Systems.java
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Licence is provided in the jar as license.yml also here:
|
||||||
|
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
|
||||||
|
*/
|
||||||
|
package main.java.com.djrapitops.plan.systems;
|
||||||
|
|
||||||
|
import main.java.com.djrapitops.plan.api.IPlan;
|
||||||
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Layer for reducing
|
||||||
|
*
|
||||||
|
* @author Rsl1122
|
||||||
|
*/
|
||||||
|
public class Systems {
|
||||||
|
|
||||||
|
FileSystem fileSystem;
|
||||||
|
DatabaseSystem databaseSystem;
|
||||||
|
|
||||||
|
public Systems(IPlan plugin) {
|
||||||
|
databaseSystem = new DatabaseSystem();
|
||||||
|
fileSystem = new FileSystem(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SubSystem[] getSubSystems() {
|
||||||
|
return new SubSystem[]{
|
||||||
|
databaseSystem,
|
||||||
|
fileSystem
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
SubSystem[] subSystems = getSubSystems();
|
||||||
|
ArrayUtils.reverse(subSystems);
|
||||||
|
for (SubSystem subSystem : subSystems) {
|
||||||
|
subSystem.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Systems getInstance() {
|
||||||
|
return MiscUtils.getIPlan().getSystems();
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package main.java.com.djrapitops.plan.systems.cache;
|
|||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.data.container.Session;
|
import main.java.com.djrapitops.plan.data.container.Session;
|
||||||
|
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -31,7 +32,12 @@ public class SessionCache {
|
|||||||
|
|
||||||
public void cacheSession(UUID uuid, Session session) {
|
public void cacheSession(UUID uuid, Session session) {
|
||||||
activeSessions.put(uuid, session);
|
activeSessions.put(uuid, session);
|
||||||
plugin.getInfoManager().cachePlayer(uuid);
|
plugin.addToProcessQueue(new Processor<Plan>(plugin) {
|
||||||
|
@Override
|
||||||
|
public void process() {
|
||||||
|
plugin.getInfoManager().cachePlayer(uuid);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endSession(UUID uuid, long time) {
|
public void endSession(UUID uuid, long time) {
|
||||||
|
@ -26,9 +26,9 @@ import main.java.com.djrapitops.plan.utilities.comparators.SessionStartComparato
|
|||||||
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
|
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
|
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.PunchCardGraphCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.PunchCardGraph;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.line.ServerPreferencePieCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.line.ServerPreferencePie;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.WorldPieCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.structure.ServerAccordionCreator;
|
import main.java.com.djrapitops.plan.utilities.html.structure.ServerAccordionCreator;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.tables.ActionsTableCreator;
|
import main.java.com.djrapitops.plan.utilities.html.tables.ActionsTableCreator;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.tables.IpTableCreator;
|
import main.java.com.djrapitops.plan.utilities.html.tables.IpTableCreator;
|
||||||
@ -72,7 +72,6 @@ public class InspectPageParser extends PageParser {
|
|||||||
|
|
||||||
return parse(profile, serverUUID, serverNames);
|
return parse(profile, serverUUID, serverNames);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
|
||||||
throw new ParseException(e);
|
throw new ParseException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +107,7 @@ public class InspectPageParser extends PageParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<UUID, WorldTimes> worldTimesPerServer = profile.getWorldTimesPerServer();
|
Map<UUID, WorldTimes> worldTimesPerServer = profile.getWorldTimesPerServer();
|
||||||
addValue("serverPieSeries", ServerPreferencePieCreator.createSeriesData(serverNames, worldTimesPerServer));
|
addValue("serverPieSeries", ServerPreferencePie.createSeries(serverNames, worldTimesPerServer));
|
||||||
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
|
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
|
||||||
addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE));
|
addValue("gmPieColors", Theme.getValue(ThemeVal.GRAPH_GM_PIE));
|
||||||
addValue("serverPieColors", Theme.getValue(ThemeVal.GRAPH_SERVER_PREF_PIE));
|
addValue("serverPieColors", Theme.getValue(ThemeVal.GRAPH_SERVER_PREF_PIE));
|
||||||
@ -195,11 +194,11 @@ public class InspectPageParser extends PageParser {
|
|||||||
List<Action> actions = profile.getAllActions();
|
List<Action> actions = profile.getAllActions();
|
||||||
addValue("tableBodyActions", ActionsTableCreator.createTable(actions));
|
addValue("tableBodyActions", ActionsTableCreator.createTable(actions));
|
||||||
|
|
||||||
String punchCardData = PunchCardGraphCreator.createDataSeries(allSessions);
|
String punchCardData = PunchCardGraph.createSeries(allSessions);
|
||||||
WorldTimes worldTimes = profile.getWorldTimes();
|
WorldTimes worldTimes = profile.getWorldTimes();
|
||||||
AnalysisUtils.addMissingWorlds(worldTimes);
|
AnalysisUtils.addMissingWorlds(worldTimes);
|
||||||
|
|
||||||
String[] worldPieData = WorldPieCreator.createSeriesData(worldTimes);
|
String[] worldPieData = WorldPie.createSeries(worldTimes);
|
||||||
|
|
||||||
addValue("worldPieSeries", worldPieData[0]);
|
addValue("worldPieSeries", worldPieData[0]);
|
||||||
addValue("gmSeries", worldPieData[1]);
|
addValue("gmSeries", worldPieData[1]);
|
||||||
|
@ -20,7 +20,7 @@ import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
|||||||
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
|
import main.java.com.djrapitops.plan.utilities.file.FileUtil;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
|
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.line.PlayerActivityGraphCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.line.PlayerActivityGraph;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -56,7 +56,7 @@ public class NetworkPageParser extends PageParser {
|
|||||||
addValue("timeZone", MiscUtils.getTimeZoneOffsetHours());
|
addValue("timeZone", MiscUtils.getTimeZoneOffsetHours());
|
||||||
addValue("networkName", Settings.BUNGEE_NETWORK_NAME.toString());
|
addValue("networkName", Settings.BUNGEE_NETWORK_NAME.toString());
|
||||||
addValue("version", plugin.getVersion());
|
addValue("version", plugin.getVersion());
|
||||||
addValue("playersOnlineSeries", PlayerActivityGraphCreator.buildSeriesDataString(networkOnlineData));
|
addValue("playersOnlineSeries", PlayerActivityGraph.createSeries(networkOnlineData));
|
||||||
addValue("playersGraphColor", Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE));
|
addValue("playersGraphColor", Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE));
|
||||||
addValue("playersOnline", plugin.getProxy().getOnlineCount());
|
addValue("playersOnline", plugin.getProxy().getOnlineCount());
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public class DebugPageResponse extends ErrorResponse {
|
|||||||
String javaVMVersion = properties.getProperty("java.vm.version");
|
String javaVMVersion = properties.getProperty("java.vm.version");
|
||||||
List<String> javaVMFlags = runtimeMxBean.getInputArguments();
|
List<String> javaVMFlags = runtimeMxBean.getInputArguments();
|
||||||
|
|
||||||
content.append("**Operating System:** ").append(osName).append(" (").append(osArch)
|
content.append("**Operating SubSystem:** ").append(osName).append(" (").append(osArch)
|
||||||
.append(") version ").append(osVersion).append("<br>");
|
.append(") version ").append(osVersion).append("<br>");
|
||||||
|
|
||||||
content.append("**Java Version:** ").append(javaVersion).append(", ").append(javaVendor).append("<br>");
|
content.append("**Java Version:** ").append(javaVersion).append(", ").append(javaVendor).append("<br>");
|
||||||
@ -159,8 +159,8 @@ public class DebugPageResponse extends ErrorResponse {
|
|||||||
for (String line : Benchmark.getAverages().asStringArray()) {
|
for (String line : Benchmark.getAverages().asStringArray()) {
|
||||||
content.append(line).append("<br>");
|
content.append(line).append("<br>");
|
||||||
}
|
}
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (Exception e) {
|
||||||
content.append("ArrayIndexOutOfBoundsException on Benchmark.getAverages().asStringArray()");
|
content.append("Exception on Benchmark.getAverages().asStringArray()");
|
||||||
}
|
}
|
||||||
content.append("```</pre>");
|
content.append("```</pre>");
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package main.java.com.djrapitops.plan.utilities;
|
package main.java.com.djrapitops.plan.utilities;
|
||||||
|
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
|
||||||
import main.java.com.djrapitops.plan.Plan;
|
import main.java.com.djrapitops.plan.Plan;
|
||||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
||||||
import main.java.com.djrapitops.plan.database.Database;
|
import main.java.com.djrapitops.plan.database.Database;
|
||||||
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
|
import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
|
||||||
import main.java.com.djrapitops.plan.database.tables.move.BatchOperationTable;
|
import main.java.com.djrapitops.plan.database.tables.move.BatchOperationTable;
|
||||||
|
import main.java.com.djrapitops.plan.systems.DatabaseSystem;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -33,7 +33,7 @@ public class ManageUtils {
|
|||||||
Plan plugin = Plan.getInstance();
|
Plan plugin = Plan.getInstance();
|
||||||
String timeStamp = new Date().toString().substring(4, 10).replace(" ", "-");
|
String timeStamp = new Date().toString().substring(4, 10).replace(" ", "-");
|
||||||
String fileName = dbName + "-backup-" + timeStamp;
|
String fileName = dbName + "-backup-" + timeStamp;
|
||||||
SQLiteDB backupDB = new SQLiteDB(plugin, fileName);
|
SQLiteDB backupDB = new SQLiteDB(fileName);
|
||||||
Collection<UUID> uuids = ManageUtils.getUUIDS(copyFromDB);
|
Collection<UUID> uuids = ManageUtils.getUUIDS(copyFromDB);
|
||||||
if (uuids.isEmpty()) {
|
if (uuids.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -74,16 +74,8 @@ public class ManageUtils {
|
|||||||
fromDB.copyEverything(toDB);
|
fromDB.copyEverything(toDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Database getDB(Plan plugin, String dbName) throws DatabaseInitException {
|
@Deprecated
|
||||||
Database database = null;
|
public static Database getDB(String dbName) throws DatabaseInitException {
|
||||||
for (Database sqldb : plugin.getDatabases()) {
|
return DatabaseSystem.getActiveDatabase(dbName);
|
||||||
String dbConfigName = sqldb.getConfigName();
|
|
||||||
if (Verify.equalsIgnoreCase(dbName, dbConfigName)) {
|
|
||||||
database = sqldb;
|
|
||||||
database.init();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return database;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import main.java.com.djrapitops.plan.database.Database;
|
|||||||
import main.java.com.djrapitops.plan.settings.Settings;
|
import main.java.com.djrapitops.plan.settings.Settings;
|
||||||
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
|
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.line.PlayerActivityGraphCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.line.PlayerActivityGraph;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.structure.SessionTabStructureCreator;
|
import main.java.com.djrapitops.plan.utilities.html.structure.SessionTabStructureCreator;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.tables.SessionsTableCreator;
|
import main.java.com.djrapitops.plan.utilities.html.tables.SessionsTableCreator;
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ public class HtmlStructure {
|
|||||||
int playerCount = db.getUserInfoTable().getServerUserCount(serverUUID);
|
int playerCount = db.getUserInfoTable().getServerUserCount(serverUUID);
|
||||||
String playerData = "[]";
|
String playerData = "[]";
|
||||||
try {
|
try {
|
||||||
playerData = PlayerActivityGraphCreator.buildSeriesDataString(db.getTpsTable().getTPSData(serverUUID));
|
playerData = PlayerActivityGraph.createSeries(db.getTpsTable().getTPSData(serverUUID));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Log.toLog(HtmlStructure.class.getClass().getName(), e);
|
Log.toLog(HtmlStructure.class.getClass().getName(), e);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ package main.java.com.djrapitops.plan.utilities.html.graphs;
|
|||||||
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
|
import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
|
||||||
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
import main.java.com.djrapitops.plan.settings.theme.Theme;
|
||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.ActivityPieCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.ActivityPie;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -19,14 +19,14 @@ import java.util.UUID;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class ActivityStackGraphCreator {
|
public class ActivityStackGraph {
|
||||||
|
|
||||||
private ActivityStackGraphCreator() {
|
private ActivityStackGraph() {
|
||||||
throw new IllegalStateException("Utility Class");
|
throw new IllegalStateException("Utility Class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] createSeries(TreeMap<Long, Map<String, Set<UUID>>> activityData) {
|
public static String[] createSeries(TreeMap<Long, Map<String, Set<UUID>>> activityData) {
|
||||||
String[] sliceNames = ActivityPieCreator.getSliceNames();
|
String[] sliceNames = ActivityPie.getSliceNames();
|
||||||
String[] colors = Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", ");
|
String[] colors = Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", ");
|
||||||
int maxCol = colors.length;
|
int maxCol = colors.length;
|
||||||
|
|
@ -19,12 +19,12 @@ import java.util.stream.Collectors;
|
|||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.6.0
|
* @since 3.6.0
|
||||||
*/
|
*/
|
||||||
public class PunchCardGraphCreator {
|
public class PunchCardGraph {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used to hide the public constructor
|
* Constructor used to hide the public constructor
|
||||||
*/
|
*/
|
||||||
private PunchCardGraphCreator() {
|
private PunchCardGraph() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,10 +34,10 @@ public class PunchCardGraphCreator {
|
|||||||
* @param sessions Sessions (Unique/Player) to be placed into the PunchCard.
|
* @param sessions Sessions (Unique/Player) to be placed into the PunchCard.
|
||||||
* @return Data array as a string.
|
* @return Data array as a string.
|
||||||
*/
|
*/
|
||||||
public static String createDataSeries(Collection<Session> sessions) {
|
public static String createSeries(Collection<Session> sessions) {
|
||||||
List<Long> sessionStarts = getSessionStarts(sessions);
|
List<Long> sessionStarts = getSessionStarts(sessions);
|
||||||
List<int[]> daysAndHours = AnalysisUtils.getDaysAndHours(sessionStarts);
|
List<int[]> daysAndHours = AnalysisUtils.getDaysAndHours(sessionStarts);
|
||||||
int[][] dataArray = createDataArray(daysAndHours);
|
int[][] dataArray = turnIntoArray(daysAndHours);
|
||||||
int big = findBiggestValue(dataArray);
|
int big = findBiggestValue(dataArray);
|
||||||
int[][] scaled = scale(dataArray, big);
|
int[][] scaled = scale(dataArray, big);
|
||||||
StringBuilder arrayBuilder = new StringBuilder("[");
|
StringBuilder arrayBuilder = new StringBuilder("[");
|
||||||
@ -62,7 +62,7 @@ public class PunchCardGraphCreator {
|
|||||||
return arrayBuilder.toString();
|
return arrayBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int[][] createDataArray(List<int[]> daysAndHours) {
|
private static int[][] turnIntoArray(List<int[]> daysAndHours) {
|
||||||
int[][] dataArray = createEmptyArray();
|
int[][] dataArray = createEmptyArray();
|
||||||
for (int[] dAndH : daysAndHours) {
|
for (int[] dAndH : daysAndHours) {
|
||||||
int d = dAndH[0];
|
int d = dAndH[0];
|
@ -4,12 +4,12 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class WorldMapCreator {
|
public class WorldMap {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used to hide the public constructor
|
* Constructor used to hide the public constructor
|
||||||
*/
|
*/
|
||||||
private WorldMapCreator() {
|
private WorldMap() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ public class WorldMapCreator {
|
|||||||
* @param geoLocations The country names of players
|
* @param geoLocations The country names of players
|
||||||
* @return The created data series
|
* @return The created data series
|
||||||
*/
|
*/
|
||||||
public static String createDataSeries(List<String> geoLocations) {
|
public static String createSeries(List<String> geoLocations) {
|
||||||
|
|
||||||
Map<String, Integer> geoCodeCounts = new HashMap<>();
|
Map<String, Integer> geoCodeCounts = new HashMap<>();
|
||||||
Map<String, String> geoCodes = getGeoCodes(geoCodeCounts);
|
Map<String, String> geoCodes = getGeoCodes(geoCodeCounts);
|
@ -6,19 +6,19 @@ import main.java.com.djrapitops.plan.utilities.analysis.Point;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CPUGraphCreator {
|
public class CPUGraph {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used to hide the public constructor
|
* Constructor used to hide the public constructor
|
||||||
*/
|
*/
|
||||||
private CPUGraphCreator() {
|
private CPUGraph() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String buildSeriesDataString(List<TPS> tpsData) {
|
public static String createSeries(List<TPS> tpsData) {
|
||||||
List<Point> points = tpsData.stream()
|
List<Point> points = tpsData.stream()
|
||||||
.map(tps -> new Point(tps.getDate(), tps.getCPUUsage()))
|
.map(tps -> new Point(tps.getDate(), tps.getCPUUsage()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return SeriesCreator.seriesGraph(points, true);
|
return LineSeries.createSeries(points, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package main.java.com.djrapitops.plan.utilities.html.graphs.line;
|
package main.java.com.djrapitops.plan.utilities.html.graphs.line;
|
||||||
|
|
||||||
|
import main.java.com.djrapitops.plan.utilities.analysis.DouglasPeuckerAlgorithm;
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.Point;
|
import main.java.com.djrapitops.plan.utilities.analysis.Point;
|
||||||
|
import main.java.com.djrapitops.plan.utilities.analysis.ReduceGapTriangles;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -15,26 +17,26 @@ import java.util.List;
|
|||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.2
|
* @since 3.5.2
|
||||||
*/
|
*/
|
||||||
public class SeriesCreator {
|
public class LineSeries {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used to hide the public constructor
|
* Constructor used to hide the public constructor
|
||||||
*/
|
*/
|
||||||
private SeriesCreator() {
|
private LineSeries() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String seriesGraph(List<Point> points, boolean reduceGapTriangles) {
|
public static String createSeries(List<Point> points, boolean reduceGapTriangles) {
|
||||||
return seriesGraph(points, reduceGapTriangles, true);
|
return createSeries(points, reduceGapTriangles, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String seriesGraph(List<Point> points, boolean reduceGapTriangles, boolean reducePoints) {
|
public static String createSeries(List<Point> points, boolean reduceGapTriangles, boolean reducePoints) {
|
||||||
StringBuilder arrayBuilder = new StringBuilder("[");
|
StringBuilder arrayBuilder = new StringBuilder("[");
|
||||||
|
|
||||||
// if (reducePoints) {
|
// if (reducePoints) {
|
||||||
// points = DouglasPeuckerAlgorithm.reducePoints(points, 0);
|
// points = DouglasPeuckerAlgorithm.reducePoints(points, 0);
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
// if (reduceGapTriangles) {
|
// if (reduceGapTriangles) {
|
||||||
// points = ReduceGapTriangles.reduce(points);
|
// points = ReduceGapTriangles.reduce(points);
|
||||||
// }
|
// }
|
@ -9,19 +9,19 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class PlayerActivityGraphCreator {
|
public class PlayerActivityGraph {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used to hide the public constructor
|
* Constructor used to hide the public constructor
|
||||||
*/
|
*/
|
||||||
private PlayerActivityGraphCreator() {
|
private PlayerActivityGraph() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String buildSeriesDataString(List<TPS> tpsData) {
|
public static String createSeries(List<TPS> tpsData) {
|
||||||
List<Point> points = tpsData.stream()
|
List<Point> points = tpsData.stream()
|
||||||
.map(tps -> new Point(tps.getDate(), tps.getPlayers()))
|
.map(tps -> new Point(tps.getDate(), tps.getPlayers()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return SeriesCreator.seriesGraph(points, true);
|
return LineSeries.createSeries(points, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,12 +14,12 @@ import java.util.stream.Collectors;
|
|||||||
* @see TPSCountTimer
|
* @see TPSCountTimer
|
||||||
* @since 3.6.0
|
* @since 3.6.0
|
||||||
*/
|
*/
|
||||||
public class RamGraphCreator {
|
public class RamGraph {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used to hide the public constructor
|
* Constructor used to hide the public constructor
|
||||||
*/
|
*/
|
||||||
private RamGraphCreator() {
|
private RamGraph() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,10 +29,10 @@ public class RamGraphCreator {
|
|||||||
* @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute.
|
* @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute.
|
||||||
* @return Series data for HighCharts
|
* @return Series data for HighCharts
|
||||||
*/
|
*/
|
||||||
public static String buildSeriesDataString(List<TPS> tpsData) {
|
public static String createSeries(List<TPS> tpsData) {
|
||||||
List<Point> points = tpsData.stream()
|
List<Point> points = tpsData.stream()
|
||||||
.map(tps -> new Point(tps.getDate(), tps.getUsedMemory()))
|
.map(tps -> new Point(tps.getDate(), tps.getUsedMemory()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return SeriesCreator.seriesGraph(points, true);
|
return LineSeries.createSeries(points, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,13 +5,13 @@ import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ServerPreferencePieCreator {
|
public class ServerPreferencePie {
|
||||||
|
|
||||||
private ServerPreferencePieCreator() {
|
private ServerPreferencePie() {
|
||||||
throw new IllegalStateException("Utility Class");
|
throw new IllegalStateException("Utility Class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String createSeriesData(Map<UUID, String> serverNames, Map<UUID, WorldTimes> serverWorldTimes) {
|
public static String createSeries(Map<UUID, String> serverNames, Map<UUID, WorldTimes> serverWorldTimes) {
|
||||||
StringBuilder seriesBuilder = new StringBuilder("[");
|
StringBuilder seriesBuilder = new StringBuilder("[");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int size = serverWorldTimes.size();
|
int size = serverWorldTimes.size();
|
@ -11,27 +11,20 @@ import java.util.stream.Collectors;
|
|||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @since 3.5.0
|
* @since 3.5.0
|
||||||
*/
|
*/
|
||||||
public class TPSGraphCreator {
|
public class TPSGraph {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used to hide the public constructor
|
* Constructor used to hide the public constructor
|
||||||
*/
|
*/
|
||||||
private TPSGraphCreator() {
|
private TPSGraph() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String buildSeriesDataString(List<TPS> tpsData) {
|
public static String createSeries(List<TPS> tpsData) {
|
||||||
List<Point> points = tpsData.stream()
|
List<Point> points = tpsData.stream()
|
||||||
.map(tps -> new Point(tps.getDate(), tps.getTicksPerSecond()))
|
.map(tps -> new Point(tps.getDate(), tps.getTicksPerSecond()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return SeriesCreator.seriesGraph(points, true);
|
return LineSeries.createSeries(points, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<TPS> filterTPS(List<TPS> tpsData, long nowMinusScale) {
|
|
||||||
return tpsData.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(t -> t.getDate() >= nowMinusScale)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -14,12 +14,12 @@ import java.util.stream.Collectors;
|
|||||||
* @see TPSCountTimer
|
* @see TPSCountTimer
|
||||||
* @since 3.6.0
|
* @since 3.6.0
|
||||||
*/
|
*/
|
||||||
public class WorldLoadGraphCreator {
|
public class WorldLoadGraph {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor used to hide the public constructor
|
* Constructor used to hide the public constructor
|
||||||
*/
|
*/
|
||||||
private WorldLoadGraphCreator() {
|
private WorldLoadGraph() {
|
||||||
throw new IllegalStateException("Utility class");
|
throw new IllegalStateException("Utility class");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,11 +29,11 @@ public class WorldLoadGraphCreator {
|
|||||||
* @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute.
|
* @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute.
|
||||||
* @return Series data for HighCharts
|
* @return Series data for HighCharts
|
||||||
*/
|
*/
|
||||||
public static String buildSeriesDataStringEntities(List<TPS> tpsData) {
|
public static String createSeriesEntities(List<TPS> tpsData) {
|
||||||
List<Point> points = tpsData.stream()
|
List<Point> points = tpsData.stream()
|
||||||
.map(tps -> new Point(tps.getDate(), tps.getEntityCount()))
|
.map(tps -> new Point(tps.getDate(), tps.getEntityCount()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return SeriesCreator.seriesGraph(points, true);
|
return LineSeries.createSeries(points, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,10 +42,10 @@ public class WorldLoadGraphCreator {
|
|||||||
* @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute.
|
* @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute.
|
||||||
* @return Series data for HighCharts
|
* @return Series data for HighCharts
|
||||||
*/
|
*/
|
||||||
public static String buildSeriesDataStringChunks(List<TPS> tpsData) {
|
public static String createSeriesChunks(List<TPS> tpsData) {
|
||||||
List<Point> points = tpsData.stream()
|
List<Point> points = tpsData.stream()
|
||||||
.map(tps -> new Point(tps.getDate(), tps.getChunksLoaded()))
|
.map(tps -> new Point(tps.getDate(), tps.getChunksLoaded()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return SeriesCreator.seriesGraph(points, true);
|
return LineSeries.createSeries(points, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,9 +14,9 @@ import java.util.*;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class ActivityPieCreator {
|
public class ActivityPie {
|
||||||
|
|
||||||
private ActivityPieCreator() {
|
private ActivityPie() {
|
||||||
throw new IllegalStateException("Utility Class");
|
throw new IllegalStateException("Utility Class");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ public class ActivityPieCreator {
|
|||||||
return new String[]{"Very Active", "Active", "Regular", "Irregular", "Inactive"};
|
return new String[]{"Very Active", "Active", "Regular", "Irregular", "Inactive"};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String createSeriesData(Map<String, Set<UUID>> activityData) {
|
public static String createSeries(Map<String, Set<UUID>> activityData) {
|
||||||
String[] colors = Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", ");
|
String[] colors = Theme.getValue(ThemeVal.GRAPH_ACTIVITY_PIE).split(", ");
|
||||||
int maxCol = colors.length;
|
int maxCol = colors.length;
|
||||||
|
|
||||||
@ -38,6 +38,6 @@ public class ActivityPieCreator {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PieSeriesCreator.createSeriesData(slices);
|
return PieSeries.createSeries(slices);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,12 +11,12 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
public class PieSeriesCreator {
|
public class PieSeries {
|
||||||
private PieSeriesCreator() {
|
private PieSeries() {
|
||||||
throw new IllegalStateException("Utility Class");
|
throw new IllegalStateException("Utility Class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String createSeriesData(List<PieSlice> slices) {
|
public static String createSeries(List<PieSlice> slices) {
|
||||||
StringBuilder seriesBuilder = new StringBuilder("[");
|
StringBuilder seriesBuilder = new StringBuilder("[");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int size = slices.size();
|
int size = slices.size();
|
@ -12,9 +12,9 @@ import main.java.com.djrapitops.plan.utilities.comparators.PieSliceComparator;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class WorldPieCreator {
|
public class WorldPie {
|
||||||
|
|
||||||
private WorldPieCreator() {
|
private WorldPie() {
|
||||||
throw new IllegalStateException("Utility Class");
|
throw new IllegalStateException("Utility Class");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,21 +24,21 @@ public class WorldPieCreator {
|
|||||||
* @param worldTimes WorldTimes object.
|
* @param worldTimes WorldTimes object.
|
||||||
* @return String array, index 0: Series data, 1: drilldown data
|
* @return String array, index 0: Series data, 1: drilldown data
|
||||||
*/
|
*/
|
||||||
public static String[] createSeriesData(WorldTimes worldTimes) {
|
public static String[] createSeries(WorldTimes worldTimes) {
|
||||||
List<PieSlice> slices = turnToSlices(worldTimes);
|
List<PieSlice> slices = turnIntoSlices(worldTimes);
|
||||||
|
|
||||||
if (Settings.ORDER_WORLD_PIE_BY_PERC.isTrue()) {
|
if (Settings.ORDER_WORLD_PIE_BY_PERC.isTrue()) {
|
||||||
slices.sort(new PieSliceComparator());
|
slices.sort(new PieSliceComparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
String seriesData = PieSeriesCreator.createSeriesData(slices);
|
String seriesData = PieSeries.createSeries(slices);
|
||||||
|
|
||||||
String drilldownData = createDrilldownData(worldTimes);
|
String drilldownData = createDrilldown(worldTimes);
|
||||||
|
|
||||||
return new String[]{seriesData, drilldownData};
|
return new String[]{seriesData, drilldownData};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<PieSlice> turnToSlices(WorldTimes worldTimes) {
|
private static List<PieSlice> turnIntoSlices(WorldTimes worldTimes) {
|
||||||
String[] colors = Theme.getValue(ThemeVal.GRAPH_WORLD_PIE).split(", ");
|
String[] colors = Theme.getValue(ThemeVal.GRAPH_WORLD_PIE).split(", ");
|
||||||
int colLenght = colors.length;
|
int colLenght = colors.length;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public class WorldPieCreator {
|
|||||||
return playtimePerAlias;
|
return playtimePerAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String createDrilldownData(WorldTimes worldTimes) {
|
private static String createDrilldown(WorldTimes worldTimes) {
|
||||||
StringBuilder drilldownBuilder = new StringBuilder();
|
StringBuilder drilldownBuilder = new StringBuilder();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
@ -13,7 +13,7 @@ import main.java.com.djrapitops.plan.settings.theme.ThemeVal;
|
|||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.WorldPieCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -66,7 +66,7 @@ public class ServerAccordionCreator {
|
|||||||
String worldId = "worldPieServer" + sanitizedServerName;
|
String worldId = "worldPieServer" + sanitizedServerName;
|
||||||
AnalysisUtils.addMissingWorlds(worldTimes);
|
AnalysisUtils.addMissingWorlds(worldTimes);
|
||||||
|
|
||||||
String[] worldData = WorldPieCreator.createSeriesData(worldTimes);
|
String[] worldData = WorldPie.createSeries(worldTimes);
|
||||||
|
|
||||||
// Accordion panel header
|
// Accordion panel header
|
||||||
html.append("<div class=\"panel panel-col-").append(Theme.getValue(ThemeVal.PARSED_SERVER_ACCORDION)).append("\">")
|
html.append("<div class=\"panel panel-col-").append(Theme.getValue(ThemeVal.PARSED_SERVER_ACCORDION)).append("\">")
|
||||||
|
@ -15,7 +15,7 @@ import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
|||||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
|
import main.java.com.djrapitops.plan.utilities.html.HtmlStructure;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.WorldPieCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.tables.KillsTableCreator;
|
import main.java.com.djrapitops.plan.utilities.html.tables.KillsTableCreator;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.tables.SessionsTableCreator;
|
import main.java.com.djrapitops.plan.utilities.html.tables.SessionsTableCreator;
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class SessionTabStructureCreator {
|
|||||||
WorldTimes worldTimes = session.getWorldTimes();
|
WorldTimes worldTimes = session.getWorldTimes();
|
||||||
AnalysisUtils.addMissingWorlds(worldTimes);
|
AnalysisUtils.addMissingWorlds(worldTimes);
|
||||||
|
|
||||||
String[] worldData = WorldPieCreator.createSeriesData(worldTimes);
|
String[] worldData = WorldPie.createSeries(worldTimes);
|
||||||
|
|
||||||
String killTable = KillsTableCreator.createTable(session.getPlayerKills());
|
String killTable = KillsTableCreator.createTable(session.getPlayerKills());
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import main.java.com.djrapitops.plan.systems.cache.SessionCache;
|
|||||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||||
import main.java.com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
import main.java.com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.WorldPieCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -113,7 +113,7 @@ public class SessionsTableCreator {
|
|||||||
|
|
||||||
Map<String, Long> playtimePerWorld = session.getWorldTimes().getWorldTimes().entrySet().stream()
|
Map<String, Long> playtimePerWorld = session.getWorldTimes().getWorldTimes().entrySet().stream()
|
||||||
.collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().getTotal()));
|
.collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().getTotal()));
|
||||||
Map<String, Long> playtimePerAlias = WorldPieCreator.transformToAliases(playtimePerWorld, aliases);
|
Map<String, Long> playtimePerAlias = WorldPie.transformToAliases(playtimePerWorld, aliases);
|
||||||
|
|
||||||
WorldTimes worldTimes = session.getWorldTimes();
|
WorldTimes worldTimes = session.getWorldTimes();
|
||||||
long total = worldTimes.getTotal();
|
long total = worldTimes.getTotal();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name: Plan
|
name: Plan
|
||||||
author: Rsl1122
|
author: Rsl1122
|
||||||
main: main.java.com.djrapitops.plan.PlanBungee
|
main: main.java.com.djrapitops.plan.PlanBungee
|
||||||
version: 4.1.3
|
version: 4.1.3.1
|
@ -1,7 +1,7 @@
|
|||||||
name: Plan
|
name: Plan
|
||||||
author: Rsl1122
|
author: Rsl1122
|
||||||
main: main.java.com.djrapitops.plan.Plan
|
main: main.java.com.djrapitops.plan.Plan
|
||||||
version: 4.1.3
|
version: 4.1.3.1
|
||||||
softdepend:
|
softdepend:
|
||||||
- EssentialsX
|
- EssentialsX
|
||||||
- Towny
|
- Towny
|
||||||
|
@ -69,7 +69,7 @@ public class DatabaseTest {
|
|||||||
TestInit t = TestInit.init();
|
TestInit t = TestInit.init();
|
||||||
plan = t.getPlanMock();
|
plan = t.getPlanMock();
|
||||||
|
|
||||||
db = new SQLiteDB(plan, "debug" + MiscUtils.getTime());
|
db = new SQLiteDB("debug" + MiscUtils.getTime());
|
||||||
db.init();
|
db.init();
|
||||||
|
|
||||||
when(plan.getDB()).thenReturn(db);
|
when(plan.getDB()).thenReturn(db);
|
||||||
@ -132,12 +132,12 @@ public class DatabaseTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMySQLGetConfigName() {
|
public void testMySQLGetConfigName() {
|
||||||
assertEquals("mysql", new MySQLDB(plan).getConfigName());
|
assertEquals("mysql", new MySQLDB().getConfigName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMySQLGetName() {
|
public void testMySQLGetName() {
|
||||||
assertEquals("MySQL", new MySQLDB(plan).getName());
|
assertEquals("MySQL", new MySQLDB().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 3000)
|
@Test(timeout = 3000)
|
||||||
@ -776,7 +776,7 @@ public class DatabaseTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBackupAndRestore() throws SQLException, DatabaseInitException {
|
public void testBackupAndRestore() throws SQLException, DatabaseInitException {
|
||||||
SQLiteDB backup = new SQLiteDB(plan, "debug-backup" + MiscUtils.getTime());
|
SQLiteDB backup = new SQLiteDB("debug-backup" + MiscUtils.getTime());
|
||||||
backup.init();
|
backup.init();
|
||||||
|
|
||||||
saveAllData(db);
|
saveAllData(db);
|
||||||
|
@ -8,7 +8,7 @@ import main.java.com.djrapitops.plan.data.container.Session;
|
|||||||
import main.java.com.djrapitops.plan.data.container.TPS;
|
import main.java.com.djrapitops.plan.data.container.TPS;
|
||||||
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
||||||
import main.java.com.djrapitops.plan.utilities.analysis.Point;
|
import main.java.com.djrapitops.plan.utilities.analysis.Point;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.PunchCardGraphCreator;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.PunchCardGraph;
|
||||||
import main.java.com.djrapitops.plan.utilities.html.graphs.line.*;
|
import main.java.com.djrapitops.plan.utilities.html.graphs.line.*;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -54,34 +54,34 @@ public class GraphTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGraphCreators() {
|
public void testGraphCreators() {
|
||||||
String expected = "[[0,0.0],[1,1.0],[2,2.0],[3,3.0],[4,4.0],[5,5.0],[6,6.0],[7,7.0],[8,8.0],[9,9.0]]";
|
String expected = "[[0,0.0],[1,1.0],[2,2.0],[3,3.0],[4,4.0],[5,5.0],[6,6.0],[7,7.0],[8,8.0],[9,9.0]]";
|
||||||
assertEquals(expected, CPUGraphCreator.buildSeriesDataString(tpsList));
|
assertEquals(expected, CPUGraph.createSeries(tpsList));
|
||||||
assertEquals(expected, PlayerActivityGraphCreator.buildSeriesDataString(tpsList));
|
assertEquals(expected, PlayerActivityGraph.createSeries(tpsList));
|
||||||
// TODO Fix TimeZone Dependency of this test
|
// TODO Fix TimeZone Dependency of this test
|
||||||
// assertEquals("[{x:3600000, y:3, z:14, marker: { radius:14}},]", PunchCardGraphCreator.createDataSeries(sessionList));
|
// assertEquals("[{x:3600000, y:3, z:14, marker: { radius:14}},]", PunchCardGraph.createSeries(sessionList));
|
||||||
|
|
||||||
assertEquals(expected, RamGraphCreator.buildSeriesDataString(tpsList));
|
assertEquals(expected, RamGraph.createSeries(tpsList));
|
||||||
assertEquals(expected, TPSGraphCreator.buildSeriesDataString(tpsList));
|
assertEquals(expected, TPSGraph.createSeries(tpsList));
|
||||||
assertEquals(expected, WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsList));
|
assertEquals(expected, WorldLoadGraph.createSeriesChunks(tpsList));
|
||||||
assertEquals(expected, WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsList));
|
assertEquals(expected, WorldLoadGraph.createSeriesEntities(tpsList));
|
||||||
// assertEquals("[{'code':'1','value':1},{'code':'2','value':2},{'code':'3','value':3},{'code':'4','value':4},{'code':'5','value':5},{'code':'6','value':6},{'code':'7','value':7},{'code':'8','value':8},{'code':'9','value':9}]", WorldMapCreator.createDataSeries(geoList));
|
// assertEquals("[{'code':'1','value':1},{'code':'2','value':2},{'code':'3','value':3},{'code':'4','value':4},{'code':'5','value':5},{'code':'6','value':6},{'code':'7','value':7},{'code':'8','value':8},{'code':'9','value':9}]", WorldMap.createSeries(geoList));
|
||||||
// TODO fix config mock dependency
|
// TODO fix config mock dependency
|
||||||
// assertEquals("[[{name:'WORLD',y:0,drilldown: 'WORLD'}], [{name:'WORLD', id:'WORLD',colors: gmPieColors,data: [['SURVIVAL',0],['SPECTATOR',0],['CREATIVE',0],['ADVENTURE',0]]}]]",
|
// assertEquals("[[{name:'WORLD',y:0,drilldown: 'WORLD'}], [{name:'WORLD', id:'WORLD',colors: gmPieColors,data: [['SURVIVAL',0],['SPECTATOR',0],['CREATIVE',0],['ADVENTURE',0]]}]]",
|
||||||
// Arrays.toString(WorldPieCreator.createSeriesData(worldTimes)));
|
// Arrays.toString(WorldPie.createSeries(worldTimes)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGraphCreatorsForBracketMistakes() {
|
public void testGraphCreatorsForBracketMistakes() {
|
||||||
String[] series = new String[]{
|
String[] series = new String[]{
|
||||||
CPUGraphCreator.buildSeriesDataString(tpsList),
|
CPUGraph.createSeries(tpsList),
|
||||||
PlayerActivityGraphCreator.buildSeriesDataString(tpsList),
|
PlayerActivityGraph.createSeries(tpsList),
|
||||||
PunchCardGraphCreator.createDataSeries(sessionList),
|
PunchCardGraph.createSeries(sessionList),
|
||||||
RamGraphCreator.buildSeriesDataString(tpsList),
|
RamGraph.createSeries(tpsList),
|
||||||
TPSGraphCreator.buildSeriesDataString(tpsList),
|
TPSGraph.createSeries(tpsList),
|
||||||
WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsList),
|
WorldLoadGraph.createSeriesChunks(tpsList),
|
||||||
WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsList),
|
WorldLoadGraph.createSeriesEntities(tpsList),
|
||||||
// WorldMapCreator.createDataSeries(geoList),
|
// WorldMap.createSeries(geoList),
|
||||||
// TODO fix config mock dependency
|
// TODO fix config mock dependency
|
||||||
// Arrays.toString(WorldPieCreator.createSeriesData(worldTimes))
|
// Arrays.toString(WorldPie.createSeries(worldTimes))
|
||||||
};
|
};
|
||||||
for (String test : series) {
|
for (String test : series) {
|
||||||
int opened = StringUtils.countMatches(test, "{");
|
int opened = StringUtils.countMatches(test, "{");
|
||||||
@ -95,7 +95,7 @@ public class GraphTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSeriesCreator() {
|
public void testSeriesCreator() {
|
||||||
String result = StringUtils.removeAll(SeriesCreator.seriesGraph(points, false, false), "[\\[\\]]");
|
String result = StringUtils.removeAll(LineSeries.createSeries(points, false, false), "[\\[\\]]");
|
||||||
String[] splittedResult = result.split(",");
|
String[] splittedResult = result.split(",");
|
||||||
|
|
||||||
Map<String, String> expected = new LinkedHashMap<>();
|
Map<String, String> expected = new LinkedHashMap<>();
|
||||||
|
@ -163,7 +163,7 @@ public class MiscUtilsTest {
|
|||||||
TestInit t = TestInit.init();
|
TestInit t = TestInit.init();
|
||||||
Plan plan = t.getPlanMock();
|
Plan plan = t.getPlanMock();
|
||||||
|
|
||||||
db = new SQLiteDB(plan, "debug" + MiscUtils.getTime());
|
db = new SQLiteDB("debug" + MiscUtils.getTime());
|
||||||
db.init();
|
db.init();
|
||||||
|
|
||||||
db.getServerTable().saveCurrentServerInfo(new ServerInfo(-1, TestInit.getServerUUID(), "ServerName", "", 20));
|
db.getServerTable().saveCurrentServerInfo(new ServerInfo(-1, TestInit.getServerUUID(), "ServerName", "", 20));
|
||||||
|
Loading…
Reference in New Issue
Block a user