aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0884-Add-player-idle-duration-API.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0884-Add-player-idle-duration-API.patch')
-rw-r--r--patches/server/0884-Add-player-idle-duration-API.patch30
1 files changed, 30 insertions, 0 deletions
diff --git a/patches/server/0884-Add-player-idle-duration-API.patch b/patches/server/0884-Add-player-idle-duration-API.patch
new file mode 100644
index 0000000000..3bf9d659b7
--- /dev/null
+++ b/patches/server/0884-Add-player-idle-duration-API.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: booky10 <[email protected]>
+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 3b2d7837486424a2d1759c4ba5d1b1d492e9ec48..b72d6395768a762cd72f2b98bc8cb2598dc286b9 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+@@ -3449,6 +3449,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;