mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-14 12:11:23 +01:00
Split InformationManager, 3rd party analysis enabled.
This commit is contained in:
parent
7ee67d4be7
commit
8b391a31cf
@ -38,6 +38,7 @@ import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
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.info.BukkitInformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.info.server.ServerInfoManager;
|
||||
import main.java.com.djrapitops.plan.systems.listeners.*;
|
||||
@ -164,7 +165,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
|
||||
processingQueue = new ProcessingQueue();
|
||||
|
||||
serverInfoManager = new ServerInfoManager(this);
|
||||
infoManager = new InformationManager(this);
|
||||
infoManager = new BukkitInformationManager(this);
|
||||
webServer.setInfoManager(infoManager);
|
||||
|
||||
Benchmark.stop("Enable", "WebServer Initialization");
|
||||
|
@ -7,6 +7,7 @@ import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
|
||||
@ -177,7 +178,7 @@ public class API {
|
||||
* @see AnalysisData
|
||||
*/
|
||||
public AnalysisData getAnalysisDataFromCache() {
|
||||
return plugin.getInfoManager().getAnalysisData();
|
||||
return ((BukkitInformationManager) plugin.getInfoManager()).getAnalysisData();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Abstraction interface for both Plan and PlanBungee.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@
|
||||
package main.java.com.djrapitops.plan.api.exceptions;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Exception thrown when Html page parsing fails.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -16,6 +16,7 @@ import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.database.databases.MySQLDB;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
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.server.ServerInfoManager;
|
||||
import main.java.com.djrapitops.plan.systems.processing.Processor;
|
||||
@ -28,7 +29,7 @@ import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Bungee Main class.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@ -82,7 +83,7 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
|
||||
}
|
||||
|
||||
serverInfoManager = new ServerInfoManager(this);
|
||||
infoManager = new InformationManager(this);
|
||||
infoManager = new BungeeInformationManager(this);
|
||||
webServer.setInfoManager(infoManager);
|
||||
|
||||
registerListener(new BungeePlayerListener(this));
|
||||
|
@ -1,6 +1,5 @@
|
||||
package main.java.com.djrapitops.plan.command.commands;
|
||||
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.command.CommandType;
|
||||
import com.djrapitops.plugin.command.CommandUtils;
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
@ -14,13 +13,11 @@ import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.html.HtmlUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* This subcommand is used to run the analysis and access the /server link.
|
||||
@ -75,13 +72,15 @@ public class AnalyzeCommand extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
Optional<Long> analysisRefreshDate = infoManager.getAnalysisRefreshDate();
|
||||
boolean forcedRefresh = args.length >= 1 && "-r".equals(args[0]);
|
||||
boolean refresh = !analysisRefreshDate.isPresent()
|
||||
|| analysisRefreshDate.get() < MiscUtils.getTime() - TimeAmount.MINUTE.ms()
|
||||
|| forcedRefresh;
|
||||
// TODO Rewrite so that a server can be specified
|
||||
// TODO Write a command for listing servers.
|
||||
// Optional<Long> analysisRefreshDate = infoManager.getAnalysisRefreshDate();
|
||||
// boolean forcedRefresh = args.length >= 1 && "-r".equals(args[0]);
|
||||
// boolean refresh = !analysisRefreshDate.isPresent()
|
||||
// || analysisRefreshDate.get() < MiscUtils.getTime() - TimeAmount.MINUTE.ms()
|
||||
// || forcedRefresh;
|
||||
|
||||
updateCache(sender, refresh);
|
||||
updateCache(sender, true);
|
||||
|
||||
sender.sendMessage(Locale.get(Msg.CMD_INFO_FETCH_DATA).toString());
|
||||
if (plugin.getWebServer().isAuthRequired() && CommandUtils.isPlayer(sender)) {
|
||||
|
@ -8,10 +8,15 @@ import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.ManageUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
@ -63,20 +68,16 @@ public class ManageClearCommand extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO CLEAR COMMAND
|
||||
// final Database database = ManageUtils.getDB(plugin, dbName);
|
||||
//
|
||||
// // If DB is null return
|
||||
// if (!Check.isTrue(Verify.notNull(database), Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString(), sender)) {
|
||||
// Log.error(dbName + " was null!");
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// runClearTask(sender, database);
|
||||
try {
|
||||
Database database = ManageUtils.getDB(plugin, dbName);
|
||||
runClearTask(sender, database);
|
||||
} catch (DatabaseInitException e) {
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_FAIL_FAULTY_DB).toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void runClearTask(ISender sender, final Database database) {
|
||||
private void runClearTask(ISender sender, Database database) {
|
||||
plugin.getRunnableFactory().createNew(new AbsRunnable("DBClearTask") {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -84,7 +85,14 @@ public class ManageClearCommand extends SubCommand {
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
|
||||
|
||||
database.removeAllData();
|
||||
// TODO Clear active session of all users & start new ones
|
||||
|
||||
DataCache dataCache = plugin.getDataCache();
|
||||
long now = MiscUtils.getTime();
|
||||
dataCache.getActiveSessions().clear();
|
||||
plugin.getServer().getOnlinePlayers().forEach(
|
||||
player -> dataCache.cacheSession(player.getUniqueId(),
|
||||
new Session(now, player.getWorld().getName(), player.getGameMode().name()))
|
||||
);
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_CLEAR_SUCCESS).toString());
|
||||
} catch (SQLException e) {
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_FAIL).toString());
|
||||
|
@ -8,15 +8,20 @@ import com.djrapitops.plugin.utilities.Verify;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.bukkit.Bukkit.getPlayer;
|
||||
|
||||
/**
|
||||
* This manage subcommand is used to remove a single player's data from the
|
||||
* database.
|
||||
@ -84,8 +89,13 @@ public class ManageRemoveCommand extends SubCommand {
|
||||
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_START).parse());
|
||||
try {
|
||||
// TODO Clear active session of user & start new one
|
||||
plugin.getDB().removeAccount(uuid);
|
||||
|
||||
DataCache dataCache = plugin.getDataCache();
|
||||
Player player = getPlayer(uuid);
|
||||
dataCache.getActiveSessions().remove(uuid);
|
||||
dataCache.cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name()));
|
||||
|
||||
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName()));
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
|
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* 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.info;
|
||||
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import main.java.com.djrapitops.plan.command.commands.AnalyzeCommand;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.systems.info.parsing.AnalysisPageParser;
|
||||
import main.java.com.djrapitops.plan.systems.info.parsing.InspectPageParser;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.response.InspectPageResponse;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class BukkitInformationManager extends InformationManager {
|
||||
|
||||
private final Plan plugin;
|
||||
private final DataCache dataCache;
|
||||
private final Analysis analysis;
|
||||
|
||||
private AnalysisData analysisData;
|
||||
private String analysisPluginsTab;
|
||||
private Long refreshDate;
|
||||
|
||||
|
||||
public BukkitInformationManager(Plan plugin) {
|
||||
this.plugin = plugin;
|
||||
dataCache = new DataCache(plugin);
|
||||
analysis = new Analysis(plugin);
|
||||
|
||||
Optional<String> bungeeConnectionAddress = plugin.getServerInfoManager().getBungeeConnectionAddress();
|
||||
if (bungeeConnectionAddress.isPresent()) {
|
||||
webServerAddress = bungeeConnectionAddress.get();
|
||||
attemptConnection();
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshAnalysis() {
|
||||
plugin.getDataCache().cacheSavedNames();
|
||||
analysis.runAnalysis(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cachePlayer(UUID uuid) {
|
||||
PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(this, uuid));
|
||||
// TODO Player page plugin tab request
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCached(UUID uuid) {
|
||||
if (usingBungeeWebServer) {
|
||||
// TODO Check if cached on bungee
|
||||
}
|
||||
return super.isCached(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnalysisCached() {
|
||||
if (usingBungeeWebServer) {
|
||||
// TODO Check if cached on bungee
|
||||
}
|
||||
return PageCache.isCached("analysisPage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAnalysisHtml() {
|
||||
// TODO Bungee part.
|
||||
try {
|
||||
return new AnalysisPageParser(analysisData, plugin).parse();
|
||||
} catch (ParseException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerHtml(UUID uuid) {
|
||||
if (usingBungeeWebServer) {
|
||||
// TODO Bungee request
|
||||
}
|
||||
try {
|
||||
return new InspectPageParser(uuid, plugin).parse();
|
||||
} catch (ParseException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataCache getDataCache() {
|
||||
return dataCache;
|
||||
}
|
||||
|
||||
public void cacheAnalysisdata(AnalysisData analysisData) {
|
||||
this.analysisData = analysisData;
|
||||
refreshDate = MiscUtils.getTime();
|
||||
// TODO Web Caching (Move from Analysis)
|
||||
AnalyzeCommand.sendAnalysisMessage(analysisNotification);
|
||||
analysisNotification.clear();
|
||||
}
|
||||
|
||||
public AnalysisData getAnalysisData() {
|
||||
return analysisData;
|
||||
}
|
||||
|
||||
public Optional<Long> getAnalysisRefreshDate() {
|
||||
return refreshDate != null ? Optional.of(refreshDate) : Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attemptConnection() {
|
||||
usingBungeeWebServer = true;
|
||||
// TODO Check the connection
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.info;
|
||||
|
||||
import main.java.com.djrapitops.plan.bungee.PlanBungee;
|
||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.response.InspectPageResponse;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class BungeeInformationManager extends InformationManager {
|
||||
|
||||
public BungeeInformationManager(PlanBungee plugin) {
|
||||
usingBungeeWebServer = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshAnalysis() {
|
||||
// TODO Refresh network page
|
||||
}
|
||||
|
||||
public void refreshAnalysis(UUID serverUUID) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cachePlayer(UUID uuid) {
|
||||
PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(this, uuid));
|
||||
// TODO Player page plugin tab request
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataCache getDataCache() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attemptConnection() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnalysisCached() {
|
||||
return PageCache.isCached("networkPage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerHtml(UUID uuid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAnalysisHtml() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -5,25 +5,12 @@
|
||||
package main.java.com.djrapitops.plan.systems.info;
|
||||
|
||||
import com.djrapitops.plugin.command.ISender;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.api.exceptions.ParseException;
|
||||
import main.java.com.djrapitops.plan.bungee.PlanBungee;
|
||||
import main.java.com.djrapitops.plan.command.commands.AnalyzeCommand;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.systems.cache.SessionCache;
|
||||
import main.java.com.djrapitops.plan.systems.info.parsing.AnalysisPageParser;
|
||||
import main.java.com.djrapitops.plan.systems.info.parsing.InspectPageParser;
|
||||
import main.java.com.djrapitops.plan.systems.info.parsing.UrlParser;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.response.InspectPageResponse;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -32,50 +19,18 @@ import java.util.UUID;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class InformationManager {
|
||||
// TODO Class that manages ALL information for API, WebAPI requests, Command Caching etc.
|
||||
private Plan plugin;
|
||||
private Database db;
|
||||
public abstract class InformationManager {
|
||||
boolean usingBungeeWebServer;
|
||||
String webServerAddress;
|
||||
Set<ISender> analysisNotification;
|
||||
|
||||
private DataCache dataCache;
|
||||
|
||||
private boolean usingBungeeWebServer;
|
||||
private String webServerAddress;
|
||||
|
||||
private Set<ISender> analysisNotification;
|
||||
private Analysis analysis;
|
||||
private AnalysisData analysisData;
|
||||
private String analysisPluginsTab;
|
||||
private Long refreshDate;
|
||||
|
||||
public InformationManager(Plan plugin) {
|
||||
this.plugin = plugin;
|
||||
db = plugin.getDB();
|
||||
|
||||
plugin.getServerInfoManager().getBungeeConnectionAddress()
|
||||
.ifPresent(address -> webServerAddress = address);
|
||||
|
||||
dataCache = new DataCache(plugin);
|
||||
analysis = new Analysis(plugin);
|
||||
public InformationManager() {
|
||||
analysisNotification = new HashSet<>();
|
||||
|
||||
if (webServerAddress != null) {
|
||||
attemptBungeeConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public InformationManager(PlanBungee plugin) {
|
||||
// TODO Init info manager.
|
||||
}
|
||||
public abstract void attemptConnection();
|
||||
|
||||
public void attemptBungeeConnection() {
|
||||
// TODO WebAPI bungee connection check
|
||||
}
|
||||
|
||||
public void cachePlayer(UUID uuid) {
|
||||
PageCache.loadPage("inspectPage: " + uuid, () -> new InspectPageResponse(this, uuid));
|
||||
// TODO Player page plugin tab request
|
||||
}
|
||||
public abstract void cachePlayer(UUID uuid);
|
||||
|
||||
public UrlParser getLinkTo(String target) {
|
||||
if (webServerAddress != null) {
|
||||
@ -85,68 +40,37 @@ public class InformationManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAnalysis() {
|
||||
plugin.getDataCache().cacheSavedNames();
|
||||
analysis.runAnalysis(this);
|
||||
}
|
||||
public abstract void refreshAnalysis();
|
||||
|
||||
public DataCache getDataCache() {
|
||||
return dataCache;
|
||||
}
|
||||
public abstract DataCache getDataCache();
|
||||
|
||||
public SessionCache getSessionCache() {
|
||||
return dataCache;
|
||||
return getDataCache();
|
||||
}
|
||||
|
||||
public boolean isCached(UUID uuid) {
|
||||
if (usingBungeeWebServer) {
|
||||
// TODO bungee part
|
||||
}
|
||||
return PageCache.isCached("inspectPage: " + uuid);
|
||||
}
|
||||
|
||||
public String getPlayerHtml(UUID uuid) {
|
||||
// TODO Bungee part.
|
||||
try {
|
||||
return new InspectPageParser(uuid, plugin).parse();
|
||||
} catch (ParseException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public abstract String getPlayerHtml(UUID uuid);
|
||||
|
||||
public boolean isAnalysisCached() {
|
||||
// TODO Bungee part
|
||||
return PageCache.isCached("analysisPage");
|
||||
}
|
||||
/**
|
||||
* Used for /server on Bukkit and /network on Bungee
|
||||
*
|
||||
* @return Is page cached.
|
||||
*/
|
||||
public abstract boolean isAnalysisCached();
|
||||
|
||||
public String getAnalysisHtml() {
|
||||
// TODO Bungee part.
|
||||
try {
|
||||
return new AnalysisPageParser(analysisData, plugin).parse();
|
||||
} catch (ParseException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void cacheAnalysisdata(AnalysisData analysisData) {
|
||||
this.analysisData = analysisData;
|
||||
refreshDate = MiscUtils.getTime();
|
||||
// TODO Web Caching (Move from Analysis)
|
||||
AnalyzeCommand.sendAnalysisMessage(analysisNotification);
|
||||
analysisNotification.clear();
|
||||
}
|
||||
/**
|
||||
* Used for /server on Bukkit and /network on Bungee
|
||||
*
|
||||
* @return Html of a page.
|
||||
*/
|
||||
public abstract String getAnalysisHtml();
|
||||
|
||||
public void addAnalysisNotification(ISender sender) {
|
||||
analysisNotification.add(sender);
|
||||
}
|
||||
|
||||
public AnalysisData getAnalysisData() {
|
||||
return analysisData;
|
||||
}
|
||||
|
||||
public Optional<Long> getAnalysisRefreshDate() {
|
||||
return refreshDate != null ? Optional.of(refreshDate) : Optional.empty();
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* //TODO Class Javadoc Comment
|
||||
* Registers the user to the database and marks first session if the user has no actions.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@ -49,7 +49,7 @@ public class RegisterProcessor extends PlayerProcessor {
|
||||
if (!usersTable.isRegistered(uuid)) {
|
||||
usersTable.registerUser(uuid, registered, name);
|
||||
}
|
||||
if (userInfoTable.isRegistered(uuid)) {
|
||||
if (db.getActionsTable().getActions(uuid).size() > 0) {
|
||||
return;
|
||||
}
|
||||
plugin.getDataCache().markFirstSession(uuid);
|
||||
|
@ -15,7 +15,7 @@ import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.database.tables.TPSTable;
|
||||
import main.java.com.djrapitops.plan.locale.Locale;
|
||||
import main.java.com.djrapitops.plan.locale.Msg;
|
||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.systems.info.BukkitInformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.info.InformationManager;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.PageCache;
|
||||
import main.java.com.djrapitops.plan.systems.webserver.response.AnalysisPageResponse;
|
||||
@ -30,10 +30,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -102,42 +99,28 @@ public class Analysis {
|
||||
*/
|
||||
public boolean analyzeData(InformationManager infoManager, Database db) {
|
||||
try {
|
||||
// rawData.sort(new UserInfoLastPlayedComparator());
|
||||
// List<UUID> uuids = rawData.stream().map(UserInfo::getUuid).collect(Collectors.toList());
|
||||
Benchmark.start("Create Empty dataset");
|
||||
DataCache dataCache = plugin.getDataCache();
|
||||
|
||||
|
||||
AnalysisData analysisData = new AnalysisData();
|
||||
List<PluginData> thirdPartyPlugins = plugin.getHookHandler().getAdditionalDataSources();
|
||||
analysisData.setPluginsTabLayout(HtmlStructure.createAnalysisPluginsTabLayout(thirdPartyPlugins));
|
||||
analysisData.setPlanVersion(plugin.getVersion());
|
||||
ActivityPart activityPart = analysisData.getActivityPart();
|
||||
// TODO GetRecentPlayers
|
||||
// activityPart.setRecentPlayersUUIDs(uuids);
|
||||
// analysisData.getPlayerCountPart().addPlayers(uuids);
|
||||
|
||||
// activityPart.setRecentPlayers(rawData.stream().map(UserInfo::getName).collect(Collectors.toList()));
|
||||
|
||||
Benchmark.stop("Analysis", "Create Empty dataset");
|
||||
fillDataset(analysisData, db);
|
||||
long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase");
|
||||
|
||||
Benchmark.start("Analysis Phase");
|
||||
Log.debug("Analysis", "Analysis Phase");
|
||||
|
||||
//TODO Fetch Size
|
||||
log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(0, fetchPhaseLength));
|
||||
|
||||
fillDataset(analysisData, db);
|
||||
// Analyze
|
||||
log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(analysisData.getPlayerCountPart().getPlayerCount(), fetchPhaseLength));
|
||||
analysisData.analyseData();
|
||||
Benchmark.stop("Analysis", "Analysis Phase");
|
||||
|
||||
log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString());
|
||||
Log.debug("Analysis", "Analyzing additional data sources (3rd party)");
|
||||
// TODO analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(uuids));
|
||||
|
||||
infoManager.cacheAnalysisdata(analysisData);
|
||||
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(analysisData.getPlayerCountPart().getUuids()));
|
||||
((BukkitInformationManager) infoManager).cacheAnalysisdata(analysisData);
|
||||
long time = Benchmark.stop("Analysis", "Analysis");
|
||||
|
||||
Log.logDebug("Analysis", time);
|
||||
@ -160,12 +143,10 @@ public class Analysis {
|
||||
}
|
||||
|
||||
private void log(String msg) {
|
||||
// TODO Send info to the command sender. (Needs a new system)
|
||||
Log.info(msg);
|
||||
}
|
||||
|
||||
private Map<String, Serializable> analyzeAdditionalPluginData(List<UUID> uuids) {
|
||||
// TODO Rewrite
|
||||
private Map<String, Serializable> analyzeAdditionalPluginData(Set<UUID> uuids) {
|
||||
Benchmark.start("3rd party");
|
||||
final Map<String, Serializable> replaceMap = new HashMap<>();
|
||||
final HookHandler hookHandler = plugin.getHookHandler();
|
||||
@ -190,7 +171,7 @@ public class Analysis {
|
||||
return;
|
||||
}
|
||||
if (analysisTypes.contains(AnalysisType.HTML)) {
|
||||
replaceMap.put(source.getPlaceholder(AnalysisType.HTML.getPlaceholderModifier()), source.getHtmlReplaceValue(AnalysisType.HTML.getModifier(), uuids.get(0)));
|
||||
replaceMap.put(source.getPlaceholder(AnalysisType.HTML.getPlaceholderModifier()), source.getHtmlReplaceValue(AnalysisType.HTML.getModifier(), UUID.randomUUID()));
|
||||
return;
|
||||
}
|
||||
for (AnalysisType type : totalTypes) {
|
||||
|
@ -77,7 +77,7 @@ public class AnalysisUtils {
|
||||
* @param uuids
|
||||
* @return
|
||||
*/
|
||||
public static String getTotal(AnalysisType analysisType, PluginData source, List<UUID> uuids) {
|
||||
public static String getTotal(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) {
|
||||
if (analysisType == null) {
|
||||
return source.parseContainer("Err ", "Null Analysistype. ");
|
||||
}
|
||||
@ -105,7 +105,7 @@ public class AnalysisUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private static Stream<Serializable> getCorrectValues(List<UUID> uuids, PluginData source) {
|
||||
private static Stream<Serializable> getCorrectValues(Collection<UUID> uuids, PluginData source) {
|
||||
return uuids.stream()
|
||||
.map(source::getValue)
|
||||
.filter(value -> !value.equals(-1))
|
||||
@ -118,7 +118,7 @@ public class AnalysisUtils {
|
||||
* @param uuids
|
||||
* @return
|
||||
*/
|
||||
public static String getAverage(AnalysisType analysisType, PluginData source, List<UUID> uuids) {
|
||||
public static String getAverage(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) {
|
||||
if (analysisType == null) {
|
||||
return source.parseContainer("Err ", "Null Analysistype. ");
|
||||
}
|
||||
@ -156,7 +156,7 @@ public class AnalysisUtils {
|
||||
* @param uuids
|
||||
* @return
|
||||
*/
|
||||
public static String getBooleanPercentage(AnalysisType analysisType, PluginData source, List<UUID> uuids) {
|
||||
public static String getBooleanPercentage(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) {
|
||||
if (analysisType != AnalysisType.BOOLEAN_PERCENTAGE) {
|
||||
return source.parseContainer("Err ", "Wrong Analysistype specified: " + analysisType.name());
|
||||
}
|
||||
@ -178,7 +178,7 @@ public class AnalysisUtils {
|
||||
* @param uuids
|
||||
* @return
|
||||
*/
|
||||
public static String getBooleanTotal(AnalysisType analysisType, PluginData source, List<UUID> uuids) {
|
||||
public static String getBooleanTotal(AnalysisType analysisType, PluginData source, Collection<UUID> uuids) {
|
||||
if (analysisType != AnalysisType.BOOLEAN_TOTAL) {
|
||||
return source.parseContainer("Err ", "Wrong Analysistype specified: " + analysisType.name());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user