Added icon (Material) to hooks

This commit is contained in:
Florian CUNY 2019-04-11 13:58:11 +02:00
parent 7ff3289afa
commit 612ae93faf
5 changed files with 31 additions and 16 deletions

View File

@ -1,7 +1,9 @@
package world.bentobox.bentobox.api.hooks;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.plugin.Plugin;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
/**
@ -9,24 +11,35 @@ import org.eclipse.jdt.annotation.Nullable;
*/
public abstract class Hook {
private String pluginName;
private @NonNull String pluginName;
private @NonNull Material icon;
public Hook(String pluginName) {
if (pluginName == null || pluginName.isEmpty()) {
throw new IllegalArgumentException("Plugin name cannot be null nor empty.");
public Hook(@NonNull String pluginName, @NonNull Material icon) {
if (pluginName.isEmpty()) {
throw new IllegalArgumentException("Plugin name cannot be empty.");
}
this.pluginName = pluginName;
this.icon = icon;
}
/**
* Returns the name of the plugin related to this Hook.
* Cannot be null.
* @return the plugin name.
*/
@NonNull
public String getPluginName() {
return pluginName;
}
/**
* Returns the icon representing this Hook.
* @return the icon.
*/
@NonNull
public Material getIcon() {
return icon;
}
/**
* 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.

View File

@ -1,8 +1,8 @@
package world.bentobox.bentobox.hooks;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.hooks.Hook;
@ -17,7 +17,7 @@ public class MultiverseCoreHook extends Hook {
private static final String MULTIVERSE_IMPORT = "mv import ";
public MultiverseCoreHook() {
super("Multiverse-Core");
super("Multiverse-Core", Material.COMPASS);
}
public void registerWorld(World world) {

View File

@ -1,5 +1,6 @@
package world.bentobox.bentobox.hooks;
import org.bukkit.Material;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.Addon;
@ -22,7 +23,7 @@ public class PlaceholderAPIHook extends Hook {
private Map<Addon, AddonPlaceholderExpansion> addonsExpansions;
public PlaceholderAPIHook() {
super("PlaceholderAPI");
super("PlaceholderAPI", Material.PAPER);
this.addonsExpansions = new HashMap<>();
}

View File

@ -1,10 +1,10 @@
package world.bentobox.bentobox.hooks;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.plugin.RegisteredServiceProvider;
import world.bentobox.bentobox.api.hooks.Hook;
import world.bentobox.bentobox.api.user.User;
@ -17,7 +17,7 @@ public class VaultHook extends Hook {
private Economy economy;
public VaultHook() {
super("Vault");
super("Vault", Material.GOLD_NUGGET);
}
@Override

View File

@ -1,12 +1,13 @@
package world.bentobox.bentobox.managers;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.hooks.Hook;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.hooks.Hook;
/**
* @author Poslovitch
*/
@ -20,7 +21,7 @@ public class HooksManager {
this.hooks = new ArrayList<>();
}
public void registerHook(Hook hook) {
public void registerHook(@NonNull Hook hook) {
if (hook.isPluginAvailable()) {
plugin.log("Hooking with " + hook.getPluginName() + "...");
if (hook.hook()) {