mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 00:15:56 +02:00
suppress or remove most warnings
This commit is contained in:
parent
73134c81c2
commit
f32609bc68
7 changed files with 34 additions and 15 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
@file:Suppress("DEPRECATION", "removal")
|
||||||
package xyz.alexcrea.cuanvil.dependency.datapack
|
package xyz.alexcrea.cuanvil.dependency.datapack
|
||||||
|
|
||||||
import io.papermc.paper.datapack.Datapack
|
import io.papermc.paper.datapack.Datapack
|
||||||
|
|
@ -21,10 +22,10 @@ object DataPackTester {
|
||||||
return Bukkit.getDatapackManager().enabledPacks
|
return Bukkit.getDatapackManager().enabledPacks
|
||||||
.stream().map { obj: Datapack -> obj.name }
|
.stream().map { obj: Datapack -> obj.name }
|
||||||
.toList()
|
.toList()
|
||||||
} catch (e: NoSuchMethodException) {
|
} catch (_: NoSuchMethodException) {
|
||||||
try {
|
try {
|
||||||
DataPack::class.java.getDeclaredMethod("getKey")
|
DataPack::class.java.getDeclaredMethod("getKey")
|
||||||
} catch (e: NoSuchMethodException) {
|
} catch (_: NoSuchMethodException) {
|
||||||
System.err.println("Could not find compatible datapack manager")
|
System.err.println("Could not find compatible datapack manager")
|
||||||
System.err.println("If you are using a datapack that should be compatible with CustomAnvil. It will not get detected...")
|
System.err.println("If you are using a datapack that should be compatible with CustomAnvil. It will not get detected...")
|
||||||
return emptyList()
|
return emptyList()
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ object AnvilTitleUtil {
|
||||||
|
|
||||||
private val runTaskMap = HashMap<UUID, ScheduledTask>()
|
private val runTaskMap = HashMap<UUID, ScheduledTask>()
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
private fun actualRename(view: InventoryView, name: String, player: HumanEntity, anvilDialog: AnvilRenameDialog) {
|
private fun actualRename(view: InventoryView, name: String, player: HumanEntity, anvilDialog: AnvilRenameDialog) {
|
||||||
runTaskMap.remove(player.uniqueId)
|
runTaskMap.remove(player.uniqueId)
|
||||||
if (view.title == name) return
|
if (view.title == name) return
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
|
||||||
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.componentLore
|
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil.componentLore
|
||||||
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT
|
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener.Companion.ANVIL_OUTPUT_SLOT
|
||||||
import xyz.alexcrea.cuanvil.util.MetricsUtil.trackError
|
import xyz.alexcrea.cuanvil.util.MetricsUtil.trackError
|
||||||
import java.lang.reflect.Constructor
|
import java.lang.IllegalStateException
|
||||||
import java.util.logging.Level
|
import java.util.logging.Level
|
||||||
|
|
||||||
object DependencyManager {
|
object DependencyManager {
|
||||||
|
|
@ -342,10 +342,14 @@ object DependencyManager {
|
||||||
|
|
||||||
|
|
||||||
private val prepareAnvilConstructor =
|
private val prepareAnvilConstructor =
|
||||||
PrepareAnvilEvent::class.java.constructors.first() as Constructor<PrepareAnvilEvent>
|
PrepareAnvilEvent::class.java.constructors.first()
|
||||||
|
|
||||||
fun createFakeEvent(view: InventoryView, result: ItemStack?): PrepareAnvilEvent {
|
fun createFakeEvent(view: InventoryView, result: ItemStack?): PrepareAnvilEvent {
|
||||||
return prepareAnvilConstructor.newInstance(view, result)
|
val result = prepareAnvilConstructor.newInstance(view, result)
|
||||||
|
if(result !is PrepareAnvilEvent)
|
||||||
|
throw IllegalStateException("Could not create a PrepareAnvilEvent ?")
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
@file:Suppress("DEPRECATION")
|
||||||
|
|
||||||
package xyz.alexcrea.cuanvil.dependency.economy
|
package xyz.alexcrea.cuanvil.dependency.economy
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy
|
import net.milkbowl.vault.economy.Economy
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import org.bukkit.NamespacedKey
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.plugin.Plugin
|
import org.bukkit.plugin.Plugin
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
class ItemsAdderDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
class ItemsAdderDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
||||||
var isLoaded: Boolean = false
|
var isLoaded: Boolean = false
|
||||||
get() {
|
get() {
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,20 @@ class LegacyEcoEnchantDependency {
|
||||||
|
|
||||||
|
|
||||||
private var ecoEnchantOldEnchantments: MutableSet<EcoEnchant>? = null
|
private var ecoEnchantOldEnchantments: MutableSet<EcoEnchant>? = null
|
||||||
|
private fun unregisterEnchantment(enchant: Any) {
|
||||||
|
EnchantmentApi.unregisterEnchantment((enchant as Enchantment).key)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun registerEnchantment(ecoEnchant: EcoEnchant, enchant: Any) {
|
||||||
|
EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, enchant as Enchantment))
|
||||||
|
}
|
||||||
|
|
||||||
fun registerEnchantments() {
|
fun registerEnchantments() {
|
||||||
val enchantments = EcoEnchants.values()
|
val enchantments = EcoEnchants.values()
|
||||||
for (ecoEnchant in enchantments) {
|
for (ecoEnchant in enchantments) {
|
||||||
ecoEnchant as Enchantment
|
// As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
||||||
|
unregisterEnchantment(ecoEnchant)
|
||||||
EnchantmentApi.unregisterEnchantment(ecoEnchant) // As eco enchants is loaded before custom anvil and register enchantment to registry, we need to unregister old "vanilla" enchant.
|
registerEnchantment(ecoEnchant, ecoEnchant)
|
||||||
EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, ecoEnchant))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ecoEnchantOldEnchantments = HashSet(enchantments)
|
ecoEnchantOldEnchantments = HashSet(enchantments)
|
||||||
|
|
@ -31,13 +38,13 @@ class LegacyEcoEnchantDependency {
|
||||||
// Add new enchantments
|
// Add new enchantments
|
||||||
for (ecoEnchant in newEnchantments)
|
for (ecoEnchant in newEnchantments)
|
||||||
if (!this.ecoEnchantOldEnchantments!!.contains(ecoEnchant))
|
if (!this.ecoEnchantOldEnchantments!!.contains(ecoEnchant))
|
||||||
EnchantmentApi.registerEnchantment(CALegacyEcoEnchant(ecoEnchant, ecoEnchant as Enchantment))
|
registerEnchantment(ecoEnchant, ecoEnchant)
|
||||||
|
|
||||||
|
|
||||||
// Remove old enchantments that not now currently used
|
// Remove old enchantments that not now currently used
|
||||||
this.ecoEnchantOldEnchantments!!.removeAll(newEnchantments)
|
this.ecoEnchantOldEnchantments!!.removeAll(newEnchantments)
|
||||||
for (oldEnchantment in this.ecoEnchantOldEnchantments!!) {
|
for (oldEnchantment in this.ecoEnchantOldEnchantments!!) {
|
||||||
EnchantmentApi.unregisterEnchantment(oldEnchantment as Enchantment)
|
unregisterEnchantment(oldEnchantment)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ecoEnchantOldEnchantments = HashSet(newEnchantments)
|
this.ecoEnchantOldEnchantments = HashSet(newEnchantments)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import lol.hyper.toolstats.tools.ItemChecker
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent
|
import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.plugin.Plugin
|
import org.bukkit.plugin.Plugin
|
||||||
import org.bukkit.plugin.RegisteredListener
|
|
||||||
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
|
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
|
|
||||||
|
|
@ -19,9 +18,13 @@ class ToolStatsDependency(plugin: Plugin) : GenericPluginDependency(plugin) {
|
||||||
getTokenMethod.trySetAccessible()
|
getTokenMethod.trySetAccessible()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ItemChecker.getTokenSafe(item: ItemStack?): Array<String> {
|
private fun ItemChecker.getTokenSafe(item: ItemStack?): Array<*> {
|
||||||
if (item == null) return arrayOf()
|
if (item == null) return arrayOf<Any>()
|
||||||
return getTokenMethod.invoke(this, item) as Array<String>
|
val result = getTokenMethod.invoke(this, item)
|
||||||
|
if(result !is Array<*>)
|
||||||
|
throw IllegalStateException("Could not get token from ToolStats")
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
|
override fun testAnvilResult(event: InventoryClickEvent): Boolean {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue