MLG-Fortress / ExtraHardMode

The now-official repository for the ExtraHardMode Bukkit Plugin.
http://dev.bukkit.org/bukkit-plugins/fun-hard-mode/
Other
24 stars 21 forks source link

Deprecated EventHandler methods on Paper starting with 1.18.1 #303

Closed SlimeDog closed 1 year ago

SlimeDog commented 2 years ago

Paper 1.18.1-161 and ff ExtraHardMode

On server start-up

[15:35:36] [Server thread/WARN]: @EventHandler method com.extrahardmode.features.AntiGrinder#onEntityDeath returns non-void type boolean. This is an unsupported behavior which will be removed in a future version of Paper.This should be reported to the developers of ExtraHardMode v3.15.0-e9c12af, (RoboMWM,Diemex,Big_Scary)
[15:35:36] [Server thread/WARN]: @EventHandler method com.extrahardmode.features.AntiGrinder#onEntitySpawn returns non-void type boolean. This is an unsupported behavior which will be removed in a future version of Paper.This should be reported to the developers of ExtraHardMode v3.15.0-e9c12af, (RoboMWM,Diemex,Big_Scary)
SlimeDog commented 1 year ago

Reminder that these are still reported by Paper 1.19.2.

Remski01 commented 1 year ago

Have asked in the Paper discord about this error, reply:

an EventHandler must return void
or, rather, should. non-void returns may be broken in the future and are not supported.

yeah just this whole class https://github.com/MLG-Fortress/ExtraHardMode/blob/e4f17b107651b0765f9a75a39399637c36ffd38c/src/main/java/com/extrahardmode/features/AntiGrinder.java#L157

just set it cancelled, remove all the returns— they don't do anything
unless you're doing something like calling the handler yourself (which you probably shouldn't)
SlimeDog commented 1 year ago

Looking at the ExtraHardMode sources, onEntityDeath() and onEntitySpawn() are declared void in all cases except in src/main/java/com/extrahardmode/features/AntiGrinder.java, where they are declared boolean and return true or false. It doesn't look like the return values are used anywhere, so the fix would be straightforward, as outlined above.

SlimeDog commented 1 year ago

I tried the fix locally, and it seems to work fine. Note that the assertFalse and assertTrue tests in src/test/com/extrahardmode/features/TestAntiGrinder.java will have to be changed as well. I did not feel comfortable making those changes -- I don't know how testing works -- so I did not post a PR.

SlimeDog commented 1 year ago

There is a new PR that covers this issue, both the code and the tests: https://github.com/MLG-Fortress/ExtraHardMode/pull/316

RoboMWM commented 1 year ago

closed by #316

ah I see why this wasn't auto-closed, it wasn't linked by the PR author.

SlimeDog commented 1 year ago

Confirmed fixed with the associated PR. Thanks.