2023-10-29 01:25:46 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: booky10 <boooky10@gmail.com>
|
|
|
|
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
|
2024-10-31 17:25:52 +01:00
|
|
|
index de97ca0a25d70de50dfcc6b092f5e58facfb5a3a..b4f967c8cc0800d0606e7ad32ff8a350387c6132 100644
|
2023-10-29 01:25:46 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2024-10-31 17:25:52 +01:00
|
|
|
@@ -3441,6 +3441,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2023-10-29 01:25:46 +02:00
|
|
|
}
|
|
|
|
// 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;
|