From c8126cf7d32d296914ca7755000c74a63085dfa6 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Tue, 8 Aug 2017 22:30:15 +0300 Subject: [PATCH] Implement #222 (and #223) Fix #228 Fix NPE due to plugin variable not being initialized when SubCommand super constructor is called. (Calls addHelp) --- ...itops_abstract_plugin_framework_2_0_2.xml} | 8 +- .../main/java/com/djrapitops/plan/Plan.java | 190 +++++++++--------- .../djrapitops/plan/command/PlanCommand.java | 2 +- .../plan/command/commands/AnalyzeCommand.java | 2 +- .../plan/command/commands/InspectCommand.java | 2 +- .../plan/command/commands/ManageCommand.java | 2 +- .../command/commands/QuickAnalyzeCommand.java | 2 +- .../command/commands/QuickInspectCommand.java | 2 +- .../command/commands/RegisterCommand.java | 2 +- .../plan/command/commands/SearchCommand.java | 2 +- .../plan/command/commands/WebUserCommand.java | 2 +- .../commands/manage/ManageClearCommand.java | 2 +- .../commands/manage/ManageHotswapCommand.java | 2 +- .../commands/manage/ManageImportCommand.java | 2 +- .../commands/manage/ManageRemoveCommand.java | 2 +- .../plan/data/additional/PluginData.java | 9 + .../plan/ui/webserver/WebServer.java | 2 +- .../plan/utilities/analysis/Analysis.java | 19 +- .../plan/utilities/metrics/BStats.java | 2 +- 19 files changed, 144 insertions(+), 112 deletions(-) rename Plan/.idea/libraries/{Maven__com_djrapitops_abstract_plugin_framework_2_0_1.xml => Maven__com_djrapitops_abstract_plugin_framework_2_0_2.xml} (67%) diff --git a/Plan/.idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_1.xml b/Plan/.idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_2.xml similarity index 67% rename from Plan/.idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_1.xml rename to Plan/.idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_2.xml index 826d210d1..d291e16ee 100644 --- a/Plan/.idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_1.xml +++ b/Plan/.idea/libraries/Maven__com_djrapitops_abstract_plugin_framework_2_0_2.xml @@ -1,13 +1,13 @@ - + - + - + - + \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index a721748e4..c4aab76dd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -111,105 +111,111 @@ public class Plan extends BukkitPlugin { */ @Override public void onEnable() { - // Sets the Required variables for BukkitPlugin instance to function correctly - setInstance(this); - super.setDebugMode(Settings.DEBUG.toString()); - super.setColorScheme(new ColorScheme(Phrase.COLOR_MAIN.color(), Phrase.COLOR_SEC.color(), Phrase.COLOR_TER.color())); - super.setLogPrefix("[Plan]"); - super.setUpdateCheckUrl("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml"); - super.setUpdateUrl("https://www.spigotmc.org/resources/plan-player-analytics.32536/"); + try { + // Sets the Required variables for BukkitPlugin instance to function correctly + setInstance(this); + super.setDebugMode(Settings.DEBUG.toString()); + super.setColorScheme(new ColorScheme(Phrase.COLOR_MAIN.color(), Phrase.COLOR_SEC.color(), Phrase.COLOR_TER.color())); + super.setLogPrefix("[Plan]"); + super.setUpdateCheckUrl("https://raw.githubusercontent.com/Rsl1122/Plan-PlayerAnalytics/master/Plan/src/main/resources/plugin.yml"); + super.setUpdateUrl("https://www.spigotmc.org/resources/plan-player-analytics.32536/"); - // Initializes BukkitPlugin variables, Checks version & Logs the debug header - super.onEnableDefaultTasks(); + // Initializes BukkitPlugin variables, Checks version & Logs the debug header + super.onEnableDefaultTasks(); - Benchmark.start("Enable"); + Benchmark.start("Enable"); - initLocale(); - Benchmark.start("Reading server variables"); - serverVariableHolder = new ServerVariableHolder(getServer()); - Benchmark.stop("Enable", "Reading server variables"); + initLocale(); + Benchmark.start("Reading server variables"); + serverVariableHolder = new ServerVariableHolder(getServer()); + Benchmark.stop("Enable", "Reading server variables"); - Benchmark.start("Copy default config"); - getConfig().options().copyDefaults(true); - getConfig().options().header(Phrase.CONFIG_HEADER.toString()); - saveConfig(); - Benchmark.stop("Enable", "Copy default config"); + Benchmark.start("Copy default config"); + getConfig().options().copyDefaults(true); + getConfig().options().header(Phrase.CONFIG_HEADER.toString()); + saveConfig(); + Benchmark.stop("Enable", "Copy default config"); - Benchmark.start("Init Database"); - Log.info(Phrase.DB_INIT.toString()); - if (Check.ErrorIfFalse(initDatabase(), Phrase.DB_FAILURE_DISABLE.toString())) { - Log.info(Phrase.DB_ESTABLISHED.parse(db.getConfigName())); - } else { - disablePlugin(); - return; - } - Benchmark.stop("Enable", "Init Database"); - - Benchmark.start("Init DataCache"); - this.handler = new DataCacheHandler(this); - this.inspectCache = new InspectCacheHandler(this); - this.analysisCache = new AnalysisCacheHandler(this); - Benchmark.stop("Enable", "Init DataCache"); - - super.getRunnableFactory().createNew(new TPSCountTimer(this)).runTaskTimer(1000, TimeAmount.SECOND.ticks()); - registerListeners(); - - this.api = new API(this); - Benchmark.start("Handle Reload"); - handler.handleReload(); - Benchmark.stop("Enable", "Handle Reload"); - - Benchmark.start("Analysis refresh task registration"); - // Analysis refresh settings - boolean bootAnalysisIsEnabled = Settings.ANALYSIS_REFRESH_ON_ENABLE.isTrue(); - int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber(); - boolean analysisRefreshTaskIsEnabled = analysisRefreshMinutes > 0; - - // Analysis refresh tasks - if (bootAnalysisIsEnabled) { - startBootAnalysisTask(); - } - if (analysisRefreshTaskIsEnabled) { - startAnalysisRefreshTask(analysisRefreshMinutes); - } - Benchmark.stop("Enable", "Analysis refresh task registration"); - - Benchmark.start("WebServer Initialization"); - // Data view settings - boolean webserverIsEnabled = Settings.WEBSERVER_ENABLED.isTrue(); - boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); - boolean usingAlternativeUI = Settings.USE_ALTERNATIVE_UI.isTrue(); - boolean hasDataViewCapability = usingAlternativeIP || usingAlternativeUI || webserverIsEnabled; - - if (webserverIsEnabled) { - uiServer = new WebServer(this); - uiServer.initServer(); - - if (!uiServer.isEnabled()) { - Log.error("WebServer was not successfully initialized."); + Benchmark.start("Init Database"); + Log.info(Phrase.DB_INIT.toString()); + if (Check.ErrorIfFalse(initDatabase(), Phrase.DB_FAILURE_DISABLE.toString())) { + Log.info(Phrase.DB_ESTABLISHED.parse(db.getConfigName())); + } else { + disablePlugin(); + return; } + Benchmark.stop("Enable", "Init Database"); - setupFilter(); - } else if (!hasDataViewCapability) { - Log.infoColor(Phrase.ERROR_NO_DATA_VIEW.toString()); + Benchmark.start("Init DataCache"); + this.handler = new DataCacheHandler(this); + this.inspectCache = new InspectCacheHandler(this); + this.analysisCache = new AnalysisCacheHandler(this); + Benchmark.stop("Enable", "Init DataCache"); + + super.getRunnableFactory().createNew(new TPSCountTimer(this)).runTaskTimer(1000, TimeAmount.SECOND.ticks()); + registerListeners(); + + this.api = new API(this); + Benchmark.start("Handle Reload"); + handler.handleReload(); + Benchmark.stop("Enable", "Handle Reload"); + + Benchmark.start("Analysis refresh task registration"); + // Analysis refresh settings + boolean bootAnalysisIsEnabled = Settings.ANALYSIS_REFRESH_ON_ENABLE.isTrue(); + int analysisRefreshMinutes = Settings.ANALYSIS_AUTO_REFRESH.getNumber(); + boolean analysisRefreshTaskIsEnabled = analysisRefreshMinutes > 0; + + // Analysis refresh tasks + if (bootAnalysisIsEnabled) { + startBootAnalysisTask(); + } + if (analysisRefreshTaskIsEnabled) { + startAnalysisRefreshTask(analysisRefreshMinutes); + } + Benchmark.stop("Enable", "Analysis refresh task registration"); + + Benchmark.start("WebServer Initialization"); + // Data view settings + boolean webserverIsEnabled = Settings.WEBSERVER_ENABLED.isTrue(); + boolean usingAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); + boolean usingAlternativeUI = Settings.USE_ALTERNATIVE_UI.isTrue(); + boolean hasDataViewCapability = usingAlternativeIP || usingAlternativeUI || webserverIsEnabled; + + uiServer = new WebServer(this); + if (webserverIsEnabled) { + uiServer.initServer(); + + if (!uiServer.isEnabled()) { + Log.error("WebServer was not successfully initialized."); + } + + setupFilter(); + } else if (!hasDataViewCapability) { + Log.infoColor(Phrase.ERROR_NO_DATA_VIEW.toString()); + } + if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) { + Log.infoColor(Phrase.NOTIFY_EMPTY_IP.toString()); + } + Benchmark.stop("Enable", "WebServer Initialization"); + + registerCommand(new PlanCommand(this)); + + Benchmark.start("Hook to 3rd party plugins"); + hookHandler = new HookHandler(this); + Benchmark.stop("Enable", "Hook to 3rd party plugins"); + + BStats bStats = new BStats(this); + bStats.registerMetrics(); + + Log.debug("Verbose debug messages are enabled."); + Log.logDebug("Enable", Benchmark.stop("Enable", "Enable")); + Log.info(Phrase.ENABLED.toString()); + } catch (Exception e) { + Log.error("Plugin Failed to Initialize Correctly."); + Log.toLog(this.getClass().getName(), e); + disablePlugin(); } - if (!usingAlternativeIP && serverVariableHolder.getIp().isEmpty()) { - Log.infoColor(Phrase.NOTIFY_EMPTY_IP.toString()); - } - Benchmark.stop("Enable", "WebServer Initialization"); - - registerCommand(new PlanCommand(this)); - - Benchmark.start("Hook to 3rd party plugins"); - hookHandler = new HookHandler(this); - Benchmark.stop("Enable", "Hook to 3rd party plugins"); - - BStats bStats = new BStats(this); - bStats.registerMetrics(); - - Log.debug("Verbose debug messages are enabled."); - Log.logDebug("Enable", Benchmark.stop("Enable", "Enable")); - Log.info(Phrase.ENABLED.toString()); } /** @@ -269,7 +275,7 @@ public class Plan extends BukkitPlugin { registerListener(new PlanDeathEventListener(this)); } - Benchmark.stop("Register Listeners"); + Benchmark.stop("Enable", "Register Listeners"); } /** diff --git a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java index 5720937fb..dfd3f9060 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/PlanCommand.java @@ -32,7 +32,7 @@ public class PlanCommand extends TreeCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 2054af449..21b0aeda7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -40,7 +40,7 @@ public class AnalyzeCommand extends SubCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index c3bad335b..911dbf11e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -47,7 +47,7 @@ public class InspectCommand extends SubCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java index 233e8cac9..cda4d46f6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/ManageCommand.java @@ -30,7 +30,7 @@ public class ManageCommand extends TreeCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/QuickAnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/QuickAnalyzeCommand.java index f31a74d1d..94e088a27 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/QuickAnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/QuickAnalyzeCommand.java @@ -42,7 +42,7 @@ public class QuickAnalyzeCommand extends SubCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/QuickInspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/QuickInspectCommand.java index 536ca9a9e..c0aa43761 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/QuickInspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/QuickInspectCommand.java @@ -47,7 +47,7 @@ public class QuickInspectCommand extends SubCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java index 263d0045d..dd11d06d7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/RegisterCommand.java @@ -40,7 +40,7 @@ public class RegisterCommand extends SubCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java index 8348e94de..a5e2c7112 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/SearchCommand.java @@ -38,7 +38,7 @@ public class SearchCommand extends SubCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java index ff7c0dc45..1686cf874 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/WebUserCommand.java @@ -26,7 +26,7 @@ public class WebUserCommand extends TreeCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java index efdd3b807..b28ec326d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageClearCommand.java @@ -38,7 +38,7 @@ public class ManageClearCommand extends SubCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java index 38be12524..a6ba70fa1 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageHotswapCommand.java @@ -38,7 +38,7 @@ public class ManageHotswapCommand extends SubCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java index 6eb6970fb..8549505e9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageImportCommand.java @@ -45,7 +45,7 @@ public class ManageImportCommand extends SubCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String sCol = colorScheme.getSecondaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java index 631595dd2..788af7ea7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/manage/ManageRemoveCommand.java @@ -41,7 +41,7 @@ public class ManageRemoveCommand extends SubCommand { @Override public String[] addHelp() { - ColorScheme colorScheme = plugin.getColorScheme(); + ColorScheme colorScheme = Plan.getInstance().getColorScheme(); String mCol = colorScheme.getMainColor(); String tCol = colorScheme.getTertiaryColor(); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java b/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java index a06c57935..56247d933 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/additional/PluginData.java @@ -203,6 +203,10 @@ public abstract class PluginData { */ public abstract Serializable getValue(UUID uuid); + public Map getValues(Collection uuids) throws UnsupportedOperationException { + throw new UnsupportedOperationException("Not overridden."); + } + /** * Used to set the Font Awesome icon. * @@ -269,6 +273,11 @@ public abstract class PluginData { this.suffix = suffix; } + public final boolean isBanData() { + return placeholder.contains("banned") + && analysisTypes.contains(AnalysisType.BOOLEAN_TOTAL); + } + /** * If a PluginData object has same placeholder, sourcePlugin and * analysisTypes, it is considered equal. diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/WebServer.java b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/WebServer.java index 724bd3bdd..fefe9a7d8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/WebServer.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/WebServer.java @@ -42,7 +42,7 @@ public class WebServer { private HttpServer server; private final int port; - private boolean usingHttps; + private boolean usingHttps = false; /** * Class Constructor. diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 051d36a97..6e8b4cb16 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -24,6 +24,7 @@ import main.java.com.djrapitops.plan.utilities.HtmlUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.comparators.UserDataLastPlayedComparator; +import java.io.Serializable; import java.util.*; import java.util.stream.Collectors; @@ -185,6 +186,7 @@ public class Analysis { final Map replaceMap = new HashMap<>(); final HookHandler hookHandler = plugin.getHookHandler(); final List sources = hookHandler.getAdditionalDataSources().stream() + .filter(p -> !p.isBanData()) .filter(p -> !p.getAnalysisTypes().isEmpty()) .collect(Collectors.toList()); final AnalysisType[] totalTypes = new AnalysisType[]{ @@ -264,6 +266,8 @@ public class Analysis { long now = MiscUtils.getTime(); Benchmark.start("Fill Dataset"); + List banSources = plugin.getHookHandler().getAdditionalDataSources() + .stream().filter(PluginData::isBanData).collect(Collectors.toList()); rawData.forEach(uData -> { uData.access(); Map gmTimes = uData.getGmTimes().getTimes(); @@ -292,7 +296,20 @@ public class Analysis { if (uData.isOp()) { playerCount.addOP(uuid); } - if (uData.isBanned()) { + + boolean banned = uData.isBanned(); + if (!banned) { + banned = banSources.stream() + .anyMatch(banData -> { + Serializable value = banData.getValue(uuid); + if (value instanceof Boolean) { + return (Boolean) value; + } + return false; + }); + } + + if (banned) { activity.addBan(uuid); } else if (uData.getLoginTimes() == 1) { activity.addJoinedOnce(uuid); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java b/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java index c473127f6..9a27d9feb 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/metrics/BStats.java @@ -13,7 +13,7 @@ public class BStats { } public void registerMetrics() { - Log.debug("Enabling bStats Metrics."); + Log.debug("Enable", "Enabling bStats Metrics."); if (bStats == null) { bStats = new Metrics(plugin); }