Made Hook an abstract class rather than an interface

This commit is contained in:
Florian CUNY 2018-10-30 09:24:36 +01:00
parent 493a525775
commit b9a86fd899
2 changed files with 15 additions and 30 deletions

View File

@ -1,26 +0,0 @@
package world.bentobox.bentobox.api.hooks;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
/**
* @author Poslovitch
*/
public abstract class BaseHook implements Hook {
private String pluginName;
public BaseHook(String pluginName) {
this.pluginName = pluginName;
}
@Override
public Plugin getPlugin() {
return Bukkit.getPluginManager().getPlugin(pluginName);
}
@Override
public boolean isPluginAvailable() {
return getPlugin() != null && getPlugin().isEnabled();
}
}

View File

@ -1,27 +1,38 @@
package world.bentobox.bentobox.api.hooks;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
/**
* @author Poslovitch
*/
public interface Hook {
public abstract class Hook {
private String pluginName;
public Hook(String pluginName) {
this.pluginName = pluginName;
}
/**
* Returns the Plugin instance related to this Hook or null if it could not be found.
* @return the Plugin instance of the plugin this Hook hooks into.
*/
Plugin getPlugin();
public Plugin getPlugin() {
return Bukkit.getPluginManager().getPlugin(pluginName);
}
/**
* Returns whether the plugin is available or not.
* @return true if the plugin is available, false otherwise.
*/
boolean isPluginAvailable();
public boolean isPluginAvailable() {
return getPlugin() != null && getPlugin().isEnabled();
}
/**
* Tries to hook into the plugin and returns whether it succeeded or not.
* @return true if it successfully hooked into the plugin, false otherwise.
*/
boolean hook();
public abstract boolean hook();
}