alexcrea / CustomAnvil

Custom Anvil is a spigot plugin that allows server administrators to customize almost every aspect of the anvil's mechanics.
GNU General Public License v3.0
4 stars 0 forks source link

Using custom recipe in Creative causes exception and deletes result item #21

Closed galennare closed 3 months ago

galennare commented 3 months ago

Create a custom recipe with a level cost in the config GUI. Then use it while in creative mode with no EXP stored. It results in this exception and deletes all items involved in the craft:

Using Paper Spigot 1.21

[17:05:50 ERROR]: Could not pass event InventoryClickEvent to CustomAnvil v1.5.4-fix
java.lang.IllegalArgumentException: Experience level must not be negative (-1)
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:191) ~[guava-32.1.2-jre.jar:?]
    at org.bukkit.craftbukkit.entity.CraftPlayer.setLevel(CraftPlayer.java:1919) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at CustomAnvil-1.5.4-fix-all.jar/io.delilaheve.AnvilEventListener.onCustomCraft(AnvilEventListener.kt:364) ~[CustomAnvil-1.5.4-fix-all.jar:?]
    at CustomAnvil-1.5.4-fix-all.jar/io.delilaheve.AnvilEventListener.anvilExtractionCheck(AnvilEventListener.kt:296) ~[CustomAnvil-1.5.4-fix-all.jar:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor5.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-api-1.21-R0.1-SNAPSHOT.jar:?]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:81) ~[paper-api-1.21-R0.1-SNAPSHOT.jar:1.21-66-99ae7bb]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.21-R0.1-SNAPSHOT.jar:?]
    at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:131) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628) ~[paper-api-1.21-R0.1-SNAPSHOT.jar:?]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:3122) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:69) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:33) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:56) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:151) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1542) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:201) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:125) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1519) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1512) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:135) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:1471) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1478) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1323) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:330) ~[paper-1.21.jar:1.21-66-99ae7bb]
    at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
galennare commented 3 months ago

This is resolved by adding experience to the player with a command, however this is likely not intended behavior.

alexcrea commented 3 months ago

Found the issue: Experience was removed even if player was in creative (unlike how vanilla work) while the craft were being allowed. Will be fixed next version. It will be released soon.

Thanks for the reporting ! It also allowed me to find another (related) issue.

I also like to update custom anvil craft to add more config and possibilities (no eta). If you have suggestion, please post them on the discord or a new GitHub issue.

alexcrea commented 3 months ago

Now fixed on 1.5.5