From 57c9286071e5c16da31f24de7316292e27d6a117 Mon Sep 17 00:00:00 2001 From: adabugra <57899270+adabugra@users.noreply.github.com> Date: Sun, 29 Dec 2024 15:14:05 +0300 Subject: [PATCH 1/2] Add Pl3xMap dependency and repo --- build.gradle.kts | 5 +++++ gradle/libs.versions.toml | 2 ++ sayanvanish-bukkit/build.gradle.kts | 1 + 3 files changed, 8 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 4f7f21c..1421c96 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -134,6 +134,11 @@ allprojects { name = "scarsz" url = uri("https://nexus.scarsz.me/content/groups/public/") } + + maven { + name = "modrinth-repo" + url = uri("https://api.modrinth.com/maven/") + } } dependencies { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 91d189b..94eb829 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,6 +13,7 @@ placeholderapi = "2.11.6" essentialsx = "2.20.1" citizens-api = "2.0.28-SNAPSHOT" squaremap-api = "1.2.3" +pl3xmap-api = "1.21.4-512" # proxy # proxy - velocity @@ -37,6 +38,7 @@ placeholderapi = { group = "me.clip", name="placeholderapi", version.ref="placeh essentialsx = { group = "net.essentialsx", name="EssentialsX", version.ref="essentialsx" } citizens-api = { group = "net.citizensnpcs", name="citizensapi", version.ref="citizens-api" } squaremap-api = { group = "xyz.jpenilla", name="squaremap-api", version.ref="squaremap-api" } +pl3xmap-api = { group = "maven.modrinth", name="pl3xmap", version.ref="pl3xmap-api" } # proxy # proxy - velocity diff --git a/sayanvanish-bukkit/build.gradle.kts b/sayanvanish-bukkit/build.gradle.kts index 322a33d..aa40c9b 100644 --- a/sayanvanish-bukkit/build.gradle.kts +++ b/sayanvanish-bukkit/build.gradle.kts @@ -19,6 +19,7 @@ dependencies { compileOnly(libs.essentialsx) compileOnly(libs.citizens.api) compileOnly(libs.squaremap.api) + compileOnly(libs.pl3xmap.api) // compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT") // paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT") From 17fc37239fbf80eb9f10ed82a0d23c6192e97508 Mon Sep 17 00:00:00 2001 From: adabugra <57899270+adabugra@users.noreply.github.com> Date: Sun, 29 Dec 2024 15:15:39 +0300 Subject: [PATCH 2/2] Add Pl3xMap support hook --- .../features/hook/FeatureHookPl3xMap.kt | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sayanvanish-bukkit/src/main/kotlin/org/sayandev/sayanvanish/bukkit/feature/features/hook/FeatureHookPl3xMap.kt diff --git a/sayanvanish-bukkit/src/main/kotlin/org/sayandev/sayanvanish/bukkit/feature/features/hook/FeatureHookPl3xMap.kt b/sayanvanish-bukkit/src/main/kotlin/org/sayandev/sayanvanish/bukkit/feature/features/hook/FeatureHookPl3xMap.kt new file mode 100644 index 0000000..2a80b77 --- /dev/null +++ b/sayanvanish-bukkit/src/main/kotlin/org/sayandev/sayanvanish/bukkit/feature/features/hook/FeatureHookPl3xMap.kt @@ -0,0 +1,44 @@ +package org.sayandev.sayanvanish.bukkit.feature.features.hook + +import net.pl3x.map.core.Pl3xMap +import org.bukkit.event.EventHandler +import org.bukkit.event.Listener +import org.sayandev.sayanvanish.api.feature.RegisteredFeature +import org.sayandev.sayanvanish.bukkit.api.event.BukkitUserUnVanishEvent +import org.sayandev.sayanvanish.bukkit.api.event.BukkitUserVanishEvent +import org.sayandev.sayanvanish.bukkit.feature.HookFeature +import org.sayandev.stickynote.bukkit.registerListener +import org.spongepowered.configurate.objectmapping.ConfigSerializable + +@RegisteredFeature +@ConfigSerializable +class FeatureHookPl3xMap: HookFeature("hook_pl3xmap", "Pl3xMap") { + + override fun enable() { + if (hasPlugin()) { + Pl3xMapHookImpl(this) + } + super.enable() + } +} + +private class Pl3xMapHookImpl(val feature: FeatureHookPl3xMap): Listener { + + init { + registerListener(this) + } + + @EventHandler + private fun onVanish(event: BukkitUserVanishEvent) { + val user = event.user + if (!feature.isActive(user)) return + user.player()?.uniqueId?.let { Pl3xMap.api().playerRegistry.get(it)?.setHidden(true, false) } + } + + @EventHandler + private fun onUnVanish(event: BukkitUserUnVanishEvent) { + val user = event.user + if (!feature.isActive(user)) return + user.player()?.uniqueId?.let { Pl3xMap.api().playerRegistry.get(it)?.setHidden(false, false) } + } +} \ No newline at end of file