Paper
Paper copied to clipboard
Add new event TickRateChangedEvent
This event fires when the tick rate is changed, either by a command or by a plugin.
Useful if you have code dependent on the tickRate (my use case is simulating and predicting possible player movements) and you don't want to have to poll the tickRate all the time.
Isn't the api/event itself missing?
Thank you for noticing that. Not used to the paper build system. Let me fix that real quick.
EDIT: rebuildPatches ate my code I'm going to have to rewrite this...
Also check https://github.com/PaperMC/Paper/blob/master/CONTRIBUTING.md#pr-policy, you're both missing comments on changed lines and you have imports instead of using fully qualified name
Also, use https://jd.papermc.io/paper/1.21.1/org/bukkit/event/Event.html#callEvent(), not the plugin manager
Pushed the actual event code
@masmc05 I addressed all the changes you requested. Added comments starting where my patch modifies code, switched to using event.callEvent() and the patch now uses the FQDN instead of imports for changes in Paper-Server.
I've addressed all issues that have been brought up. Is there anything else I need to do for this to be merged?
The event mix jetbrains and jspecify nullable annotations. And it's a bit iffy when a plugin change the tick rate cause the command executor doesn't receive the right tick rate in the feedback message (unlike the WorldGameRuleChangeEvent for example)
I'll fix the notations but I don't understand your second concern, what exactly is the problem? That the message returned to the player won't reflect the new tick rate?
That the message returned to the player won't reflect the new tick rate?
Yes, the server prints the output of the tick rate, and yet, if a plugin mutates it, this value will be wrong; if we want to support mutation, the logic should be adjusted to get the new rate so that the message is displayed properly, rather than having invisible side-effects to end users
I've restructured this PR so that mutations will be reflected in messages and return values.
Hi, is there anything left for me to do before this can be merged?