mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-08 01:17:45 +01:00
Card columns for plugin tabs
- Cleaned up some unneeded PluginData API classes
This commit is contained in:
parent
59309090a9
commit
272906e420
@ -19,7 +19,6 @@ package com.djrapitops.plan.api;
|
||||
import com.djrapitops.plan.api.data.PlayerContainer;
|
||||
import com.djrapitops.plan.api.data.ServerContainer;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.db.access.Query;
|
||||
import com.djrapitops.plan.db.access.queries.containers.ContainerFetchQueries;
|
||||
@ -50,7 +49,6 @@ public class CommonAPI implements PlanAPI {
|
||||
|
||||
private final DBSystem dbSystem;
|
||||
private final UUIDUtility uuidUtility;
|
||||
private final HookHandler hookHandler;
|
||||
private final PluginLogger logger;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@ -58,13 +56,11 @@ public class CommonAPI implements PlanAPI {
|
||||
public CommonAPI(
|
||||
DBSystem dbSystem,
|
||||
UUIDUtility uuidUtility,
|
||||
HookHandler hookHandler,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.dbSystem = dbSystem;
|
||||
this.uuidUtility = uuidUtility;
|
||||
this.hookHandler = hookHandler;
|
||||
this.logger = logger;
|
||||
this.errorHandler = errorHandler;
|
||||
PlanAPIHolder.set(this);
|
||||
@ -72,7 +68,9 @@ public class CommonAPI implements PlanAPI {
|
||||
|
||||
@Override
|
||||
public void addPluginDataSource(PluginData pluginData) {
|
||||
hookHandler.addPluginDataSource(pluginData);
|
||||
logger.warn(pluginData.getClass().getName() + " was attempted to be registered." +
|
||||
" PluginData API has been decommissioned, so this is a no-op." +
|
||||
" Please move to using DataExtension API. https://github.com/plan-player-analytics/Plan/wiki/APIv5");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,136 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.data.plugin;
|
||||
|
||||
import com.djrapitops.plan.data.element.InspectContainer;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.pluginbridge.plan.Bridge;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Class responsible for hooking to other plugins and managing the %plugins%
|
||||
* placeholder on Analysis and Inspect pages.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Singleton
|
||||
public class HookHandler implements SubSystem {
|
||||
|
||||
private final List<PluginData> additionalDataSources;
|
||||
|
||||
private final Bridge bridge;
|
||||
private PluginsConfigSection configHandler;
|
||||
private final PluginLogger logger;
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
@Inject
|
||||
public HookHandler(
|
||||
Bridge bridge,
|
||||
PluginsConfigSection configHandler,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.bridge = bridge;
|
||||
this.configHandler = configHandler;
|
||||
this.logger = logger;
|
||||
this.errorHandler = errorHandler;
|
||||
|
||||
additionalDataSources = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
try {
|
||||
bridge.hook(this);
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
logger.error("Plan Plugin Bridge not included in the plugin jar.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
// Nothing to disable
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new PluginData source to the list.
|
||||
* <p>
|
||||
* The plugin data will appear on Analysis and/or Inspect pages depending on
|
||||
* how the extending object is set up.
|
||||
* <p>
|
||||
* Refer to documentation on GitHub for more information.
|
||||
*
|
||||
* @param dataSource an object extending the PluginData class.
|
||||
*/
|
||||
public void addPluginDataSource(PluginData dataSource) {
|
||||
if (dataSource == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!configHandler.hasSection(dataSource)) {
|
||||
configHandler.createSection(dataSource);
|
||||
}
|
||||
if (configHandler.isEnabled(dataSource)) {
|
||||
additionalDataSources.stream()
|
||||
.filter(pluginData -> pluginData.getSourcePlugin().equals(dataSource.getSourcePlugin()))
|
||||
.findAny()
|
||||
.ifPresent(additionalDataSources::remove);
|
||||
logger.debug("Registered a new datasource: " + dataSource.getSourcePlugin());
|
||||
additionalDataSources.add(dataSource);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
logger.error("Attempting to register PluginDataSource caused an exception.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get all PluginData objects currently registered.
|
||||
*
|
||||
* @return List of PluginData objects.
|
||||
*/
|
||||
public List<PluginData> getAdditionalDataSources() {
|
||||
return additionalDataSources;
|
||||
}
|
||||
|
||||
public Map<PluginData, InspectContainer> getInspectContainersFor(UUID uuid) {
|
||||
List<PluginData> plugins = getAdditionalDataSources();
|
||||
Map<PluginData, InspectContainer> containers = new HashMap<>();
|
||||
for (PluginData pluginData : plugins) {
|
||||
InspectContainer inspectContainer = new InspectContainer();
|
||||
try {
|
||||
InspectContainer container = pluginData.getPlayerData(uuid, inspectContainer);
|
||||
if (container != null && !container.isEmpty()) {
|
||||
containers.put(pluginData, container);
|
||||
}
|
||||
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError e) {
|
||||
String pluginName = pluginData.getSourcePlugin();
|
||||
logger.error("PluginData caused exception: " + pluginName +
|
||||
", you can disable the integration under 'Plugins." + pluginName + ".Enabled'");
|
||||
errorHandler.log(L.WARN, pluginData.getClass(), e);
|
||||
}
|
||||
}
|
||||
return containers;
|
||||
}
|
||||
}
|
@ -39,11 +39,6 @@ public class PluginsConfigSection {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean hasSection(PluginData dataSource) {
|
||||
return hasSection(dataSource.getSourcePlugin());
|
||||
}
|
||||
|
||||
public boolean hasSection(String pluginName) {
|
||||
ConfigNode section = getPluginsSection();
|
||||
return section.getNode(pluginName + ".Enabled").isPresent();
|
||||
@ -54,11 +49,6 @@ public class PluginsConfigSection {
|
||||
.orElse(config.addNode("Plugins"));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void createSection(PluginData dataSource) throws IOException {
|
||||
createSection(dataSource.getSourcePlugin());
|
||||
}
|
||||
|
||||
public void createSection(String pluginName) throws IOException {
|
||||
ConfigNode section = getPluginsSection();
|
||||
|
||||
@ -67,11 +57,6 @@ public class PluginsConfigSection {
|
||||
section.save();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isEnabled(PluginData dataSource) {
|
||||
return isEnabled(dataSource.getSourcePlugin());
|
||||
}
|
||||
|
||||
public boolean isEnabled(String pluginName) {
|
||||
ConfigNode section = getPluginsSection();
|
||||
return section.getBoolean(pluginName + ".Enabled");
|
||||
|
@ -19,7 +19,6 @@ package com.djrapitops.plan.system;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||
import com.djrapitops.plan.utilities.html.structure.Accordions;
|
||||
import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator;
|
||||
import com.djrapitops.plan.utilities.html.tables.HtmlTables;
|
||||
import dagger.Lazy;
|
||||
|
||||
@ -33,21 +32,18 @@ public class HtmlUtilities {
|
||||
private final Lazy<HtmlTables> htmlTables;
|
||||
private final Lazy<Graphs> graphs;
|
||||
private final Lazy<Accordions> accordions;
|
||||
private final Lazy<AnalysisPluginsTabContentCreator> analysisPluginsTabContentCreator;
|
||||
|
||||
@Inject
|
||||
public HtmlUtilities(
|
||||
Lazy<Formatters> formatters,
|
||||
Lazy<HtmlTables> htmlTables,
|
||||
Lazy<Graphs> graphs,
|
||||
Lazy<Accordions> accordions,
|
||||
Lazy<AnalysisPluginsTabContentCreator> analysisPluginsTabContentCreator
|
||||
Lazy<Accordions> accordions
|
||||
) {
|
||||
this.formatters = formatters;
|
||||
this.htmlTables = htmlTables;
|
||||
this.graphs = graphs;
|
||||
this.accordions = accordions;
|
||||
this.analysisPluginsTabContentCreator = analysisPluginsTabContentCreator;
|
||||
}
|
||||
|
||||
public Formatters getFormatters() {
|
||||
@ -66,7 +62,4 @@ public class HtmlUtilities {
|
||||
return accordions.get();
|
||||
}
|
||||
|
||||
public AnalysisPluginsTabContentCreator getAnalysisPluginsTabContentCreator() {
|
||||
return analysisPluginsTabContentCreator.get();
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ package com.djrapitops.plan.system;
|
||||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.capability.CapabilityServiceImplementation;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.db.access.queries.objects.ServerQueries;
|
||||
import com.djrapitops.plan.extension.ExtensionService;
|
||||
import com.djrapitops.plan.extension.ExtensionServiceImplementation;
|
||||
@ -73,7 +72,6 @@ public class PlanSystem implements SubSystem {
|
||||
private final ImportSystem importSystem;
|
||||
private final ExportSystem exportSystem;
|
||||
private final HtmlUtilities htmlUtilities;
|
||||
private final HookHandler hookHandler;
|
||||
private final ExtensionServiceImplementation extensionService;
|
||||
private final QueryServiceImplementation queryService;
|
||||
private final PlanAPI planAPI;
|
||||
@ -95,7 +93,6 @@ public class PlanSystem implements SubSystem {
|
||||
ImportSystem importSystem,
|
||||
ExportSystem exportSystem,
|
||||
HtmlUtilities htmlUtilities,
|
||||
HookHandler hookHandler,
|
||||
ExtensionServiceImplementation extensionService,
|
||||
QueryServiceImplementation queryService,
|
||||
PlanAPI planAPI,
|
||||
@ -115,7 +112,6 @@ public class PlanSystem implements SubSystem {
|
||||
this.importSystem = importSystem;
|
||||
this.exportSystem = exportSystem;
|
||||
this.htmlUtilities = htmlUtilities;
|
||||
this.hookHandler = hookHandler;
|
||||
this.extensionService = extensionService;
|
||||
this.queryService = queryService;
|
||||
this.planAPI = planAPI;
|
||||
@ -149,8 +145,7 @@ public class PlanSystem implements SubSystem {
|
||||
exportSystem,
|
||||
cacheSystem,
|
||||
listenerSystem,
|
||||
taskSystem,
|
||||
hookHandler
|
||||
taskSystem
|
||||
);
|
||||
queryService.register();
|
||||
extensionService.register();
|
||||
@ -168,7 +163,6 @@ public class PlanSystem implements SubSystem {
|
||||
enabled = false;
|
||||
disableSystems(
|
||||
taskSystem,
|
||||
hookHandler,
|
||||
cacheSystem,
|
||||
listenerSystem,
|
||||
importSystem,
|
||||
@ -242,10 +236,6 @@ public class PlanSystem implements SubSystem {
|
||||
return cacheSystem;
|
||||
}
|
||||
|
||||
public HookHandler getHookHandler() {
|
||||
return hookHandler;
|
||||
}
|
||||
|
||||
public PlanAPI getPlanAPI() {
|
||||
return planAPI;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import com.djrapitops.plan.system.webserver.RequestTarget;
|
||||
import com.djrapitops.plan.system.webserver.auth.Authentication;
|
||||
import com.djrapitops.plan.system.webserver.pages.json.ServerTabJSONHandler;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.pages.AnalysisPluginTabs;
|
||||
import com.djrapitops.plan.utilities.html.pages.ServerPluginTabs;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -47,7 +47,7 @@ public class PluginTabJSONParser extends ServerTabJSONHandler<Object> {
|
||||
List<ExtensionServerData> extensionData = dbSystem.getDatabase()
|
||||
.query(new ExtensionServerDataQuery(serverUUID));
|
||||
|
||||
AnalysisPluginTabs pluginTabs = new AnalysisPluginTabs(extensionData, formatters);
|
||||
ServerPluginTabs pluginTabs = new ServerPluginTabs(extensionData, formatters);
|
||||
return new ExtensionTabs(pluginTabs.getNav(), pluginTabs.getTabs());
|
||||
});
|
||||
}
|
||||
|
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.system.webserver.response.pages.parts;
|
||||
|
||||
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.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.webserver.response.pages.PageResponse;
|
||||
import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.HtmlStructure;
|
||||
import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Represents Plugins tabs on Inspect page.
|
||||
* <p>
|
||||
* Extends Response so that it can be stored in ResponseCache.
|
||||
*
|
||||
* @deprecated PluginData API has been deprecated - see https://github.com/plan-player-analytics/Plan/wiki/APIv5---DataExtension-API for new API.
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class InspectPagePluginsContent extends PageResponse {
|
||||
|
||||
// ServerUUID, {nav, html}
|
||||
private final Map<String, String[]> pluginsTab;
|
||||
|
||||
public InspectPagePluginsContent() {
|
||||
pluginsTab = new HashMap<>();
|
||||
}
|
||||
|
||||
public InspectPagePluginsContent(String nav, String html) {
|
||||
pluginsTab = new HashMap<>();
|
||||
addTab(nav, html);
|
||||
}
|
||||
|
||||
public static InspectPagePluginsContent generateForThisServer(UUID playerUUID, ServerInfo serverInfo, HookHandler hookHandler) {
|
||||
String serverName = serverInfo.getServer().getName();
|
||||
String actualServerName = "Plan".equals(serverName) ? "Server " + serverInfo.getServer().getId() : serverName;
|
||||
|
||||
Map<PluginData, InspectContainer> containers = hookHandler.getInspectContainersFor(playerUUID);
|
||||
if (containers.isEmpty()) {
|
||||
return new InspectPagePluginsContent("<li><a>" + actualServerName + " (No Data)</a></li>",
|
||||
"<div class=\"tab\"><div class=\"row clearfix\">" +
|
||||
"<div class=\"col-md-12\">" + Html.CARD.parse("<p>No Data (" + actualServerName + ")</p>") +
|
||||
"</div></div></div>");
|
||||
}
|
||||
|
||||
String nav = "<li><a class=\"nav-button\" href=\"javascript:void(0)\">" + actualServerName + " (Legacy)</a></li>";
|
||||
String tab = createTab(containers);
|
||||
|
||||
return new InspectPagePluginsContent(nav, tab);
|
||||
}
|
||||
|
||||
private static String createTab(Map<PluginData, InspectContainer> containers) {
|
||||
StringBuilder tab = new StringBuilder();
|
||||
tab.append("<div class=\"tab\"><div class=\"row clearfix\">");
|
||||
|
||||
List<PluginData> order = new ArrayList<>(containers.keySet());
|
||||
order.sort(new PluginDataNameComparator());
|
||||
|
||||
for (PluginData pluginData : order) {
|
||||
InspectContainer container = containers.get(pluginData);
|
||||
AnalysisPluginsTabContentCreator.appendThird(pluginData, container, tab);
|
||||
}
|
||||
|
||||
tab.append("</div></div>");
|
||||
return tab.toString();
|
||||
}
|
||||
|
||||
public void addTab(String nav, String html) {
|
||||
pluginsTab.put(nav, new String[]{nav, html});
|
||||
}
|
||||
|
||||
public void addTab(InspectPagePluginsContent content) {
|
||||
pluginsTab.putAll(content.pluginsTab);
|
||||
}
|
||||
|
||||
public String[] getContents() {
|
||||
if (pluginsTab.isEmpty()) {
|
||||
return HtmlStructure.createInspectPageTabContentCalculating();
|
||||
}
|
||||
|
||||
List<String[]> order = new ArrayList<>(pluginsTab.values());
|
||||
// Sort serverNames alphabetically
|
||||
order.sort(Comparator.comparing(name -> name[0]));
|
||||
|
||||
StringBuilder nav = new StringBuilder();
|
||||
StringBuilder tabs = new StringBuilder();
|
||||
for (String[] tab : order) {
|
||||
nav.append(tab[0]);
|
||||
tabs.append(tab[1]);
|
||||
}
|
||||
return new String[]{nav.toString(), tabs.toString()};
|
||||
}
|
||||
}
|
@ -25,7 +25,6 @@ import com.djrapitops.plan.system.info.server.properties.ServerProperties;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.formatting.PlaceholderReplacer;
|
||||
import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -39,7 +38,6 @@ import static com.djrapitops.plan.data.store.keys.NetworkKeys.*;
|
||||
public class NetworkPage implements Page {
|
||||
|
||||
private final NetworkContainer networkContainer;
|
||||
private final AnalysisPluginsTabContentCreator analysisPluginsTabContentCreator;
|
||||
|
||||
private final VersionCheckSystem versionCheckSystem;
|
||||
private final PlanFiles files;
|
||||
@ -48,14 +46,12 @@ public class NetworkPage implements Page {
|
||||
|
||||
NetworkPage(
|
||||
NetworkContainer networkContainer,
|
||||
AnalysisPluginsTabContentCreator analysisPluginsTabContentCreator,
|
||||
VersionCheckSystem versionCheckSystem,
|
||||
PlanFiles files,
|
||||
ServerProperties serverProperties,
|
||||
Formatters formatters
|
||||
) {
|
||||
this.networkContainer = networkContainer;
|
||||
this.analysisPluginsTabContentCreator = analysisPluginsTabContentCreator;
|
||||
this.versionCheckSystem = versionCheckSystem;
|
||||
this.files = files;
|
||||
this.serverProperties = serverProperties;
|
||||
@ -83,11 +79,10 @@ public class NetworkPage implements Page {
|
||||
);
|
||||
placeholderReplacer.put("update", versionCheckSystem.getUpdateHtml().orElse(""));
|
||||
|
||||
AnalysisPluginTabs analysisPluginTabs = new AnalysisPluginTabs(networkContainer.getBungeeContainer().getValue(ServerKeys.EXTENSION_DATA).orElse(new ArrayList<>()), formatters);
|
||||
ServerPluginTabs serverPluginTabs = new ServerPluginTabs(networkContainer.getBungeeContainer().getValue(ServerKeys.EXTENSION_DATA).orElse(new ArrayList<>()), formatters);
|
||||
|
||||
String[] content = analysisPluginsTabContentCreator.createContent(null, networkContainer.getUnsafe(NetworkKeys.PLAYERS_MUTATOR));
|
||||
String nav = analysisPluginTabs.getNav() + content[0];
|
||||
String tabs = analysisPluginTabs.getTabs() + content[1];
|
||||
String nav = serverPluginTabs.getNav();
|
||||
String tabs = serverPluginTabs.getTabs();
|
||||
|
||||
placeholderReplacer.put("navPluginsTabs", nav);
|
||||
placeholderReplacer.put("tabsPlugins", tabs);
|
||||
|
@ -17,7 +17,6 @@
|
||||
package com.djrapitops.plan.utilities.html.pages;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.NotFoundException;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.store.containers.NetworkContainer;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
@ -32,9 +31,7 @@ import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||
import com.djrapitops.plan.system.update.VersionCheckSystem;
|
||||
import com.djrapitops.plan.system.webserver.response.pages.parts.InspectPagePluginsContent;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator;
|
||||
import com.djrapitops.plan.utilities.html.tables.HtmlTables;
|
||||
import com.djrapitops.plugin.benchmarking.Timings;
|
||||
import com.djrapitops.plugin.logging.debug.DebugLogger;
|
||||
@ -61,8 +58,6 @@ public class PageFactory {
|
||||
private final Lazy<ServerInfo> serverInfo;
|
||||
private final Lazy<HtmlTables> tables;
|
||||
private final Lazy<Formatters> formatters;
|
||||
private final Lazy<AnalysisPluginsTabContentCreator> analysisPluginsTabContentCreator;
|
||||
private final Lazy<HookHandler> hookHandler;
|
||||
private final Lazy<DebugLogger> debugLogger;
|
||||
private final Lazy<Timings> timings;
|
||||
private final Lazy<ErrorHandler> errorHandler;
|
||||
@ -77,8 +72,6 @@ public class PageFactory {
|
||||
Lazy<ServerInfo> serverInfo,
|
||||
Lazy<HtmlTables> tables,
|
||||
Lazy<Formatters> formatters,
|
||||
Lazy<AnalysisPluginsTabContentCreator> analysisPluginsTabContentCreator,
|
||||
Lazy<HookHandler> hookHandler,
|
||||
Lazy<DebugLogger> debugLogger,
|
||||
Lazy<Timings> timings,
|
||||
Lazy<ErrorHandler> errorHandler
|
||||
@ -91,8 +84,6 @@ public class PageFactory {
|
||||
this.serverInfo = serverInfo;
|
||||
this.tables = tables;
|
||||
this.formatters = formatters;
|
||||
this.analysisPluginsTabContentCreator = analysisPluginsTabContentCreator;
|
||||
this.hookHandler = hookHandler;
|
||||
this.debugLogger = debugLogger;
|
||||
this.timings = timings;
|
||||
this.errorHandler = errorHandler;
|
||||
@ -167,19 +158,10 @@ public class PageFactory {
|
||||
return new PlayerPluginTab(navs.toString(), tabs.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Marked for removal when the connection system will be removed.
|
||||
*/
|
||||
@Deprecated
|
||||
public InspectPagePluginsContent inspectPagePluginsContent(UUID playerUUID) {
|
||||
return InspectPagePluginsContent.generateForThisServer(playerUUID, serverInfo.get(), hookHandler.get());
|
||||
}
|
||||
|
||||
public NetworkPage networkPage() {
|
||||
NetworkContainer networkContainer = dbSystem.get().getDatabase()
|
||||
.query(ContainerFetchQueries.fetchNetworkContainer()); // Not cached, big.
|
||||
return new NetworkPage(networkContainer,
|
||||
analysisPluginsTabContentCreator.get(),
|
||||
versionCheckSystem.get(), fileSystem.get(), serverInfo.get().getServerProperties(), formatters.get());
|
||||
}
|
||||
}
|
@ -133,7 +133,7 @@ public class PlayerPluginTab implements Comparable<PlayerPluginTab> {
|
||||
"<h1 class=\"h3 mb-0 text-gray-800\"><i class=\"sidebar-toggler fa fa-fw fa-bars\"></i>${playerName} · " + serverName + " Plugins</h1>" +
|
||||
"</div>" +
|
||||
// End Page heading
|
||||
"<div class=\"row clearfix\">" + content + "</div></div></div>";
|
||||
"<div class=\"card-columns\">" + content + "</div></div></div>";
|
||||
}
|
||||
|
||||
private TabsElement.Tab wrapToTabElementTab(ExtensionTabData tabData) {
|
||||
@ -204,17 +204,18 @@ public class PlayerPluginTab implements Comparable<PlayerPluginTab> {
|
||||
builder.append("<p>");
|
||||
}
|
||||
builder.append(Icon.fromExtensionIcon(descriptive.getIcon()))
|
||||
.append(' ').append(descriptive.getText()).append(": ").append(formattedValue).append("</p>");
|
||||
.append(' ').append(descriptive.getText()).append("<span class=\"float-right\"><b>").append(formattedValue).append("</b></span></p>");
|
||||
}
|
||||
|
||||
private String wrapInContainer(ExtensionInformation information, String tabsElement) {
|
||||
String colWidth = hasWideTable ? "col-md-8 col-lg-8" : "col-md-4 col-lg-4";
|
||||
return "<div class=\"col-xs-12 col-sm-12 " + colWidth + "\"><div class=\"card shadow mb-0\">" +
|
||||
// TODO move large tables to their own tabs
|
||||
return "<div class=\"card shadow mb-4\">" +
|
||||
"<div class=\"card-header py-3\">" +
|
||||
"<h6 class=\"m-0 font-weight-bold col-black\">" + Icon.fromExtensionIcon(information.getIcon()) + ' ' + information.getPluginName() + "</h6>" +
|
||||
"</div>" +
|
||||
tabsElement +
|
||||
"</div></div>";
|
||||
"</div>";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +41,7 @@ import java.util.*;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class AnalysisPluginTabs {
|
||||
public class ServerPluginTabs {
|
||||
|
||||
private List<ExtensionServerData> serverData;
|
||||
|
||||
@ -55,12 +55,12 @@ public class AnalysisPluginTabs {
|
||||
|
||||
private boolean hasWideTable;
|
||||
|
||||
public AnalysisPluginTabs(String nav, String tab) {
|
||||
public ServerPluginTabs(String nav, String tab) {
|
||||
this.nav = nav;
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
public AnalysisPluginTabs(
|
||||
public ServerPluginTabs(
|
||||
List<ExtensionServerData> serverData,
|
||||
Formatters formatters
|
||||
) {
|
||||
@ -133,7 +133,7 @@ public class AnalysisPluginTabs {
|
||||
"<h1 class=\"h3 mb-0 text-gray-800\"><i class=\"sidebar-toggler fa fa-fw fa-bars\"></i><span class=\"server-name\"></span> · Plugins Overview</h1>" +
|
||||
"</div>" +
|
||||
// End Page heading
|
||||
"<div class=\"row clearfix\">" + content + "</div></div></div>";
|
||||
"<div class=\"card-columns\">" + content + "</div></div></div>";
|
||||
}
|
||||
|
||||
private TabsElement.Tab wrapToTabElementTab(ExtensionTabData tabData) {
|
||||
@ -209,11 +209,12 @@ public class AnalysisPluginTabs {
|
||||
|
||||
private String wrapInContainer(ExtensionInformation information, String tabsElement) {
|
||||
String colWidth = hasWideTable ? "col-md-8 col-lg-8 col-sm-12" : "col-md-4 col-lg-4 col-sm-12";
|
||||
return "<div class=\"col-xs-12 col-sm-12 " + colWidth + "\"><div class=\"card shadow mb-0\">" +
|
||||
// TODO move large tables to their own tabs
|
||||
return "<div class=\"card shadow mb-4\">" +
|
||||
"<div class=\"card-header py-3\">" +
|
||||
"<h6 class=\"m-0 font-weight-bold col-black\">" + Icon.fromExtensionIcon(information.getIcon()) + ' ' + information.getPluginName() + "</h6>" +
|
||||
"</div>" +
|
||||
tabsElement +
|
||||
"</div></div>";
|
||||
"</div>";
|
||||
}
|
||||
}
|
@ -1,211 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.utilities.html.structure;
|
||||
|
||||
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.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.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.*;
|
||||
|
||||
/**
|
||||
* Creates Plugin section contents for Analysis page.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @deprecated PluginData API has been deprecated - see https://github.com/plan-player-analytics/Plan/wiki/APIv5---DataExtension-API for new API.
|
||||
*/
|
||||
@Singleton
|
||||
@Deprecated
|
||||
public class AnalysisPluginsTabContentCreator {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private static void appendNewTab(PluginData pluginData, AnalysisContainer container, StringBuilder nav, StringBuilder otherTabs) {
|
||||
nav.append("<li><a class=\"nav-button\" href=\"javascript:void(0)\">").append(pluginData.getSourcePlugin()).append(" (Legacy)</a></li>");
|
||||
otherTabs.append("<div class=\"tab\"><div class=\"row clearfix\"><div class=\"col-xs-12 col-sm-12 col-md-12 col-lg-12\">" +
|
||||
"<div class=\"card\">" +
|
||||
"<div class=\"header\">" +
|
||||
"<h2>")
|
||||
.append(pluginData.parsePluginIcon()).append(" ").append(pluginData.getSourcePlugin())
|
||||
.append("</h2></div>")
|
||||
.append(container.parseHtml())
|
||||
.append("</div></div></div></div>");
|
||||
}
|
||||
|
||||
private 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.getAdditionalDataSources();
|
||||
|
||||
sources.parallelStream().forEach(source -> {
|
||||
String pluginName = source.getSourcePlugin();
|
||||
try {
|
||||
timings.start("Source " + pluginName);
|
||||
|
||||
source.setAnalysisData(analysisContainer);
|
||||
AnalysisContainer container = source.getServerData(uuids, new AnalysisContainer());
|
||||
if (container != null && !container.isEmpty()) {
|
||||
containers.put(source, container);
|
||||
}
|
||||
|
||||
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError e) {
|
||||
logger.error("A PluginData-source caused an exception: " + pluginName +
|
||||
", you can disable the integration under 'Plugins." + pluginName + ".Enabled'");
|
||||
errorHandler.log(L.WARN, this.getClass(), e);
|
||||
} finally {
|
||||
timings.end(DebugChannels.ANALYSIS, "Source " + pluginName);
|
||||
source.setAnalysisData(null);
|
||||
}
|
||||
});
|
||||
return containers;
|
||||
}
|
||||
|
||||
public static void appendThird(PluginData pluginData, InspectContainer container, StringBuilder generalTab) {
|
||||
generalTab.append("<div class=\"col-xs-12 col-sm-12 col-md-4 col-lg-4\">" +
|
||||
"<div class=\"card\">" +
|
||||
"<div class=\"header\">" +
|
||||
"<h2>")
|
||||
.append(pluginData.parsePluginIcon()).append(" ").append(pluginData.getSourcePlugin())
|
||||
.append("</h2></div>")
|
||||
.append(container.parseHtml())
|
||||
.append("</div></div>");
|
||||
}
|
||||
|
||||
private static void appendTwoThirds(PluginData pluginData, AnalysisContainer container, StringBuilder generalTab) {
|
||||
generalTab.append("<div class=\"col-xs-12 col-sm-12 col-md-8 col-lg-8\">" +
|
||||
"<div class=\"card\">" +
|
||||
"<div class=\"header\">" +
|
||||
"<h2>")
|
||||
.append(pluginData.parsePluginIcon()).append(" ").append(pluginData.getSourcePlugin())
|
||||
.append("</h2></div>")
|
||||
.append(container.parseHtml())
|
||||
.append("</div></div>");
|
||||
}
|
||||
|
||||
private static void appendWhole(PluginData pluginData, AnalysisContainer container, StringBuilder generalTab) {
|
||||
generalTab.append("<div class=\"col-xs-12 col-sm-12 col-md-12 col-lg-12\">" +
|
||||
"<div class=\"card\">" +
|
||||
"<div class=\"header\">" +
|
||||
"<h2>")
|
||||
.append(pluginData.parsePluginIcon()).append(" ").append(pluginData.getSourcePlugin())
|
||||
.append("</h2></div>").append("<div class=\"body\">")
|
||||
.append(container.parseHtml())
|
||||
.append("</div></div></div>");
|
||||
}
|
||||
|
||||
public String[] createContent(
|
||||
com.djrapitops.plan.data.store.containers.AnalysisContainer analysisContainer,
|
||||
PlayersMutator mutator
|
||||
) {
|
||||
|
||||
if (mutator.all().isEmpty()) {
|
||||
return new String[]{"", ""};
|
||||
}
|
||||
|
||||
List<UUID> uuids = mutator.uuids();
|
||||
Map<PluginData, AnalysisContainer> containers = analyzeAdditionalPluginData(uuids, analysisContainer);
|
||||
|
||||
List<PluginData> order = new ArrayList<>(containers.keySet());
|
||||
order.sort(new PluginDataNameComparator());
|
||||
|
||||
StringBuilder nav = new StringBuilder();
|
||||
StringBuilder generalTab = new StringBuilder();
|
||||
StringBuilder otherTabs = new StringBuilder();
|
||||
|
||||
generalTab.append("<div class=\"tab\"><div class=\"row clearfix\">");
|
||||
|
||||
boolean displayGeneralTab = false;
|
||||
|
||||
for (PluginData pluginData : order) {
|
||||
AnalysisContainer container = containers.get(pluginData);
|
||||
|
||||
switch (pluginData.getSize()) {
|
||||
case TAB:
|
||||
appendNewTab(pluginData, container, nav, otherTabs);
|
||||
break;
|
||||
case WHOLE:
|
||||
if (!container.hasOnlyValues()) {
|
||||
appendWhole(pluginData, container, generalTab);
|
||||
displayGeneralTab = true;
|
||||
}
|
||||
break;
|
||||
case TWO_THIRDS:
|
||||
if (!container.hasOnlyValues()) {
|
||||
appendTwoThirds(pluginData, container, generalTab);
|
||||
displayGeneralTab = true;
|
||||
}
|
||||
break;
|
||||
case THIRD:
|
||||
default:
|
||||
appendThird(pluginData, container, generalTab);
|
||||
displayGeneralTab = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
generalTab.append("</div></div>");
|
||||
|
||||
String playerListTab = "<div class=\"tab\">" +
|
||||
"<div class=\"row clearfix\">" +
|
||||
"<div class=\"col-lg-12 col-md-12 col-sm-12 col-xs-12\">" +
|
||||
"<div class=\"card\">" +
|
||||
"<div class=\"header\"><h2><i class=\"fa fa-users\"></i> Plugin Data</h2></div>" +
|
||||
"<div class=\"body\">" +
|
||||
tables.pluginPlayersTable(containers, mutator.all()).parseHtml() +
|
||||
"</div></div></div>" +
|
||||
"</div></div>";
|
||||
|
||||
return new String[]{
|
||||
(displayGeneralTab ? "<li><a class=\"nav-button\" href=\"javascript:void(0)\">General (Legacy)</a></li>" : "")
|
||||
+ "<li><a class=\"nav-button\" href=\"javascript:void(0)\">Player Data (Legacy)</a></li>" + nav.toString(),
|
||||
(displayGeneralTab ? generalTab.toString() : "") + playerListTab + otherTabs.toString()
|
||||
};
|
||||
}
|
||||
}
|
@ -17,7 +17,6 @@
|
||||
package com.djrapitops.plan.utilities.html.tables;
|
||||
|
||||
import com.djrapitops.plan.api.CommonAPI;
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.store.containers.PlayerContainer;
|
||||
import com.djrapitops.plan.data.store.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
@ -51,7 +50,6 @@ class PlayersTableTest {
|
||||
new CommonAPI(
|
||||
Mockito.mock(DBSystem.class),
|
||||
Mockito.mock(UUIDUtility.class),
|
||||
Mockito.mock(HookHandler.class),
|
||||
new TestPluginLogger(),
|
||||
new ConsoleErrorLogger(new TestPluginLogger())
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user