Add player idle duration API

Implements API for getting and resetting a player's idle duration.
This commit is contained in:
booky10 2023-10-14 03:11:11 +02:00
parent de8998e411
commit 2b6b81bde9

View File

@ -3416,6 +3416,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
// Paper end
// Paper start
@Override
public Duration getIdleDuration() {
return Duration.ofMillis(net.minecraft.Util.getMillis() - this.getHandle().getLastActionTime());
}
@Override
public void resetIdleDuration() {
this.getHandle().resetLastActionTime();
}
// Paper end
public Player.Spigot spigot()
{
return this.spigot;