mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-25 18:48:15 +01:00
Implemented basic Hooks API
WIP
This commit is contained in:
parent
5b97d16a2d
commit
5cdfe690f4
@ -0,0 +1,26 @@
|
||||
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();
|
||||
}
|
||||
}
|
27
src/main/java/world/bentobox/bentobox/api/hooks/Hook.java
Normal file
27
src/main/java/world/bentobox/bentobox/api/hooks/Hook.java
Normal file
@ -0,0 +1,27 @@
|
||||
package world.bentobox.bentobox.api.hooks;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* @author Poslovitch
|
||||
*/
|
||||
public interface Hook {
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Returns whether the plugin is available or not.
|
||||
* @return true if the plugin is available, false otherwise.
|
||||
*/
|
||||
boolean isPluginAvailable();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package world.bentobox.bentobox.managers;
|
||||
|
||||
import world.bentobox.bentobox.api.hooks.Hook;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Poslovitch
|
||||
*/
|
||||
public class HooksManager {
|
||||
|
||||
private List<Hook> hooks;
|
||||
|
||||
public List<Hook> getHooks() {
|
||||
return hooks;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user