Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Add new event TickRateChangedEvent

Open Axionize opened this issue 1 year ago • 11 comments

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.

Axionize avatar Oct 08 '24 05:10 Axionize

Isn't the api/event itself missing?

dawon avatar Oct 08 '24 06:10 dawon

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...

Axionize avatar Oct 08 '24 07:10 Axionize

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

masmc05 avatar Oct 08 '24 08:10 masmc05

Pushed the actual event code

Axionize avatar Oct 08 '24 17:10 Axionize

@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.

Axionize avatar Oct 09 '24 00:10 Axionize

I've addressed all issues that have been brought up. Is there anything else I need to do for this to be merged?

Axionize avatar Oct 15 '24 15:10 Axionize

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)

Lulu13022002 avatar Oct 16 '24 14:10 Lulu13022002

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?

Axionize avatar Oct 17 '24 04:10 Axionize

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

electronicboy avatar Oct 17 '24 20:10 electronicboy

I've restructured this PR so that mutations will be reflected in messages and return values.

Axionize avatar Oct 20 '24 07:10 Axionize

Hi, is there anything left for me to do before this can be merged?

Axionize avatar Oct 28 '24 02:10 Axionize