Paper/patches/server/1025-Add-player-idle-duration-API.patch
Jake Potrebic 1e7dd72f15
Remove 'fix Vanilla Minecart speed' patch (#10068)
The game uses 0.95d now
2023-12-22 17:44:36 -08: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 26ef78ea23a9b3abdf3e43aa5e90eec15bf1d78b..5ff67321df91bcf66b198ff346630e4d912ae341 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -3284,6 +3284,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;