fix AxPlayersWarps incompatibility (#82)

This commit is contained in:
alexcrea 2025-07-25 05:42:16 +02:00 committed by GitHub
commit e4176404ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 37 additions and 2 deletions

View file

@ -26,7 +26,6 @@ val effectiveVersion = "$version" +
repositories {
// EcoEnchants
maven(url = "https://repo.auxilor.io/repository/maven-public/")
}
dependencies {
@ -61,6 +60,9 @@ dependencies {
// ToolStats
compileOnly(files("libs/toolstats-1.9.6-stripped.jar"))
// AxPlayerWarps
compileOnly(files("libs/AxPlayerWarps-1.10.3.jar"))
// Include nms
implementation(project(":nms:nms-common"))
implementation(project(":nms:v1_17R1", configuration = "reobf"))

Binary file not shown.

View file

@ -1,9 +1,11 @@
package xyz.alexcrea.cuanvil.dependency
import com.willfp.eco.core.gui.player
import io.delilaheve.CustomAnvil
import org.bukkit.Bukkit
import org.bukkit.ChatColor
import org.bukkit.entity.HumanEntity
import org.bukkit.entity.Player
import org.bukkit.event.inventory.InventoryClickEvent
import org.bukkit.event.inventory.PrepareAnvilEvent
import org.bukkit.inventory.AnvilInventory
@ -40,6 +42,8 @@ object DependencyManager {
var disenchantmentCompatibility: DisenchantmentDependency? = null
var havenBagsCompatibility: HavenBagsDependency? = null
var axPlayerWarpsCompatibility: AxPlayerWarpsDependency? = null
val genericDependencies = ArrayList<GenericPluginDependency>()
fun loadDependency() {
@ -88,6 +92,11 @@ object DependencyManager {
havenBagsCompatibility!!.redirectListeners()
}
// AxPlayerWarps dependency
if (pluginManager.isPluginEnabled("AxPlayerWarps")) {
axPlayerWarpsCompatibility = AxPlayerWarpsDependency()
}
// "Generic" dependencies
if (pluginManager.isPluginEnabled("ToolStats"))
genericDependencies.add(ToolStatsDependency(pluginManager.getPlugin("ToolStats")!!))
@ -153,6 +162,9 @@ object DependencyManager {
// Test if the inventory is a gui(version specific)
if (!bypass && (externGuiTester?.testIfGui(event.view) == true)) bypass = true
// Test if in an ax player warp rating gui
if (!bypass && (axPlayerWarpsCompatibility?.testIfGui(player) == true)) bypass = true
return bypass
}
@ -203,7 +215,12 @@ object DependencyManager {
}
// Return null if there was an issue
fun tryTreatAnvilResult(event: PrepareAnvilEvent, result: ItemStack, useType: AnvilUseType, cost: Int): CATreatAnvilResultEvent? {
fun tryTreatAnvilResult(
event: PrepareAnvilEvent,
result: ItemStack,
useType: AnvilUseType,
cost: Int
): CATreatAnvilResultEvent? {
val treatEvent = CATreatAnvilResultEvent(event, useType, result, cost)
try {
unsafeTryTreatAnvilResult(treatEvent)
@ -279,6 +296,9 @@ object DependencyManager {
// Test if the inventory is a gui(version specific)
if (!bypass && (externGuiTester?.testIfGui(event.view) == true)) bypass = true
// Test if in an ax player warp rating gui
if (!bypass && (axPlayerWarpsCompatibility?.testIfGui(event.player) == true)) bypass = true
return bypass
}

View file

@ -0,0 +1,13 @@
package xyz.alexcrea.cuanvil.dependency.plugins
import com.artillexstudios.axplayerwarps.libs.axapi.gui.AnvilInput
import org.bukkit.entity.HumanEntity
import org.bukkit.entity.Player
class AxPlayerWarpsDependency {
fun testIfGui(player: HumanEntity): Boolean {
return player is Player && AnvilInput.get(player) != null
}
}