Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework the event API #378

Open
astei opened this issue Oct 28, 2020 · 1 comment
Open

Rework the event API #378

astei opened this issue Oct 28, 2020 · 1 comment
Labels
type: feature New feature or request

Comments

@astei
Copy link
Contributor

astei commented Oct 28, 2020

The Velocity event API, as currently designed, has some major flaws in its design that we should aim to correct for Velocity Polymer.

Handling of potentially blocking events

Status: Implemented with #384, thanks @Cybermaxke! It works essentially as I described, though the terminology is a bit different.

The original design choice for dealing with events that might potentially take too long in Velocity 1.x.x was to offload all event execution to a separate thread pool and execute the event handlers there. Unfortunately it is quite possible for this thread pool to be easily exhausted, Switching from the current fixed-size thread pool to a cached thread pool may help a little here, but it still poses issues. It also introduces context switching which may not be ideal for some users.

My current proposed solution is:

  • All events will now fire on the event loop initially. This means relatively lightweight listeners can run on the Netty event loop and reduce latency.
  • If there is a possibility for an event listener to do a task that can take some time, the event handler can choose to pause bubbling the event, perform the logic, and then resume bubbling the event.

Concrete implementations of events

Status: zml needs to do some refactoring for this, but event-impl-gen is what we plan to use to generate event implementations.

This concept was borrowed from Bukkit and as I have come to learn, is a very bad idea. This to some degree significantly complicated the transition from text to adventure, for instance.

For Velocity 2.0.0 we will take a page from Sponge and rework all Velocity events to use interfaces, then hide the actual event implementation in the proxy. So as to prevent duplication of code, we will try to auto-generate as much event-related code as possible.

Reconsider the event result system

Status: The result system will not be changed. There will be some reorganization, but most developers seem to need help with using it. Velocity 2.0.0 will add convenience methods that will set results for the user.

The event result system was introduced to combine the action to take as a result of an event and any associated actions to go with it. This has resulted in much confusion from plugin developers. I do not have a concrete strategy to handle this yet.

Consider adding a cause system ala Sponge

Status: This system isn't likely to add value since most events in Velocity already have a clear, fixed cause-and-effect relationship. We may reconsider this later if there is developer demand for it.

@astei astei added the type: feature New feature or request label Oct 28, 2020
@astei astei added this to the Velocity 2.0.0 milestone Oct 28, 2020
@MrIvanPlays
Copy link
Contributor

For Velocity 2.0.0 we will take a page from Sponge and rework all Velocity events to use interfaces, then hide the actual event implementation in the proxy.

Don't rly understand how can this make a transition as breaking as the transition from text to adventure less complicated.

@astei astei changed the title [2.0.0] Rework the event API Rework the event API May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants