From 2ea272ee4a39a62dfed0e731fc2d58210062eccf Mon Sep 17 00:00:00 2001 From: Craftinators Date: Thu, 16 Mar 2023 17:39:58 -0400 Subject: [PATCH 01/18] fix(Hook): abstraction and documentation of `Hook` --- .../hibiscusmc/hmccosmetics/hooks/Hook.java | 85 ++++++++++++++----- 1 file changed, 66 insertions(+), 19 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hook.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hook.java index 5757c8b1..b263f0df 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hook.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hook.java @@ -2,45 +2,92 @@ package com.hibiscusmc.hmccosmetics.hooks; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -public class Hook implements Listener { - +/** + * Represents a hook into other minecraft plugins + */ +public abstract class Hook implements Listener { private final String id; - private boolean active; - private boolean itemHook; + private boolean active = false; + private boolean itemHook = false; - public Hook(String id) { + public Hook(@NotNull String id) { this.id = id; - active = false; Hooks.addHook(this); } - public void load() { - // Override - } + /** + * Loads this hook + * + * @implNote By default, this method does nothing. It should be overridden by child classes to implement any necessary loading logic + */ + public void load() { } - public ItemStack getItem(String itemId) { + /** + * Gets an {@link ItemStack} that is associated with the provided id from the hooked plugin + * @param itemId The id of the {@link ItemStack} + * @return The {@link ItemStack} with the id provided. If an invalid id was provided or if the hook doesn't have any related {@link ItemStack}s then this will return null + * @implNote By default, this method returns null. It should be overridden by child classes if you will to have your hook return a related {@link ItemStack} + */ + @Nullable + public ItemStack getItem(@NotNull String itemId) { return null; - // Override } - public String getId() { + /** + * Gets the id of this hook + * + * @return The unique id for this hook + */ + @NotNull + public final String getId() { return id; } - public void setActive(boolean active) { - this.active = active; - } - + /** + * Gets whether this hook has been activated + * @return true if this hook is active, false otherwise + * @deprecated As of release 2.2.5+, replaced by {@link #isActive()} + */ + @Deprecated public boolean getActive() { return this.active; } - public void setEnabledItemHook(boolean enabled) { - itemHook = enabled; + /** + * Gets whether this hook has been activated + * @return true if this hook is active, false otherwise + * @since 2.2.5 + */ + public final boolean isActive() { + return this.active; } - public boolean hasEnabledItemHook() { + /** + * Sets whether this hook is active + * @param active true to activate the hook, false otherwise + */ + public final void setActive(boolean active) { + this.active = active; + } + + /** + * Whether the method {@link #getItem(String)} should return a non-null value + * @return true if {@link #getItem(String)} should return a non-null value, false otherwise + * + * @apiNote Even though this method returns true does not mean that {@link #getItem(String)} won't return null, rather if this returns false then {@link #getItem(String)} should return false everytime + */ + public final boolean hasEnabledItemHook() { return itemHook; } + + /** + * Sets whether the method {@link #getItem(String)} should return a non-null value + * @param enabled true if {@link #getItem(String)} should return a non-null value, false otherwise + */ + public final void setEnabledItemHook(boolean enabled) { + itemHook = enabled; + } } From 7a32697906a1e0f36604c1e3b238d9e898122a92 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Thu, 16 Mar 2023 17:55:53 -0400 Subject: [PATCH 02/18] docs(HookHMCCosmetics): documented class --- .../hmccosmetics/hooks/items/HookHMCCosmetics.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookHMCCosmetics.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookHMCCosmetics.java index 193b12d1..425d7678 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookHMCCosmetics.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookHMCCosmetics.java @@ -3,18 +3,23 @@ package com.hibiscusmc.hmccosmetics.hooks.items; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic; import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics; import com.hibiscusmc.hmccosmetics.hooks.Hook; -import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; -public class HookHMCCosmetics extends Hook implements Listener { - +/** + * A hook that integrates the plugin {@link com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin HMCCosmetics} to provide cosmetic items + */ +public class HookHMCCosmetics extends Hook { public HookHMCCosmetics() { super("HMCCosmetics"); setEnabledItemHook(true); } + /** + * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin HMCCosmetics} + */ @Override - public ItemStack getItem(String itemId) { + public ItemStack getItem(@NotNull String itemId) { Cosmetic cosmetic = Cosmetics.getCosmetic(itemId); if (cosmetic == null) return null; return cosmetic.getItem(); From 5b129cc254132a01488e69ea4fda6aff4b673cb5 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Thu, 16 Mar 2023 18:40:50 -0400 Subject: [PATCH 03/18] docs(HookItemAdder): documented class --- .../hmccosmetics/hooks/items/HookItemAdder.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java index 441d9c2d..c7b1a7ac 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java @@ -7,11 +7,14 @@ import dev.lone.itemsadder.api.CustomStack; import dev.lone.itemsadder.api.Events.ItemsAdderLoadDataEvent; import org.bukkit.Material; import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; -public class HookItemAdder extends Hook implements Listener { - +/** + * A hook that integrates the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} to provide items + */ +@SuppressWarnings("SpellCheckingInspection") +public class HookItemAdder extends Hook { private boolean enabled = false; public HookItemAdder() { @@ -19,8 +22,11 @@ public class HookItemAdder extends Hook implements Listener { setEnabledItemHook(true); } + /** + * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} + */ @Override - public ItemStack getItem(String itemId) { + public ItemStack getItem(@NotNull String itemId) { if (enabled) { CustomStack stack = CustomStack.getInstance(itemId); if (stack == null) return null; @@ -32,7 +38,8 @@ public class HookItemAdder extends Hook implements Listener { @EventHandler public void onItemAdderDataLoad(ItemsAdderLoadDataEvent event) { - if (enabled && !Settings.getItemsAdderReloadChange()) return; // Defaultly it will only run once at startup. If hook setting is enable + // By default, it will only run once at startup, if hook setting is enabled + if (enabled && !Settings.getItemsAdderReloadChange()) return; this.enabled = true; HMCCosmeticsPlugin.setup(); } From 093b01d7ff2d708c0dfed4ab396082b89adff919 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Thu, 16 Mar 2023 18:43:52 -0400 Subject: [PATCH 04/18] docs(HookLooty): documented class --- .../hmccosmetics/hooks/items/HookLooty.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookLooty.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookLooty.java index b330ef54..88d6a6a4 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookLooty.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookLooty.java @@ -3,18 +3,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items; import com.hibiscusmc.hmccosmetics.hooks.Hook; import com.mineinabyss.geary.prefabs.PrefabKey; import com.mineinabyss.looty.LootyFactory; -import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; -public class HookLooty extends Hook implements Listener { - +/** + * A hook that integrates the plugin {@link com.mineinabyss.looty.LootyPlugin Looty} to provide items + */ +@SuppressWarnings("SpellCheckingInspection") +public class HookLooty extends Hook { public HookLooty() { super("looty"); setEnabledItemHook(true); } + /** + * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link com.mineinabyss.looty.LootyPlugin Looty} + */ @Override - public ItemStack getItem(String itemId) { + public ItemStack getItem(@NotNull String itemId) { PrefabKey prefabKey = PrefabKey.Companion.ofOrNull(itemId); if (prefabKey == null) return null; return LootyFactory.INSTANCE.createFromPrefab(prefabKey); From e3408742705977a59c4a562666afed5f22bb43c3 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 08:37:52 -0400 Subject: [PATCH 05/18] docs(HookMythic): documented class --- .../hibiscusmc/hmccosmetics/hooks/items/HookMythic.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java index 7b1972bd..db447042 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java @@ -2,17 +2,18 @@ package com.hibiscusmc.hmccosmetics.hooks.items; import com.hibiscusmc.hmccosmetics.hooks.Hook; import io.lumine.mythic.bukkit.MythicBukkit; -import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; -public class HookMythic extends Hook implements Listener { +@SuppressWarnings("SpellCheckingInspection") +public class HookMythic extends Hook { public HookMythic() { super("mythicmobs"); setEnabledItemHook(true); } @Override - public ItemStack getItem(String itemId) { + public ItemStack getItem(@NotNull String itemId) { return MythicBukkit.inst().getItemManager().getItemStack(itemId); } } From 1d51ee07118abbe175661768c099097418380659 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 08:37:52 -0400 Subject: [PATCH 06/18] docs(HookMythic): documented class --- .../hmccosmetics/hooks/items/HookMythic.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java index 7b1972bd..58679bcf 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java @@ -2,17 +2,25 @@ package com.hibiscusmc.hmccosmetics.hooks.items; import com.hibiscusmc.hmccosmetics.hooks.Hook; import io.lumine.mythic.bukkit.MythicBukkit; -import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; -public class HookMythic extends Hook implements Listener { +/** + * A hook that integrates the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} to provide cosmetic items + */ +@SuppressWarnings("SpellCheckingInspection") +public class HookMythic extends Hook { public HookMythic() { super("mythicmobs"); setEnabledItemHook(true); } + + /** + * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} + */ @Override - public ItemStack getItem(String itemId) { + public ItemStack getItem(@NotNull String itemId) { return MythicBukkit.inst().getItemManager().getItemStack(itemId); } } From d6c4b51b986cbcf3813526267e8ed31dca63595a Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 08:42:05 -0400 Subject: [PATCH 07/18] docs(HookMythic): documented class --- .../java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java | 1 - 1 file changed, 1 deletion(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java index 58679bcf..714029a6 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java @@ -15,7 +15,6 @@ public class HookMythic extends Hook { setEnabledItemHook(true); } - /** * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} */ From a030d1272b65c37ad8cbe2ef3bafc752af27f773 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 08:44:10 -0400 Subject: [PATCH 08/18] docs(HookOraxen): documented class --- .../hmccosmetics/hooks/items/HookOraxen.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java index 3a808e42..50a7c167 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java @@ -3,18 +3,24 @@ package com.hibiscusmc.hmccosmetics.hooks.items; import com.hibiscusmc.hmccosmetics.hooks.Hook; import io.th0rgal.oraxen.api.OraxenItems; import io.th0rgal.oraxen.items.ItemBuilder; -import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.NotNull; -public class HookOraxen extends Hook implements Listener { - +/** + * A hook that integrates the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin} to provide cosmetic items + */ +@SuppressWarnings("SpellCheckingInspection") +public class HookOraxen extends Hook { public HookOraxen() { super("oraxen"); setEnabledItemHook(true); } + /** + * Gets a cosmetic {@link ItemStack} that is associated with the provided id from the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin} + */ @Override - public ItemStack getItem(String itemId) { + public ItemStack getItem(@NotNull String itemId) { ItemBuilder builder = OraxenItems.getItemById(itemId); if (builder == null) return null; return builder.build(); From c3b4abea40013ebd742d990c318a95cc87122491 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 08:53:00 -0400 Subject: [PATCH 09/18] docs(HookCMI): documented class --- .../com/hibiscusmc/hmccosmetics/hooks/misc/HookCMI.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookCMI.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookCMI.java index f2023d65..51ace580 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookCMI.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookCMI.java @@ -7,11 +7,12 @@ import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; -public class HookCMI extends Hook implements Listener { - +/** + * A hook that integrates the plugin {@link com.Zrips.CMI.CMI CMI} + */ +public class HookCMI extends Hook { public HookCMI() { super("CMI"); } From d0dfa19f2def11b4d383eed9adfd54ea16efa940 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 08:53:09 -0400 Subject: [PATCH 10/18] docs(HookHMCColor): documented class --- .../hibiscusmc/hmccosmetics/hooks/misc/HookHMCColor.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookHMCColor.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookHMCColor.java index 10c83ffb..a2eb10a1 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookHMCColor.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookHMCColor.java @@ -1,10 +1,11 @@ package com.hibiscusmc.hmccosmetics.hooks.misc; import com.hibiscusmc.hmccosmetics.hooks.Hook; -import org.bukkit.event.Listener; - -public class HookHMCColor extends Hook implements Listener { +/** + * A hook that integrates the plugin {@link com.hibiscusmc.hmccolor.HMCColor HMCColor} + */ +public class HookHMCColor extends Hook { public HookHMCColor() { super("HMCColor"); } From 6fcf893bacb34db4c598b499921e83225b45e597 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 08:53:37 -0400 Subject: [PATCH 11/18] docs: fixed wording --- .../com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java | 2 +- .../java/com/hibiscusmc/hmccosmetics/hooks/items/HookLooty.java | 2 +- .../com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java | 2 +- .../com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java index c7b1a7ac..01de28eb 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookItemAdder.java @@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; /** - * A hook that integrates the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} to provide items + * A hook that integrates the plugin {@link dev.lone.itemsadder.api.ItemsAdder ItemsAdder} to provide custom items */ @SuppressWarnings("SpellCheckingInspection") public class HookItemAdder extends Hook { diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookLooty.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookLooty.java index 88d6a6a4..74e85b8a 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookLooty.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookLooty.java @@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; /** - * A hook that integrates the plugin {@link com.mineinabyss.looty.LootyPlugin Looty} to provide items + * A hook that integrates the plugin {@link com.mineinabyss.looty.LootyPlugin Looty} to provide custom items */ @SuppressWarnings("SpellCheckingInspection") public class HookLooty extends Hook { diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java index 714029a6..2dbf8a8c 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookMythic.java @@ -6,7 +6,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; /** - * A hook that integrates the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} to provide cosmetic items + * A hook that integrates the plugin {@link io.lumine.mythic.bukkit.MythicBukkit MythicBukkit} to provide custom items */ @SuppressWarnings("SpellCheckingInspection") public class HookMythic extends Hook { diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java index 50a7c167..99b5567e 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/items/HookOraxen.java @@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; /** - * A hook that integrates the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin} to provide cosmetic items + * A hook that integrates the plugin {@link io.th0rgal.oraxen.OraxenPlugin OraxenPlugin} to provide custom items */ @SuppressWarnings("SpellCheckingInspection") public class HookOraxen extends Hook { From 6192515550d9e66d61a3b37e2d1f4a7e05d52ea5 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 08:54:10 -0400 Subject: [PATCH 12/18] docs(HookPremiumVanish): documented class --- .../hmccosmetics/hooks/misc/HookPremiumVanish.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookPremiumVanish.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookPremiumVanish.java index 751b5f66..c824da3e 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookPremiumVanish.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookPremiumVanish.java @@ -7,13 +7,14 @@ import de.myzelyam.api.vanish.PlayerHideEvent; import de.myzelyam.api.vanish.PlayerShowEvent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; -public class HookPremiumVanish extends Hook implements Listener { - - // NOTE: Supervanish and Premium Vanish both use the same api - +/** + * A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish} + * + * @implSpec Supervanish and Premium Vanish both use the same api + */ +public class HookPremiumVanish extends Hook { public HookPremiumVanish() { super("PremiumVanish"); } @@ -33,5 +34,4 @@ public class HookPremiumVanish extends Hook implements Listener { if (user == null) return; user.showCosmetics(); } - } From 2fb28dda327146b82c8e047cd4284653f7a92b19 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 08:54:17 -0400 Subject: [PATCH 13/18] docs(HookSuperVanish): documented class --- .../hmccosmetics/hooks/misc/HookSuperVanish.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookSuperVanish.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookSuperVanish.java index 750e5310..e8ddec68 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookSuperVanish.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/misc/HookSuperVanish.java @@ -7,13 +7,14 @@ import de.myzelyam.api.vanish.PlayerHideEvent; import de.myzelyam.api.vanish.PlayerShowEvent; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; import org.jetbrains.annotations.NotNull; -public class HookSuperVanish extends Hook implements Listener { - - // NOTE: Supervanish and Premium Vanish both use the same api - +/** + * A hook that integrates the plugin {@link de.myzelyam.api.vanish.VanishAPI Supervanish} + * + * @implSpec Supervanish and Premium Vanish both use the same api + */ +public class HookSuperVanish extends Hook { public HookSuperVanish() { super("SuperVanish"); } From 3f8f84735fd5532d78ab9a86178c26b779568919 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 08:58:39 -0400 Subject: [PATCH 14/18] docs(HookPlaceholderAPI): documented class --- .../hooks/placeholders/HookPlaceholderAPI.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HookPlaceholderAPI.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HookPlaceholderAPI.java index 00606171..6c92ae26 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HookPlaceholderAPI.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HookPlaceholderAPI.java @@ -2,14 +2,20 @@ package com.hibiscusmc.hmccosmetics.hooks.placeholders; import com.hibiscusmc.hmccosmetics.hooks.Hook; +/** + * A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPI PlaceholderAPI} + */ public class HookPlaceholderAPI extends Hook { - public HookPlaceholderAPI() { super("PlaceholderAPI"); } + /** + * @throws RuntimeException If PlaceholderAPI fails to register + */ @Override - public void load() { - new HMCPlaceholderExpansion().register(); + public void load() throws RuntimeException { + if (!new HMCPlaceholderExpansion().register()) + throw new RuntimeException("Failed to register PlaceholderExpansion"); } } From c2bf0322a7c09c7d8771ca9b2ee517fa0ecfb3f7 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 09:06:37 -0400 Subject: [PATCH 15/18] docs(WGHook): documented class --- .../hmccosmetics/hooks/worldguard/WGHook.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/worldguard/WGHook.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/worldguard/WGHook.java index dc4541a1..60f4b3ce 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/worldguard/WGHook.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/worldguard/WGHook.java @@ -9,9 +9,18 @@ import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; import java.util.logging.Level; +/** + * A hook that integrates the plugin {@link com.sk89q.worldguard.WorldGuard WorldGuard} + */ public class WGHook { - + /** + * @implNote Please use {@link #getCosmeticEnableFlag()} instead + */ public static StateFlag COSMETIC_ENABLE_FLAG; + + /** + * @implNote Please use {@link #getCosmeticWardrobeFlag()} instead + */ public static StateFlag COSMETIC_WARDROBE_FLAG; public WGHook() { @@ -35,10 +44,18 @@ public class WGHook { } } + /** + * Gets the cosmetic enable {@link StateFlag} + * @return The cosmetic enable {@link StateFlag} + */ public static StateFlag getCosmeticEnableFlag() { return COSMETIC_ENABLE_FLAG; } + /** + * Gets the cosmetic wardrobe {@link StateFlag} + * @return The cosmetic wardrobe {@link StateFlag} + */ public static StateFlag getCosmeticWardrobeFlag() { return COSMETIC_WARDROBE_FLAG; } From 1ed1a2c41dbdcc5f9cf3c7c0abeb437bed8e73c8 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 09:08:11 -0400 Subject: [PATCH 16/18] docs(WGListener): documented class --- .../hibiscusmc/hmccosmetics/hooks/worldguard/WGListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/worldguard/WGListener.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/worldguard/WGListener.java index 6f303266..5d4bdd7e 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/worldguard/WGListener.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/worldguard/WGListener.java @@ -14,8 +14,10 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; import org.jetbrains.annotations.NotNull; +/** + * Contains {@link com.sk89q.worldguard.WorldGuard WorldGuard} related event listeners + */ public class WGListener implements Listener { - @EventHandler public void onPlayerMove(@NotNull PlayerMoveEvent event) { CosmeticUser user = CosmeticUsers.getUser(event.getPlayer()); From 4f8a32c3e8a02807ebe06f8c7ebafbd93a8cdc3a Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 16:01:55 -0400 Subject: [PATCH 17/18] docs(HMCPlaceholderExpansion): documented class --- .../hmccosmetics/cosmetic/Cosmetics.java | 2 + .../placeholders/HMCPlaceholderExpansion.java | 54 +++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetics.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetics.java index 2a743eaf..811f847e 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetics.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/cosmetic/Cosmetics.java @@ -8,6 +8,7 @@ import com.hibiscusmc.hmccosmetics.util.MessagesUtil; import org.apache.commons.lang3.EnumUtils; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.spongepowered.configurate.CommentedConfigurationNode; import org.spongepowered.configurate.ConfigurateException; import org.spongepowered.configurate.ConfigurationNode; @@ -33,6 +34,7 @@ public class Cosmetics { COSMETICS.remove(cosmetic); } + @Nullable public static Cosmetic getCosmetic(String id) { return COSMETICS.get(id); } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HMCPlaceholderExpansion.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HMCPlaceholderExpansion.java index 1aed68ab..cfea8ac7 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HMCPlaceholderExpansion.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/placeholders/HMCPlaceholderExpansion.java @@ -12,12 +12,15 @@ import org.bukkit.OfflinePlayer; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.List; +/** + * A hook that integrates the plugin {@link me.clip.placeholderapi.PlaceholderAPIPlugin PlaceholderAPIPlugin} + */ public class HMCPlaceholderExpansion extends PlaceholderExpansion { - private static boolean papiEnabled = false; public HMCPlaceholderExpansion() { @@ -73,7 +76,7 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion { if (placeholderArgs.size() == 2) return user.getCosmetic(slot).getId(); switch (placeholderArgs.get(2).toLowerCase()) { case "material" -> { - return getMaterial(user.getCosmetic(slot)); + return getMaterialName(user.getCosmetic(slot)); } case "custommodeldata" -> { return getModelData(user.getCosmetic(slot)); @@ -135,33 +138,76 @@ public class HMCPlaceholderExpansion extends PlaceholderExpansion { return null; } + /** + * Gets the name of the cosmetic item {@link org.bukkit.Material Material} + * @param cosmetic The cosmetic to get its {@link org.bukkit.Material Material}s name + * @return The name of the cosmetic item {@link org.bukkit.Material Material} + * @deprecated As of release 2.2.5+, use {@link #getMaterialName(Cosmetic)} instead + */ + @Deprecated + @Nullable public String getMaterial(@NotNull Cosmetic cosmetic) { ItemStack item = cosmetic.getItem(); if (item == null) return null; - return cosmetic.getItem().getType().toString(); + return item.getType().toString(); } + /** + * Gets the name of the cosmetic item {@link org.bukkit.Material Material} + * @param cosmetic The cosmetic to get its {@link org.bukkit.Material Material}s name + * @return The name of the cosmetic item {@link org.bukkit.Material Material} + * @since 2.2.5 + */ + @Nullable + public String getMaterialName(@NotNull Cosmetic cosmetic) { + ItemStack item = cosmetic.getItem(); + if (item == null) return null; + return item.getType().toString(); + } + + /** + * Gets the cosmetic items custom model data + * @param cosmetic The cosmetic to get its custom model data + * @return The cosmetic items custom model data + */ + @Nullable public String getModelData(@NotNull Cosmetic cosmetic) { ItemStack item = cosmetic.getItem(); if (item == null) return null; if (!item.hasItemMeta()) return null; ItemMeta itemMeta = item.getItemMeta(); + if (itemMeta == null) return null; return String.valueOf(itemMeta.getCustomModelData()); } + /** + * Gets the cosmetic items display name + * @param cosmetic The cosmetic to get its items display name + * @return The cosmetic items display name + */ + @Nullable public String getItemName(@NotNull Cosmetic cosmetic) { ItemStack item = cosmetic.getItem(); if (item == null) return null; if (!item.hasItemMeta()) return null; ItemMeta itemMeta = item.getItemMeta(); + if (itemMeta == null) return null; return itemMeta.getDisplayName(); } + /** + * Gets the cosmetic items lore + * @param cosmetic The cosmetic to get its items lore + * @return The cosmetic items lore + */ + @Nullable public String getItemLore(@NotNull Cosmetic cosmetic) { ItemStack item = cosmetic.getItem(); if (item == null) return null; if (item.hasItemMeta()) { - return String.valueOf(item.getItemMeta().getLore()); + ItemMeta itemMeta = item.getItemMeta(); + if (itemMeta == null) return null; + return String.valueOf(itemMeta.getLore()); } return null; } From 4d8d43ee2a3fc3cff61fda14a8eb1ac845c5aad4 Mon Sep 17 00:00:00 2001 From: Craftinators Date: Fri, 17 Mar 2023 16:03:18 -0400 Subject: [PATCH 18/18] docs(Hooks): `getActive` -> `isActive` --- .../main/java/com/hibiscusmc/hmccosmetics/hooks/Hooks.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hooks.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hooks.java index dd4ad00f..7c6ed5e9 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hooks.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/hooks/Hooks.java @@ -67,13 +67,13 @@ public class Hooks { if (!isItemHook(split[0])) return null; Hook hook = getHook(split[0]); if (!hook.hasEnabledItemHook()) return null; - if (!hook.getActive()) return null; + if (!hook.isActive()) return null; return hook.getItem(split[1]); } public static boolean isActiveHook(String id) { Hook hook = getHook(id); if (hook == null) return false; - return hook.getActive(); + return hook.isActive(); } }