question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid usage of event API

See original GitHub issue

Description

Describe the bug

Because BentoBox uses the Bukkit event API wrongly, registered listeners are called for events they didn’t sign up for.

Steps to reproduce the behavior

Register a listener for an event, such as BentoBoxReadyEvent, not using the @EventHandler annotation, but by registering your own EventExecutor, with this method. This listener (/ executor) will be called for all of BentoBox’s events, not just the BentoBoxReadyEvent that it was registered to listen to. Example code:

Listener listener = new Listener() { };
EventExecutor eventExecutor = (execListener, event) -> Bukkit.broadcastMessage("Event " + event + " called");
Bukkit.getPluginManager().registerEvent(BentoBoxReadyEvent.class, listener, EventPriority.NORMAL, eventExecutor, this);

Expected behavior

The listener (/ executor) should only be called for the event it was registered to listen to.

Additional context (Optional)

https://gist.github.com/TPGamesNL/ee79fc4c348721925e2b4cfafb1a9ea0 Because BentoBox’s events use the abstract class BentoBoxEvent, which contains the required HandlerList, Bukkit sees all of BentoBox’s events as one event: BentoBoxEvent, therefore registered listeners will be called for all of its events, not just the event it was registered to listen to.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
BONNecommented, Dec 24, 2020

Handler list should be per each event, instead single global in abstract bentobox event

1reaction
tastybentocommented, Dec 24, 2020

Well, due to API usage, we cannot just change it directly… It should be deprecated and used correctly and update in each addon.

I would say we need at least 1 BentoBox release with “deprecation”.

Yes, I’ll mark the current BentoBoxEvent as deprecated for 1.15.4 and then 1.16.0 can have the new version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTMLInputElement: invalid event - Web APIs | MDN
The invalid event fires when a submittable element has been checked for validity and doesn't satisfy its constraints.
Read more >
Why do I get an "invalid payload" error for sending events?
If you are getting an "invalid payload" error for sending events to the insights API, we would recommend reviewing that your event data ......
Read more >
Handle API errors | Google Calendar API - Google Developers
User error. This can mean that a required field or parameter has not been provided, the value supplied is invalid, or the combination...
Read more >
GoogleCalendarV3 API throws error Invalid Value [400] when ...
The Error in Post was thrown because of this invalid value of ColorId. Google Calendar allows only 11 colors for an Event in...
Read more >
Troubleshoot the Event API - Optimizely
This topic helps you debug issues with sending API events to Optimizely's Event API. ... Event had one or more incorrect or missing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found