From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: booky10 Date: Sat, 14 Oct 2023 03:11:11 +0200 Subject: [PATCH] Add player idle duration API Implements API for getting and resetting a player's idle duration. diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 3d061f6dd550e395ec572ecdbd80b8d2d36a4453..f983f5dfb0bc5a4aee3971c13d2b84f12519edec 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -3286,6 +3286,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;