1.13.2 "not-finite" crash without plugin calls

[15:34:25] [Server thread/WARN]: xars456 moved wrongly!
[15:34:25] [Server thread/ERROR]: Encountered an unexpected exception
java.lang.IllegalArgumentException: x not finite
	at org.bukkit.util.NumberConversions.checkFinite(NumberConversions.java:118) ~[patched_1.13.2.jar:git-Paper-636]
	at org.bukkit.util.Vector.checkFinite(Vector.java:800) ~[patched_1.13.2.jar:git-Paper-636]
	at org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity.setVelocity(CraftEntity.java:268) ~[patched_1.13.2.jar:git-Paper-636]
	at net.minecraft.server.v1_13_R2.EntityTrackerEntry.track(EntityTrackerEntry.java:280) ~[patched_1.13.2.jar:git-Paper-636]
	at net.minecraft.server.v1_13_R2.EntityTracker.updatePlayers(EntityTracker.java:175) ~[patched_1.13.2.jar:git-Paper-636]
	at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:1123) ~[patched_1.13.2.jar:git-Paper-636]
	at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:439) ~[patched_1.13.2.jar:git-Paper-636]
	at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:940) ~[patched_1.13.2.jar:git-Paper-636]
	at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:837) ~[patched_1.13.2.jar:git-Paper-636]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
[15:34:25] [Server thread/ERROR]: This crash report has been saved to: /home/minecraft/server/inf/./crash-reports/crash-2019-06-27_15.34.25-server.txt
[15:34:25] [Server thread/INFO]: Stopping server

As we can see, there’s no related method call by a specific plugin. We have many custom plugins and it’s hard to trace where the bug is.
It happend 3 times in June, and I still cann’t figure out why.
I tried to catch exceptions in our plugins but it seems that even if i don’t catch them, they won’t cause a server crash. it will just print a error message instead.

So I wonder how a infinite value was set when there’s a pre-check in API call (which happens when I pass a infinite value into a vector and set it to a player), and It rejects the input and print a error message like this:

[18:34:55] [Server thread/WARN]: [RPGItems] Task #21683 for RPGItems v3.7.686986-mc1.13.2 generated an exception
java.lang.IllegalArgumentException: x not finite
	at org.bukkit.util.NumberConversions.checkFinite(NumberConversions.java:118) ~[patched_1.13.2.jar:git-Paper-628]
	at org.bukkit.util.Vector.checkFinite(Vector.java:800) ~[patched_1.13.2.jar:git-Paper-628]
	at org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity.setVelocity(CraftEntity.java:268) ~[patched_1.13.2.jar:git-Paper-628]
	at think.rpgitems.power.impl.PowerKnockup.lambda$hit$0(PowerKnockup.java:51) ~[?:?]
	at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftTask.run(CraftTask.java:84) ~[patched_1.13.2.jar:git-Paper-628]
	at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:449) ~[patched_1.13.2.jar:git-Paper-628]
	at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:1010) ~[patched_1.13.2.jar:git-Paper-628]
	at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:439) ~[patched_1.13.2.jar:git-Paper-628]
	at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:940) ~[patched_1.13.2.jar:git-Paper-628]
	at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:837) ~[patched_1.13.2.jar:git-Paper-628]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]

It indicates the method so I can fix it.

So I suspect that it’s a issue for minecraft / Spigot / Paper. Maybe the pre-check method should be more powerful to handle situations like this.

Something on PlayerVelocityEvent, we can’t really touch that one cleanly due to the fact that it doesn’t actually rely on the setter as the Vector it returns is mutable, I don’t believe that there is a nice fix for this here other than cloning the vector and making sure that you validate it’s safe before applying it to the player

what if we don’t crash the whole game?
will the player flys around or error messages spam the console?
If not, I suggest that we should just cancel the invalid input and keep the server running.
It’s not a big problem but it did made my server operator headache in some special situations :p.

I’ll check all Vectors I used and clone them before using to prevent unexpected crashes.

Thanks a lot.