mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-25 00:51:20 +01:00
Fixed very specific anvil edge case
This commit is contained in:
parent
27b351858f
commit
cbdaf0bccd
@ -17,7 +17,6 @@ import org.bukkit.event.inventory.PrepareAnvilEvent
|
|||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.meta.Damageable
|
import org.bukkit.inventory.meta.Damageable
|
||||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta
|
||||||
import org.jetbrains.annotations.NotNull
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
@ -90,15 +89,24 @@ class AnvilSupport(
|
|||||||
|
|
||||||
val oldLeft = event.inventory.getItem(0)
|
val oldLeft = event.inventory.getItem(0)
|
||||||
|
|
||||||
|
if (result == FAIL) {
|
||||||
|
return@run
|
||||||
|
}
|
||||||
|
|
||||||
if (oldLeft == null || oldLeft.type != outItem.type) {
|
if (oldLeft == null || oldLeft.type != outItem.type) {
|
||||||
return@run
|
return@run
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == FAIL || left == old) {
|
if (left == old) {
|
||||||
return@run
|
return@run
|
||||||
}
|
}
|
||||||
|
|
||||||
val cost = oldCost + price
|
var cost = oldCost + price
|
||||||
|
|
||||||
|
// Unbelievably specific edge case
|
||||||
|
if (oldCost == -price) {
|
||||||
|
cost = price
|
||||||
|
}
|
||||||
|
|
||||||
// Cost could be less than zero at times, so I include that here.
|
// Cost could be less than zero at times, so I include that here.
|
||||||
if (cost <= 0) {
|
if (cost <= 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user