Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7865

PrepareAnvilEvent::getAnvilView() results in NoSuchMethodError on server

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Major Major
    • None
    • None
    • 1.21-R0.1-SNAPSHOT
    • EnchantCopy v1.0-SNAPSHOT
    • Yes

      Spigot 1.21 does not have CraftInventoryAnvil implement the API class AnvilView, which results in a NoSuchMethod error when attempting to access it from the API:

      [14:16:43] [Server thread/ERROR]: Could not pass event PrepareAnvilEvent to EnchantCopy v1.0-SNAPSHOT
      java.lang.NoSuchMethodError: 'org.bukkit.inventory.view.AnvilView org.bukkit.event.inventory.PrepareAnvilEvent.getView()'
          at enchantcopy-1.0-SNAPSHOT.jar/com.voxelbuster.enchantcopy.PluginEventHandler.onAnvilUse(PluginEventHandler.java:38) ~[enchantcopy-1.0-SNAPSHOT.jar:?]
          at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor287.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 org.bukkit.event.Event.callEvent(Event.java:45) ~[paper-api-1.21-R0.1-SNAPSHOT.jar:?]
          at org.bukkit.craftbukkit.event.CraftEventFactory.callPrepareResultEvent(CraftEventFactory.java:1800) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.inventory.ItemCombinerMenu.slotsChanged(ItemCombinerMenu.java:114) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.inventory.ItemCombinerMenu$3.setChanged(ItemCombinerMenu.java:104) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.SimpleContainer.setItem(SimpleContainer.java:226) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.inventory.Slot.set(Slot.java:66) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.inventory.Slot.setByPlayer(Slot.java:62) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.inventory.Slot.setByPlayer(Slot.java:58) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.inventory.AbstractContainerMenu.moveItemStackTo(AbstractContainerMenu.java:866) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.inventory.AbstractContainerMenu.moveItemStackTo(AbstractContainerMenu.java:772) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.inventory.ItemCombinerMenu.quickMoveStack(ItemCombinerMenu.java:160) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.inventory.AbstractContainerMenu.doClick(AbstractContainerMenu.java:539) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.world.inventory.AbstractContainerMenu.clicked(AbstractContainerMenu.java:382) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:3130) ~[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.runAllTasks(BlockableEventLoop.java:114) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1622) ~[paper-1.21.jar:1.21-66-99ae7bb]
          at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1309) ~[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) ~[?:?]

       

      From spigot JAR (CraftInventoryAnvil.class) [spigot-api-1.21-R0.1-20240807.214924-87.jar]:

      package org.bukkit.craftbukkit.v1_21_R1.inventory;

      import com.google.common.base.Preconditions;
      import net.minecraft.world.IInventory;
      import net.minecraft.world.inventory.ContainerAnvil;
      import org.bukkit.Location;
      import org.bukkit.inventory.AnvilInventory;

      public class CraftInventoryAnvil extends CraftResultInventory implements AnvilInventory {
      private final Location location;
      private final ContainerAnvil container;

      ...

      This forces plugin developers to depend on AnvilView methods from the Spigot server JAR.

            Unassigned Unassigned
            voxelbuster Galen Nare
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: