mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-26 09:11:39 +01:00
Added Hook#getFailureCause() and fixed NPE in HooksManager
This commit is contained in:
parent
8fe4b16805
commit
c236e1a3bc
@ -47,4 +47,10 @@ public abstract class Hook {
|
||||
* @return true if it successfully hooked into the plugin, false otherwise.
|
||||
*/
|
||||
public abstract boolean hook();
|
||||
|
||||
/**
|
||||
* Returns an explanation that will be sent to the user to tell them why the hook process did not succeed.
|
||||
* @return the probable causes why the hook process did not succeed.
|
||||
*/
|
||||
public abstract String getFailureCause();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package world.bentobox.bentobox.managers;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.hooks.Hook;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -16,6 +17,7 @@ public class HooksManager {
|
||||
|
||||
public HooksManager(BentoBox plugin) {
|
||||
this.plugin = plugin;
|
||||
this.hooks = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void registerHook(Hook hook) {
|
||||
@ -24,7 +26,7 @@ public class HooksManager {
|
||||
if (hook.hook()) {
|
||||
hooks.add(hook);
|
||||
} else {
|
||||
plugin.log("Could not hook with " + hook.getPluginName() + ". Skipping...");
|
||||
plugin.log("Could not hook with " + hook.getPluginName() + " because: " + hook.getFailureCause() + ". Skipping...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user