mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-01 07:03:26 +01:00
Made Hook an abstract class rather than an interface
This commit is contained in:
parent
493a525775
commit
b9a86fd899
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +1,38 @@
|
|||||||
package world.bentobox.bentobox.api.hooks;
|
package world.bentobox.bentobox.api.hooks;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Poslovitch
|
* @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.
|
* 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.
|
* @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.
|
* Returns whether the plugin is available or not.
|
||||||
* @return true if the plugin is available, false otherwise.
|
* @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.
|
* Tries to hook into the plugin and returns whether it succeeded or not.
|
||||||
* @return true if it successfully hooked into the plugin, false otherwise.
|
* @return true if it successfully hooked into the plugin, false otherwise.
|
||||||
*/
|
*/
|
||||||
boolean hook();
|
public abstract boolean hook();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user