mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
fix AxPlayersWarps incompatibility
This commit is contained in:
parent
78ce6a8f42
commit
f4aaeddb25
4 changed files with 37 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue