Paper/patches/server/1024-Add-player-idle-duration-API.patch
Alex 88d28d6bdd
Fix long loading screen when refreshing skins (#10026)
Send `ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START` when refreshing players after
player profile changes.
2023-12-28 00:22:44 +01:00

31 lines
1.1 KiB
Diff

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
index f6abddc962babce7a72bd30a0213c580d3fdad7f..e7a59e33333234cf548769c5318d3a59db5c78b1 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3305,6 +3305,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;