mojira.dev
MC-254410

/setidletimeout set to a timer longer than 35791 disconnects idle player immediately

When i used the idle time out command and set it to 99999999, I expected it to take 9999999 minutes to get kicked out, but it took 1 second to get kicked out.

Linked issues

Attachments

Comments 4

Was that the exact value you set it to? Feels like it overflowed, but even with an overflow, you can't get 1 second with that.

It starts with 35792. 35791 and below work fine.

This seems correct. MinecraftServer#getPlayerIdleTimeout() returns an int, and ServerGamePacketListenerImpl#tick() has this piece of code:

...
        if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long)(this.server.getPlayerIdleTimeout() * 1000 * 60)) {
            this.disconnect(Component.translatable("multiplayer.disconnect.idling"));
        }
...

This overflows to negative when the timeout is greater than 35791 (35792 * 1000 * 60 > 2147483647, which is the int limit), which means that the player will get instantly kicked out. The timeout should be cast to long first, instead of the whole calculation:

(long)(this.server.getPlayerIdleTimeout()) * 1000 * 60

instead of

(long)(this.server.getPlayerIdleTimeout() * 1000 * 60)

Can confirm in 23w12a

aStickGuy

slicedlime

Community Consensus

Platform

Normal

Commands, Networking

1.19, 1.19.4, 23w12a

23w16a

Retrieved