mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-03 05:51:28 +01:00
[#841] Attempt to prevent NPE related to GriefPrevention
This commit is contained in:
parent
193ed783ff
commit
c3534042dd
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
<artifactId>PlanPluginBridge</artifactId>
|
||||
<version>4.6.0</version>
|
||||
<version>4.6.0-1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.groupId}:${project.artifactId}</name>
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.djrapitops.pluginbridge.plan.griefprevention;
|
||||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.pluginbridge.plan.Hook;
|
||||
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
@ -36,14 +37,23 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
|
||||
@Singleton
|
||||
public class GriefPreventionHook extends Hook {
|
||||
|
||||
private final PluginLogger logger;
|
||||
|
||||
@Inject
|
||||
public GriefPreventionHook() {
|
||||
public GriefPreventionHook(
|
||||
PluginLogger logger
|
||||
) {
|
||||
super("me.ryanhamshire.GriefPrevention.GriefPrevention");
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public void hook(HookHandler handler) throws NoClassDefFoundError {
|
||||
if (enabled) {
|
||||
DataStore dataStore = getPlugin(GriefPrevention.class).dataStore;
|
||||
if (dataStore == null) {
|
||||
logger.warn("GriefPrevention DataStore was not initialized yet. Run '/plan reload' to try to re-hook.");
|
||||
return;
|
||||
}
|
||||
handler.addPluginDataSource(new GriefPreventionData(dataStore));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user