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

Resolve issues with Event IgnoreCancelled annotation being ignored #114

Merged
merged 1 commit into from
Dec 1, 2024

Conversation

RhysB
Copy link
Member

@RhysB RhysB commented Dec 1, 2024

Ensure the server adhears to the ignoreCancelled (@EventHandler(priority = Event.Priority.Monitor, ignoreCancelled = true)) annotation for listeners.

This code has been tested and verified utilizing the following code.
` @eventhandler(priority = Event.Priority.Monitor, ignoreCancelled = true)
public void monitorChatEvent(PlayerChatEvent event) {
// Print the message to the console with the priority

    if(event.isCancelled()) {
        logger(Level.INFO, "Monitor: " + event.getMessage() + ". This should not be printed as this listener is set to ignore cancelled events.");
    } else {
        logger(Level.INFO, "Monitor: " + event.getMessage());
    }
}

@EventHandler(priority = Event.Priority.Normal, ignoreCancelled = false)
public void normalChatEvent(PlayerChatEvent event) {
    // Print the message to the console with the priority
    logger(Level.INFO, "Normal: " + event.getMessage());

    // 50% chance to cancel the event
    if (Math.random() < 0.5) {
        System.out.println("Cancelling event");
        event.setCancelled(true);
    }
}`

Without Patch
image

With Patch
image

@RhysB RhysB requested a review from a team December 1, 2024 01:56
Copy link
Contributor

@Grassboii Grassboii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fantastic

Copy link

@RitzKid76 RitzKid76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to ritzy

@Grassboii Grassboii merged commit d27e141 into master Dec 1, 2024
2 checks passed
@RhysB RhysB deleted the resolve-ignore-cancelle branch December 1, 2024 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants