Skip to content

Commit e82ac29

Browse files
committed
Fixed null pointer exception when using metrics while the plugin is disabled
1 parent 3e6c671 commit e82ac29

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,13 @@ public void onEnable() {
4949
factory.submit(ConfigEntries.class);
5050
}
5151

52-
this.enable();
53-
54-
//Metrics (https://bstats.org/)
5552
Metrics metrics = new Metrics(this);
56-
metrics.addCustomChart(new SingleLineChart("configured_sections", () -> sectionManager.getSections().size()));
53+
if (this.enable()) {
54+
metrics.addCustomChart(new SingleLineChart("configured_sections", () -> sectionManager.getSections().size()));
55+
}
5756
}
5857

59-
private void enable() {
58+
private boolean enable() {
6059
factory.load(0, true);
6160

6261
mainCommand = new MainCommand(this);
@@ -121,6 +120,7 @@ private void enable() {
121120
}
122121

123122
getLogger().info("The plugin has finished loading without any problems");
123+
return true;
124124
} catch (RuntimeException e) {
125125
this.failed = true;
126126
getLogger().severe("The plugin could not continue loading due to an unexpected exception");
@@ -132,6 +132,7 @@ private void enable() {
132132
getLogger().warning("Nothing is going to work until you do that, you can reload me by using the /balancer command");
133133
getLogger().warning("-----------------------------------------------------");
134134
}
135+
return false;
135136
}
136137

137138
@Override

0 commit comments

Comments
 (0)