-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add a new event for when an entity's scoreboard tags are changed: ScoreboardTagsChangeEvent
#13080
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
base: main
Are you sure you want to change the base?
Conversation
We generally dislike low level zero-contextual events to be cancellable, especially in cases where plugin calls will be involved; These events are okay for notification purposes (assuming they're not too heavy), but, generally, "plugins actions are exposed to everything else" is a pretty niche area due to just not breaking stuff blindly |
In this case, As for "plugins actions are exposed to everything else", I can see the reservations, though tags can be manipulated by means other than plugins. |
The only reason an add would currently fail is either that the tag already existed or you hit the size limit; The concern here is that plugins have 0 real context of why a tag was being mutated, exposing such events for the purposes of notification to allow plugins to update stuff like a cache sounds fair, allowing plugins to blindly prevent a tag from being added to an entity is a bit more iffy |
Alright, I see, that is indeed iffy. I will completely remove cancellation then. |
Regarding naming and/or structure, is there any glaring issue? Apart from it being a feature patch. |
79c574e
to
6ec009f
Compare
There it goes, amended the commits. Do you prefer squashing them both into one? |
The merger can deal with that aspect; Tags should probably not be mutable inside of the event, and the event generally shouldn't fire for loading data |
Good point. Would
Mmm, I see the concern. If we don't include that, modifying through NBT won't be covered. We can either accept that (I'd rather not, but ultimately it is okay if you prefer that) or opt to fire the event in the |
unmodifiableList would be fine; firing inside of data is probably going to be the best option here |
6ec009f
to
7440ccb
Compare
There we go. |
This adds a new event, `ScoreboardTagsChangeEvent`, which is called when an entity gets their scoreboard tags changed, through plugins calling `Entity#addScoreboardTag`, `/tag`, `/data`, etc. It is fired before the change happens and cannot be cancelled. It contains the affected entity, which change it is happening (add, remove or replace), and which tags are part of the change.
7440ccb
to
ba5904f
Compare
This adds a new event,
ScoreboardTagsChangeEvent
, which is called when an entity gets their scoreboard tags changed, through plugins callingEntity#addScoreboardTag
,/tag
,/data
, etc.It is fired before the change happens and can be cancelled. It contains the affected entity, which change it is happening (add, remove or replace), and which tags are part of the change.
I was looking to implement this event, because I'm currently emulating it, on a plugin I'm developing, by doing some complex and brittle handling of commands. However, it can't handle plugins calling
addScoreboardTag
/addTag
and it isn't even complete for vanilla methods (e.g. has issues withexecute
context changes).So I thought of adding this small event, it shouldn't impact performance that much. Even though I wasn't originally thinking of doing it, I made it cancellable, because why not?
I do have one concern with the current implementation, which is that it always creates a new list, even for single tag changes (which are likely to be the vast majority of changes). Not sure what the best move here is, suggestions are welcome.
Note: This implementation isn't finalized, it is missing doc comments, possibly some changes to imports, and naturally doesn't need to use feature patches. I threw this together very quickly to understand if the maintainers are okay with adding this event. If it is green-lit, I will finish it. In retrospective, I should have made an issue first, but oh well 🙃