[SPIGOT-2702] PrepareAnvilEvent fires 3 times Created: 27/Sep/16  Updated: 27/Dec/20  Resolved: 01/Oct/16

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: BillyGalbreath Assignee: Unassigned
Resolution: Won't Fix Votes: 1
Labels: None

Issue Links:
Duplicate
is duplicated by SPIGOT-6266 PrepareSmithingEvent called multiple ... Resolved

 Description   

As title states, the PrepareAnvilEvent fires 3 times. I asked in IRC if this is a known thing, and no one seemed to know, so I'm chalking this up as a bug.

This can be recreated with a simple event that outputs to console and simply place items into and put items out of an anvil inventory:

    @EventHandler
    public void onPrepareAnvil(PrepareAnvilEvent event) {
        System.out.println("Test");
    }


 Comments   
Comment by Black Hole [ 11/Dec/19 ]

As a workaround you could store if such event was called for a particular inventory and schedule a one time handling for the next tick.

Comment by Reg [ 11/Dec/19 ]

It now fires 5 times.

I appreciate the comment that it would be a lot of work to fix this but my plugin just broke because I had hardcoded it to handle three calls from each PrepareAnvilEvent and now, all of a sudden it's getting five calls.

What makes this particularly awkward is that I can no longer trust the fact that the number of calls will be consistent across (even minor) versions.

Comment by md_5 [ 01/Oct/16 ]

This is because the update routine is indeed run 3 times. It can't really be fixed without rewriting inventories.

Generated at Tue Apr 22 04:41:55 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.