aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorbooky10 <[email protected]>2023-10-29 01:25:46 +0200
committerGitHub <[email protected]>2023-10-28 19:25:46 -0400
commit5bdfb29ba1fc5c097847617e0bd4737818feab2c (patch)
treed31d4a6a69dfdd4c7ed88ffedd244e2c00be3018
parentc6fac381ed94219deb569345add7fcdbeb70f060 (diff)
downloadPaper-5bdfb29ba1fc5c097847617e0bd4737818feab2c.tar.gz
Paper-5bdfb29ba1fc5c097847617e0bd4737818feab2c.zip
Add player idle duration API (#9833)
* Add player idle duration API Implements API for getting, setting and resetting a player's idle duration. * Remove idle duration setter * Rebase
-rw-r--r--patches/api/0442-Add-player-idle-duration-API.patch41
-rw-r--r--patches/server/1039-Add-player-idle-duration-API.patch30
2 files changed, 71 insertions, 0 deletions
diff --git a/patches/api/0442-Add-player-idle-duration-API.patch b/patches/api/0442-Add-player-idle-duration-API.patch
new file mode 100644
index 0000000000..5be2c8d0eb
--- /dev/null
+++ b/patches/api/0442-Add-player-idle-duration-API.patch
@@ -0,0 +1,41 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: booky10 <[email protected]>
+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/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
+index 20fa1024f9ad8f478a347be5c554b5e45b398a1c..2996db88343060624d6aab7889290ae74a973fe8 100644
+--- a/src/main/java/org/bukkit/entity/Player.java
++++ b/src/main/java/org/bukkit/entity/Player.java
+@@ -3274,6 +3274,29 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
+ void increaseWardenWarningLevel();
+ // Paper end
+
++ // Paper start
++ /**
++ * The idle duration is reset when the player
++ * sends specific action packets.
++ * <p>
++ * After the idle duration exceeds {@link org.bukkit.Bukkit#getIdleTimeout()}, the
++ * player will be kicked for {@link org.bukkit.event.player.PlayerKickEvent.Cause#IDLING}.
++ *
++ * @return the current idle duration of this player
++ */
++ @NotNull Duration getIdleDuration();
++
++ /**
++ * Resets this player's idle duration.
++ * <p>
++ * After the idle duration exceeds {@link org.bukkit.Bukkit#getIdleTimeout()}, the
++ * player will be kicked for {@link org.bukkit.event.player.PlayerKickEvent.Cause#IDLING}.
++ *
++ * @see #getIdleDuration()
++ */
++ void resetIdleDuration();
++ // Paper end
++
+ @NotNull
+ @Override
+ Spigot spigot();
diff --git a/patches/server/1039-Add-player-idle-duration-API.patch b/patches/server/1039-Add-player-idle-duration-API.patch
new file mode 100644
index 0000000000..18eb6c5321
--- /dev/null
+++ b/patches/server/1039-Add-player-idle-duration-API.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: booky10 <[email protected]>
+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 604ed1f6742a6b028b9db2809f7bd4b9a3b38f4d..bd2cb9080a5a215c97d4dc038ab8e8d1f7c20f8f 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+@@ -3278,6 +3278,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;