geforkt von Mirrors/Paper
0cdce89d59
If a playerdata doesn't contain a valid, loaded world, reset to the main world spawn point
31 Zeilen
1.1 KiB
Diff
31 Zeilen
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 f6bc3a4af1bffe6abf5a93e975848de44965cbe3..57b67e42c1e5784ecd752cf1a5165a4d7eccdb15 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -3270,6 +3270,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;
|