From 2c4894c35c203839e829d80f14067c18a279a035 Mon Sep 17 00:00:00 2001 From: lojosho Date: Tue, 29 Apr 2025 22:43:40 -0500 Subject: [PATCH] squash! feat: use vanished metadata rather than apis for each plugin --- build.gradle.kts | 1 + .../lojosho/hibiscuscommons/hooks/Hooks.java | 2 + .../hooks/misc/HookPremiumVanish.java | 37 +++++++++++++++++++ .../hooks/misc/HookSuperVanish.java | 35 ++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 common/src/main/java/me/lojosho/hibiscuscommons/hooks/misc/HookPremiumVanish.java create mode 100644 common/src/main/java/me/lojosho/hibiscuscommons/hooks/misc/HookSuperVanish.java diff --git a/build.gradle.kts b/build.gradle.kts index bbf7189..d7ebda5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -89,6 +89,7 @@ allprojects { compileOnly("it.unimi.dsi:fastutil:8.5.15") compileOnly("com.denizenscript:denizen:1.2.7-SNAPSHOT") compileOnly("io.lumine:Mythic-Dist:5.8.0") + compileOnly("com.github.LeonMangler:SuperVanish:6.2.17") compileOnly("net.Indyuce:MMOItems-API:6.9.4-SNAPSHOT") compileOnly("com.willfp:eco:6.74.5") compileOnly("me.clip:placeholderapi:2.11.6") diff --git a/common/src/main/java/me/lojosho/hibiscuscommons/hooks/Hooks.java b/common/src/main/java/me/lojosho/hibiscuscommons/hooks/Hooks.java index 15492d6..56ffc1b 100644 --- a/common/src/main/java/me/lojosho/hibiscuscommons/hooks/Hooks.java +++ b/common/src/main/java/me/lojosho/hibiscuscommons/hooks/Hooks.java @@ -40,6 +40,8 @@ public class Hooks { private static final HookCustomFishing CF_HOOK = new HookCustomFishing(); private static final HookGSit GSIT_HOOK = new HookGSit(); private static final HookCraftEngine CRAFT_ENGINE_HOOK = new HookCraftEngine(); + private static final HookPremiumVanish PREMIUM_VANISH_HOOK = new HookPremiumVanish(); + private static final HookSuperVanish SUPER_VANISH_HOOK = new HookSuperVanish(); private static boolean allHooksActive = false; diff --git a/common/src/main/java/me/lojosho/hibiscuscommons/hooks/misc/HookPremiumVanish.java b/common/src/main/java/me/lojosho/hibiscuscommons/hooks/misc/HookPremiumVanish.java new file mode 100644 index 0000000..b48f28b --- /dev/null +++ b/common/src/main/java/me/lojosho/hibiscuscommons/hooks/misc/HookPremiumVanish.java @@ -0,0 +1,37 @@ +package me.lojosho.hibiscuscommons.hooks.misc; + +import de.myzelyam.api.vanish.PlayerHideEvent; +import de.myzelyam.api.vanish.PlayerShowEvent; +import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent; +import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent; +import me.lojosho.hibiscuscommons.hooks.Hook; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +/** + * 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"); + setActive(true); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerVanish(@NotNull PlayerHideEvent event) { + HibiscusPlayerVanishEvent newEvent = new HibiscusPlayerVanishEvent(this, event.getPlayer()); + Bukkit.getPluginManager().callEvent(newEvent); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerShow(@NotNull PlayerShowEvent event) { + HibiscusPlayerUnVanishEvent newEvent = new HibiscusPlayerUnVanishEvent(this, event.getPlayer()); + Bukkit.getPluginManager().callEvent(newEvent); + } +} diff --git a/common/src/main/java/me/lojosho/hibiscuscommons/hooks/misc/HookSuperVanish.java b/common/src/main/java/me/lojosho/hibiscuscommons/hooks/misc/HookSuperVanish.java new file mode 100644 index 0000000..3b1dcaf --- /dev/null +++ b/common/src/main/java/me/lojosho/hibiscuscommons/hooks/misc/HookSuperVanish.java @@ -0,0 +1,35 @@ +package me.lojosho.hibiscuscommons.hooks.misc; + +import de.myzelyam.api.vanish.PlayerHideEvent; +import de.myzelyam.api.vanish.PlayerShowEvent; +import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerUnVanishEvent; +import me.lojosho.hibiscuscommons.api.events.HibiscusPlayerVanishEvent; +import me.lojosho.hibiscuscommons.hooks.Hook; +import org.bukkit.Bukkit; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.jetbrains.annotations.NotNull; + +/** + * 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"); + setActive(true); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerVanish(@NotNull PlayerHideEvent event) { + HibiscusPlayerVanishEvent newEvent = new HibiscusPlayerVanishEvent(this, event.getPlayer()); + Bukkit.getPluginManager().callEvent(newEvent); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onPlayerShow(@NotNull PlayerShowEvent event) { + HibiscusPlayerUnVanishEvent newEvent = new HibiscusPlayerUnVanishEvent(this, event.getPlayer()); + Bukkit.getPluginManager().callEvent(newEvent); + } +}