Fix PlayerSit being blocked/warned by PlotSquared (#333) - #335
Open
whilowcx wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #333.
Two separate issues stacked on top of each other in
PlayerSitEventHandler, both related to how the player-sit click is handled relative to other plugins listening on the same events.1.
playerInteractAtEntityEventnever cancelled the event, and ran atHIGHESTPlotSquared has its own listener on
PlayerInteractAtEntityEventthat runs at a lower priority than GSit's (which wasHIGHEST), and cancels the event itself when the clicking player isn't trusted on the plot. Since GSit's handler usesignoreCancelled = true, it never got a chance to run once PlotSquared had already cancelled it, regardless oftrusted-region-only. That option only controls GSit's own internal PlotSquared check, it can't affect a third-party plugin's native protection reacting to the raw event first.Moved the listener to
LOWEST(so GSit's own checks run before any protection plugin can react) and made it cancel the event oncesitOnPlayeractually succeeds, instead of leaving it uncancelled.2.
PlayerInteractEntityEventwas never touchedRight-clicking a player fires both
PlayerInteractAtEntityEventand, independently,PlayerInteractEntityEvent. Cancelling the first doesn't stop the second from firing. PlotSquared has a separate listener on the plainPlayerInteractEntityEventtoo, which is what still produced a permission warning (plots.admin.interact.road) even after fixing 1, despite the sit already working by that point.Added a
LOWESTpriority listener forPlayerInteractEntityEventthat cancels it, but only when the clicking player is already a passenger of the right-clicked target, i.e. only for the interaction GSit itself just handled, so it doesn't swallow unrelated interactions.Testing
Built and ran on a local Paper 26.2 server with PlotSquared (built from source) and GSit patched:
trusted-region-only: false: sitting on another player now works both outside plots and inside plots you're not trusted on, no PlotSquared errors or messages.trusted-region-only: true: sitting on a player inside a plot you're not trusted on is correctly blocked by GSit itself; still allowed on the road, as expected.