Added AnalysisContainer access to PluginData on getServerContainer call

This commit is contained in:
Rsl1122 2018-07-09 08:51:45 +03:00
parent 02f3aa21de
commit 61cb0ecb0a
3 changed files with 19 additions and 4 deletions

View File

@ -28,6 +28,8 @@ public abstract class PluginData {
private String helpText;
protected com.djrapitops.plan.data.store.containers.AnalysisContainer analysisData;
public PluginData(ContainerSize size, String sourcePlugin) {
this.size = size;
this.sourcePlugin = sourcePlugin;
@ -87,4 +89,8 @@ public abstract class PluginData {
public final String getWithIcon(String text, String icon, String color) {
return Html.FA_COLORED_ICON.parse(color, icon) + " " + text;
}
public final void setAnalysisData(com.djrapitops.plan.data.store.containers.AnalysisContainer analysisData) {
this.analysisData = analysisData;
}
}

View File

@ -377,7 +377,9 @@ public class AnalysisContainer extends DataContainer {
// 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))
AnalysisPluginsTabContentCreator.createContent(
getUnsafe(AnalysisKeys.PLAYERS_MUTATOR),
this)
);
putSupplier(AnalysisKeys.PLUGINS_TAB_NAV, () -> getUnsafe(navAndTabs)[0]);
putSupplier(AnalysisKeys.PLUGINS_TAB, () -> getUnsafe(navAndTabs)[1]);

View File

@ -25,13 +25,16 @@ import java.util.*;
*/
public class AnalysisPluginsTabContentCreator {
public static String[] createContent(PlayersMutator mutator) {
public static String[] createContent(
PlayersMutator mutator,
com.djrapitops.plan.data.store.containers.AnalysisContainer analysisContainer
) {
if (mutator.all().isEmpty()) {
return new String[]{"<li><a>No Data</a></li>", ""};
}
List<UUID> uuids = mutator.uuids();
Map<PluginData, AnalysisContainer> containers = analyzeAdditionalPluginData(uuids);
Map<PluginData, AnalysisContainer> containers = analyzeAdditionalPluginData(uuids, analysisContainer);
List<PluginData> order = new ArrayList<>(containers.keySet());
order.sort(new PluginDataNameComparator());
@ -90,7 +93,10 @@ public class AnalysisPluginsTabContentCreator {
};
}
private static Map<PluginData, AnalysisContainer> analyzeAdditionalPluginData(Collection<UUID> uuids) {
private static Map<PluginData, AnalysisContainer> analyzeAdditionalPluginData(
Collection<UUID> uuids,
com.djrapitops.plan.data.store.containers.AnalysisContainer analysisContainer
) {
Map<PluginData, AnalysisContainer> containers = new HashMap<>();
List<PluginData> sources = HookHandler.getInstance().getAdditionalDataSources();
@ -101,6 +107,7 @@ public class AnalysisPluginsTabContentCreator {
try {
Benchmark.start("Analysis", "Analysis: Source " + source.getSourcePlugin());
source.setAnalysisData(analysisContainer);
AnalysisContainer container = source.getServerData(uuids, new AnalysisContainer());
if (container != null && !container.isEmpty()) {
containers.put(source, container);