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

Schedulers are not run before player-caused events are fired

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • None
    • None

      At line 708 in MinecraftServer is code that runs 'FutureTask's which are nms's equivelent of Schedulers.
      Those FutureTask's are executed before the bukkit schedulers, and the schedulers are executed after those FutureTasks have been dealt with.

      When the server receives an async packet from mojang, if its not a async supported action, its added to a FutureTask to be run on the main thread.

      The Bukkit Schedulers have its own internal field which it uses to determine when to run a scheduler, and the current tick of the scheduler stuff. This is updated by the main thread, after Future Tasks have finished.

      This means that if a player right clicks a block, the server will call the "PlayerInteractEvent" and the plugins listening for that event will fire a new scheduler for 5 ticks.
      The Scheduler will see its current tick is 100, so it makes the Scheduler run at 105.
      Then the MinecraftServer finishes with receving the packets, and it starts doing the schedulers for that tick.
      Suddenly, the current tick is now 101, and the scheduler will be called in 200ms instead of 250ms.

      This can be fixed by moving the scheduler code to occur before the FutureTask code.

            Unassigned Unassigned
            libraryaddict libraryaddict
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: