chaseoes / FirstJoinPlus

Customize all aspects of new players joining for the first time.
http://dev.bukkit.org/bukkit-plugins/firstjoinplus/
11 stars 16 forks source link

"bound must be positive" when calling getRandomPlayer #49

Open RoboMWM opened 7 years ago

RoboMWM commented 7 years ago

I'll investigate more if need be, but I have things to do and may PR a fix later if someone else doesn't find it before me.


[08:42:15] [Server thread/ERROR]: Could not pass event PlayerQuitEvent to FirstJoinPlus v2.4.1
org.bukkit.event.EventException
    at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:46) ~[patched_1.11.jar:git-Paper-962]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.11.jar:git-Paper-962]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.11.jar:git-Paper-962]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:517) [patched_1.11.jar:git-Paper-962]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:502) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.PlayerList.disconnect(PlayerList.java:410) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.PlayerConnection.a(PlayerConnection.java:1055) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.NetworkManager.handleDisconnection(NetworkManager.java:322) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.ServerConnection.c(ServerConnection.java:184) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:912) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:403) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:749) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:648) [patched_1.11.jar:git-Paper-962]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_111]
Caused by: java.lang.IllegalArgumentException: bound must be positive
    at java.util.Random.nextInt(Unknown Source) ~[?:1.8.0_111]
    at com.chaseoes.firstjoinplus.utilities.Utilities.getRandomPlayer(Utilities.java:153) ~[?:?]
    at com.chaseoes.firstjoinplus.utilities.Utilities.replaceVariables(Utilities.java:163) ~[?:?]
    at com.chaseoes.firstjoinplus.PlayerListeners.onPlayerQuit(PlayerListeners.java:72) ~[?:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor111.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:44) ~[patched_1.11.jar:git-Paper-962]
    ... 13 more
chaseoes commented 7 years ago

From what I can tell on that line, this should only happen if getServer().getOnlinePlayers() is empty (returns a size of 0); which should theoretically never be the case since it's being called during PlayerQuitEvent and that list shouldn't be empty until after the event has completed.

Not too sure, I would have to do some more research myself as well.

RoboMWM commented 7 years ago

This is all I've got in the logs:

[08:41:42] [LoginProcessingThread/INFO]: UUID of player kaptein2plays is nobodycaressoiremovedit
[08:41:43] [Server thread/INFO]: kaptein2plays[/removed] logged in with entity id 981608 at ([lazypvpworld]13.175060740610363, 11.0, 34.294799782587994)
[08:41:43] [Craft Scheduler Thread - 1006/INFO]: [GAListener] Player: kaptein2plays has 0 votes
[08:42:15] [Server thread/INFO]: kaptein2plays lost connection: Timed out
[08:42:15] [Server thread/ERROR]: Could not pass event PlayerQuitEvent to FirstJoinPlus v2.4.1
org.bukkit.event.EventException
    at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:46) ~[patched_1.11.jar:git-Paper-962]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.11.jar:git-Paper-962]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.11.jar:git-Paper-962]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:517) [patched_1.11.jar:git-Paper-962]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:502) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.PlayerList.disconnect(PlayerList.java:410) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.PlayerConnection.a(PlayerConnection.java:1055) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.NetworkManager.handleDisconnection(NetworkManager.java:322) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.ServerConnection.c(ServerConnection.java:184) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.MinecraftServer.D(MinecraftServer.java:912) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.DedicatedServer.D(DedicatedServer.java:403) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.MinecraftServer.C(MinecraftServer.java:749) [patched_1.11.jar:git-Paper-962]
    at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:648) [patched_1.11.jar:git-Paper-962]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_111]
Caused by: java.lang.IllegalArgumentException: bound must be positive
    at java.util.Random.nextInt(Unknown Source) ~[?:1.8.0_111]
    at com.chaseoes.firstjoinplus.utilities.Utilities.getRandomPlayer(Utilities.java:153) ~[?:?]
    at com.chaseoes.firstjoinplus.utilities.Utilities.replaceVariables(Utilities.java:163) ~[?:?]
    at com.chaseoes.firstjoinplus.PlayerListeners.onPlayerQuit(PlayerListeners.java:72) ~[?:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor111.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor$1.execute(EventExecutor.java:44) ~[patched_1.11.jar:git-Paper-962]
    ... 13 more
[08:42:15] [Server thread/INFO]: kaptein2plays left the game

I am running waterfall (fork of bungee). But yea, doesn't make much sense to me either.

chaseoes commented 7 years ago

That explains some more, specifically these lines:

[08:42:15] [Server thread/INFO]: kaptein2plays lost connection: Timed out
[08:42:15] [Server thread/INFO]: kaptein2plays left the game

I'm pretty sure that should not have happened. The same user somehow disconnected from the server twice despite only being connected once. I could be wrong but I think only one of those messages should have appeared.

FirstJoinPlus would have worked properly on the first disconnect it saw (when they timed out), but when it saw the second it resulted in an error since they were already removed from the player list on the first disconnect.

Possibly a bug in the server code? I'm assuming this was only a one time occurrence.

Again, just not really sure how getOnlinePlayers could ever be empty during that event otherwise this would happen every single time a user left the server when they're the only one online.

RoboMWM commented 7 years ago

The same user somehow disconnected from the server twice despite only being connected once. I could be wrong but I think only one of those messages should have appeared.

I'll double check, but if I recall it always prints their reason for losing connection (disconnected being the normal way), and then prints whatever is in event#getQuitMessage (which is interesting, because I silence quit messages, so normally for me this would not print). So probably is a server bug(?) since it seems quitevent was called too late?