Add PlayerCodeOfConductSendEvent - #13512
Conversation
8279814 to
7c093bd
Compare
Warriorrrr
left a comment
There was a problem hiding this comment.
This seems like fine API to have to me, and does already work when tested. One important thing that will either need to be documented or addressed is that the event won't be fired if the server doesn't have code of conducts enabled, or has no txt files configured in the codeofconduct folder.
Would it be worth looking into firing it cancelled, making it possible to uncancel in those situations? Like, would that behavior match how other events work or would it be considered a problem for server admins wanting to disable it? |
|
I feel that pre-cancelled events are generally more of a legacy compat behavioral hack of "we're firing this when it really shouldn't, this is cancelled because no side-effects will occur from this, we just want to let you know" - I guess you could argue that applies here, but I think the reality is that the intent works just fine here, the intent is to send it unless something cancels it, it will just do nothing if there is no data to send, etc |
|
I was viewing it as a "this is where I'd put my code of conduct, IF I HAD ONE!" opportunity for plugins to define their own so server admins don't have to define a dummy one just to get their pre-player code of conduct plugin to work. |
|
Yea, I understand that, my thought was more "empty by default rather than a cancelled boolean", or something to that effect; cancellation to me always felt like it should be more plugin driven rather than api caller driven |
|
Ah, so empty message doesn't send, like the join/quit event messages? That seems reasonable. |
|
Yes |
|
Updated to always fire! |
|
I fail to understand why this event would even fire empty if there was no code of conduct. |
|
You can only send the COC inside of configuration mode which is generally a chore for plugins to deal with the whole rigamarole of when the server is already there with the handling for this process anyways |
electronicboy
left a comment
There was a problem hiding this comment.
Flow, etc, looks fine to me
|
Pushed this diff at the advice of @Warriorrrr -+ if (true || !codeOfConducts.isEmpty()) { // Always fire the task
++ if (io.papermc.paper.event.player.PlayerCodeOfConductSendEvent.getHandlerList().getRegisteredListeners().length > 0 || !codeOfConducts.isEmpty()) { // Fire even if empty, if there are event listeners to potentially send one |
|
These paper comments dont properly wrap the diff |
Took me forever to notice the single linebreak at the bottom. Next time please share the specific issue! 😭 |
Fires even if the player was not about to receive one, so any player can receive one even if default disabled. Setting to null cancels sending.
Enables customizing the code of conduct per send.
Just throwing the idea out there. Draft because I'm not sure we even want this and because I haven't bothered to test it yet (but I can't see it blowing up).
Possible uses: