aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0437-Add-player-idle-duration-API.patch
blob: d8f5d40c3c3fa18fd8edb492de8d019e6cd7a76b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 0d6401cd26424c971b137c968467e29f47c03d8b..0d585390066966f3afd6b88c6d80806292a3cd31 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -3645,6 +3645,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();