mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 23:57:43 +01:00
30 lines
1.1 KiB
Diff
30 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 7ad3a0605be9d89bf7618f2ed8767fdebf25a178..651d59330fdbdaf2bdeab5795808ceaabc3dbddb 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -3414,6 +3414,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;
|