disable load for v1 after 1.21

This commit is contained in:
alexcrea 2026-07-10 23:21:31 +02:00
parent 862f9914fa
commit fe63f489c9
Signed by: alexcrea
GPG key ID: E59DF23EE2A2266C
26 changed files with 12 additions and 500 deletions

View file

@ -11,7 +11,6 @@ import xyz.alexcrea.cuanvil.command.EditConfigExecutor
import xyz.alexcrea.cuanvil.command.ReloadExecutor
import xyz.alexcrea.cuanvil.config.ConfigHolder
import xyz.alexcrea.cuanvil.dependency.DependencyManager
import xyz.alexcrea.cuanvil.dependency.MinecraftVersionUtil
import xyz.alexcrea.cuanvil.dependency.economy.EconomyManager
import xyz.alexcrea.cuanvil.dependency.util.PlatformUtil
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry
@ -25,6 +24,7 @@ import xyz.alexcrea.cuanvil.update.ModrinthUpdateChecker
import xyz.alexcrea.cuanvil.update.PluginSetDefault
import xyz.alexcrea.cuanvil.update.UpdateHandler
import xyz.alexcrea.cuanvil.update.UpdateUtils
import xyz.alexcrea.cuanvil.update.Version
import xyz.alexcrea.cuanvil.util.MetricsUtil
import java.io.File
import java.io.FileReader
@ -203,6 +203,13 @@ open class CustomAnvil : JavaPlugin() {
}
private fun legacyCheck() {
val currentVersion = UpdateUtils.currentMinecraftVersion()
if (currentVersion.greaterEqual(Version(1, 21, 0))) {
logger.warning("You are running a Minecraft version above or equal to 1.21.0")
logger.warning("Please use CustomAnvil v2 instead if you wish to use the plugin with this version.")
Bukkit.getPluginManager().disablePlugin(this)
return
}
// Disable old plugin name if exist
val potentialPlugin = Bukkit.getPluginManager().getPlugin("UnsafeEnchantsPlus")
if (potentialPlugin != null) {
@ -215,10 +222,6 @@ open class CustomAnvil : JavaPlugin() {
if(!isPaper) {
logger.warning("It seems you are using spigot")
logger.warning("Please take notice that spigot is less supported than paper and derivatives")
if(MinecraftVersionUtil.isTooNewForSpigot) {
logger.warning("If replace too expensive is not working this is likely because of spigot")
logger.warning("As native nms is not supported for spigot starting 26.1")
}
}
val loader = if(isPaper) "paper" else "spigot"

View file

@ -6,7 +6,6 @@ import org.bukkit.inventory.ItemStack
import org.bukkit.inventory.meta.Damageable
import xyz.alexcrea.cuanvil.update.UpdateUtils
import xyz.alexcrea.cuanvil.util.MaterialUtil.customType
import xyz.alexcrea.cuanvil.util.MaxDamageCheckerUtil
import kotlin.math.ceil
import kotlin.math.max
import kotlin.math.min
@ -21,13 +20,6 @@ object ItemUtil {
*/
fun ItemStack.isEnchantedBook() = type == ENCHANTED_BOOK
private fun maxDamage(type: Material, damageable: Damageable): Int {
val ver = UpdateUtils.currentMinecraftVersion()
if(ver.major <= 1 && ver.minor <= 20 && ver.patch < 5) return type.maxDurability.toInt()
return MaxDamageCheckerUtil.getMaxDamage(type, damageable)
}
/**
* Set this [ItemStack]s durability from a combination of the
* [first] and [second] item's durability values
@ -40,7 +32,7 @@ object ItemUtil {
val meta = itemMeta
if(meta !is Damageable) return false
val maxDamage = maxDamage(type, meta)
val maxDamage = type.maxDurability.toInt()
val damage = (first.itemMeta as? Damageable)?.damage ?: 0
if (damage == 0) return false

View file

@ -51,8 +51,4 @@ object MinecraftVersionUtil {
}
}
val isTooNewForSpigot: Boolean get() {
return UpdateUtils.currentMinecraftVersion().major != 1
}
}