From 612ae93faf0f08468920afa6899a586e3c5a29c6 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Thu, 11 Apr 2019 13:58:11 +0200 Subject: [PATCH] Added icon (Material) to hooks --- .../bentobox/bentobox/api/hooks/Hook.java | 23 +++++++++++++++---- .../bentobox/hooks/MultiverseCoreHook.java | 4 ++-- .../bentobox/hooks/PlaceholderAPIHook.java | 3 ++- .../bentobox/bentobox/hooks/VaultHook.java | 8 +++---- .../bentobox/managers/HooksManager.java | 9 ++++---- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/api/hooks/Hook.java b/src/main/java/world/bentobox/bentobox/api/hooks/Hook.java index 0c2c0adfc..fe72e2049 100644 --- a/src/main/java/world/bentobox/bentobox/api/hooks/Hook.java +++ b/src/main/java/world/bentobox/bentobox/api/hooks/Hook.java @@ -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. diff --git a/src/main/java/world/bentobox/bentobox/hooks/MultiverseCoreHook.java b/src/main/java/world/bentobox/bentobox/hooks/MultiverseCoreHook.java index f25a3315e..d4d239b0f 100644 --- a/src/main/java/world/bentobox/bentobox/hooks/MultiverseCoreHook.java +++ b/src/main/java/world/bentobox/bentobox/hooks/MultiverseCoreHook.java @@ -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) { diff --git a/src/main/java/world/bentobox/bentobox/hooks/PlaceholderAPIHook.java b/src/main/java/world/bentobox/bentobox/hooks/PlaceholderAPIHook.java index 0d97ba5ae..412206250 100644 --- a/src/main/java/world/bentobox/bentobox/hooks/PlaceholderAPIHook.java +++ b/src/main/java/world/bentobox/bentobox/hooks/PlaceholderAPIHook.java @@ -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 addonsExpansions; public PlaceholderAPIHook() { - super("PlaceholderAPI"); + super("PlaceholderAPI", Material.PAPER); this.addonsExpansions = new HashMap<>(); } diff --git a/src/main/java/world/bentobox/bentobox/hooks/VaultHook.java b/src/main/java/world/bentobox/bentobox/hooks/VaultHook.java index e530a8a8a..9f17ffb76 100644 --- a/src/main/java/world/bentobox/bentobox/hooks/VaultHook.java +++ b/src/main/java/world/bentobox/bentobox/hooks/VaultHook.java @@ -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 diff --git a/src/main/java/world/bentobox/bentobox/managers/HooksManager.java b/src/main/java/world/bentobox/bentobox/managers/HooksManager.java index d50f7e608..fa326a06c 100644 --- a/src/main/java/world/bentobox/bentobox/managers/HooksManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/HooksManager.java @@ -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()) {