mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-21 20:22:45 +02:00
[Debt] AnalysisPluginsTabContentCreator non-static
This commit is contained in:
parent
7a817d3463
commit
e7cbf10ee3
|
@ -52,6 +52,7 @@ public class AnalysisContainer extends DataContainer {
|
|||
private Graphs graphs;
|
||||
private HtmlTables tables;
|
||||
private Accordions accordions;
|
||||
private AnalysisPluginsTabContentCreator pluginsTabContentCreator;
|
||||
|
||||
private Formatter<DateHolder> yearFormatter;
|
||||
private Formatter<Long> secondLongFormatter;
|
||||
|
@ -430,12 +431,7 @@ public class AnalysisContainer extends DataContainer {
|
|||
private void addPluginSuppliers() {
|
||||
// TODO Refactor into a system that supports running the analysis on Bungee
|
||||
Key<String[]> navAndTabs = new Key<>(new Type<String[]>() {}, "NAV_AND_TABS");
|
||||
putSupplier(navAndTabs, () ->
|
||||
AnalysisPluginsTabContentCreator.createContent(
|
||||
getUnsafe(AnalysisKeys.PLAYERS_MUTATOR),
|
||||
this
|
||||
)
|
||||
);
|
||||
putSupplier(navAndTabs, () -> pluginsTabContentCreator.createContent(this));
|
||||
putSupplier(AnalysisKeys.PLUGINS_TAB_NAV, () -> getUnsafe(navAndTabs)[0]);
|
||||
putSupplier(AnalysisKeys.PLUGINS_TAB, () -> getUnsafe(navAndTabs)[1]);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ package com.djrapitops.plan.system;
|
|||
*/
|
||||
public class DebugChannels {
|
||||
|
||||
public static final String ANALYSIS = "Analysis";
|
||||
public static final String INFO_REQUESTS = "InfoRequests";
|
||||
public static final String CONNECTIONS = "Connections";
|
||||
public static final String WEB_REQUESTS = "Web Requests";
|
||||
|
|
|
@ -4,18 +4,22 @@
|
|||
*/
|
||||
package com.djrapitops.plan.utilities.html.structure;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.data.element.AnalysisContainer;
|
||||
import com.djrapitops.plan.data.element.InspectContainer;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.data.store.keys.AnalysisKeys;
|
||||
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
|
||||
import com.djrapitops.plan.system.DebugChannels;
|
||||
import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator;
|
||||
import com.djrapitops.plan.utilities.html.tables.HtmlTables;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.api.Benchmark;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -23,13 +27,35 @@ import java.util.*;
|
|||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
// TODO Turn non static
|
||||
@Singleton
|
||||
public class AnalysisPluginsTabContentCreator {
|
||||
|
||||
public static String[] createContent(
|
||||
PlayersMutator mutator,
|
||||
private final HookHandler hookHandler;
|
||||
private final HtmlTables tables;
|
||||
private final Timings timings;
|
||||
private final PluginLogger logger;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public AnalysisPluginsTabContentCreator(
|
||||
HookHandler hookHandler,
|
||||
HtmlTables tables,
|
||||
Timings timings,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.hookHandler = hookHandler;
|
||||
this.tables = tables;
|
||||
this.timings = timings;
|
||||
this.logger = logger;
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
|
||||
public String[] createContent(
|
||||
com.djrapitops.plan.data.store.containers.AnalysisContainer analysisContainer
|
||||
) {
|
||||
PlayersMutator mutator = analysisContainer.getValue(AnalysisKeys.PLAYERS_MUTATOR).orElse(new PlayersMutator(new ArrayList<>()));
|
||||
|
||||
if (mutator.all().isEmpty()) {
|
||||
return new String[]{"<li><a>No Data</a></li>", ""};
|
||||
}
|
||||
|
@ -77,8 +103,6 @@ public class AnalysisPluginsTabContentCreator {
|
|||
|
||||
generalTab.append("</div></div>");
|
||||
|
||||
HtmlTables tables = null; // TODO Use HtmlTables
|
||||
|
||||
String playerListTab = "<div class=\"tab\">" +
|
||||
"<div class=\"row clearfix\">" +
|
||||
"<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12\">" +
|
||||
|
@ -96,20 +120,17 @@ public class AnalysisPluginsTabContentCreator {
|
|||
};
|
||||
}
|
||||
|
||||
private static Map<PluginData, AnalysisContainer> analyzeAdditionalPluginData(
|
||||
private Map<PluginData, AnalysisContainer> analyzeAdditionalPluginData(
|
||||
Collection<UUID> uuids,
|
||||
com.djrapitops.plan.data.store.containers.AnalysisContainer analysisContainer
|
||||
) {
|
||||
Map<PluginData, AnalysisContainer> containers = new HashMap<>();
|
||||
|
||||
HookHandler hookHandler = null; // TODO
|
||||
List<PluginData> sources = hookHandler.getAdditionalDataSources();
|
||||
|
||||
sources.parallelStream().forEach(source -> {
|
||||
PlanPlugin plugin = PlanPlugin.getInstance();
|
||||
StaticHolder.saveInstance(AnalysisPluginsTabContentCreator.class, plugin.getClass());
|
||||
try {
|
||||
Benchmark.start("Analysis: Source " + source.getSourcePlugin());
|
||||
timings.start("Source " + source.getSourcePlugin());
|
||||
|
||||
source.setAnalysisData(analysisContainer);
|
||||
AnalysisContainer container = source.getServerData(uuids, new AnalysisContainer());
|
||||
|
@ -118,10 +139,10 @@ public class AnalysisPluginsTabContentCreator {
|
|||
}
|
||||
|
||||
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError e) {
|
||||
Log.error("A PluginData-source caused an exception: " + source.getSourcePlugin());
|
||||
Log.toLog(AnalysisPluginsTabContentCreator.class, e);
|
||||
logger.error("A PluginData-source caused an exception: " + source.getSourcePlugin());
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
} finally {
|
||||
Benchmark.stop("Analysis", "Analysis: Source " + source.getSourcePlugin());
|
||||
timings.end(DebugChannels.ANALYSIS, "Source " + source.getSourcePlugin());
|
||||
}
|
||||
});
|
||||
return containers;
|
||||
|
|
Loading…
Reference in New Issue
Block a user