mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-09 20:31:38 +01:00
Fix #228 Fix NPE due to plugin variable not being initialized when SubCommand super constructor is called. (Calls addHelp)
This commit is contained in:
parent
3925a99ead
commit
c8126cf7d3
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.djrapitops:abstract-plugin-framework:2.0.1">
|
||||
<library name="Maven: com.djrapitops:abstract-plugin-framework:2.0.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.1/abstract-plugin-framework-2.0.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.2/abstract-plugin-framework-2.0.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.1/abstract-plugin-framework-2.0.1-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.2/abstract-plugin-framework-2.0.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.1/abstract-plugin-framework-2.0.1-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.2/abstract-plugin-framework-2.0.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -111,6 +111,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
// Sets the Required variables for BukkitPlugin instance to function correctly
|
||||
setInstance(this);
|
||||
super.setDebugMode(Settings.DEBUG.toString());
|
||||
@ -181,8 +182,8 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
boolean usingAlternativeUI = Settings.USE_ALTERNATIVE_UI.isTrue();
|
||||
boolean hasDataViewCapability = usingAlternativeIP || usingAlternativeUI || webserverIsEnabled;
|
||||
|
||||
if (webserverIsEnabled) {
|
||||
uiServer = new WebServer(this);
|
||||
if (webserverIsEnabled) {
|
||||
uiServer.initServer();
|
||||
|
||||
if (!uiServer.isEnabled()) {
|
||||
@ -210,6 +211,11 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -269,7 +275,7 @@ public class Plan extends BukkitPlugin<Plan> {
|
||||
registerListener(new PlanDeathEventListener(this));
|
||||
}
|
||||
|
||||
Benchmark.stop("Register Listeners");
|
||||
Benchmark.stop("Enable", "Register Listeners");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@ public class PlanCommand extends TreeCommand<Plan> {
|
||||
|
||||
@Override
|
||||
public String[] addHelp() {
|
||||
ColorScheme colorScheme = plugin.getColorScheme();
|
||||
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
|
||||
|
||||
String mCol = colorScheme.getMainColor();
|
||||
String sCol = colorScheme.getSecondaryColor();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -30,7 +30,7 @@ public class ManageCommand extends TreeCommand<Plan> {
|
||||
|
||||
@Override
|
||||
public String[] addHelp() {
|
||||
ColorScheme colorScheme = plugin.getColorScheme();
|
||||
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
|
||||
|
||||
String mCol = colorScheme.getMainColor();
|
||||
String sCol = colorScheme.getSecondaryColor();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -26,7 +26,7 @@ public class WebUserCommand extends TreeCommand<Plan> {
|
||||
|
||||
@Override
|
||||
public String[] addHelp() {
|
||||
ColorScheme colorScheme = plugin.getColorScheme();
|
||||
ColorScheme colorScheme = Plan.getInstance().getColorScheme();
|
||||
|
||||
String mCol = colorScheme.getMainColor();
|
||||
String sCol = colorScheme.getSecondaryColor();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -203,6 +203,10 @@ public abstract class PluginData {
|
||||
*/
|
||||
public abstract Serializable getValue(UUID uuid);
|
||||
|
||||
public Map<UUID, Serializable> getValues(Collection<UUID> 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.
|
||||
|
@ -42,7 +42,7 @@ public class WebServer {
|
||||
private HttpServer server;
|
||||
private final int port;
|
||||
|
||||
private boolean usingHttps;
|
||||
private boolean usingHttps = false;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
|
@ -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<String, String> replaceMap = new HashMap<>();
|
||||
final HookHandler hookHandler = plugin.getHookHandler();
|
||||
final List<PluginData> 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<PluginData> banSources = plugin.getHookHandler().getAdditionalDataSources()
|
||||
.stream().filter(PluginData::isBanData).collect(Collectors.toList());
|
||||
rawData.forEach(uData -> {
|
||||
uData.access();
|
||||
Map<String, Long> 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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user