Files
Purpur/patches/api/0007-AFK-API.patch
jmp c7b279fe1b Updated Upstream (Paper & Tuinity)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
05af2837c [CI-SKIP] Improved the annotation test output
586966949 abstract custom set tags, add entity tags
c7667378e Added PlayerLoomPatternSelectEvent
00972e80d Reimplement GS4QueryEvent
544c5c278 Re-add coral block tags (#4987)
7d56c8deb Added PlayerLecternPageChangeEvent
c7cdf255b Add BlockFailedDispenseEvent
c8a8d6fbe Added world settings for mobs picking up loot
91eda5bd3 Added ServerResourcesReloadedEvent
be81b4f5c Add a Enchantable MaterialTag
975d18703 Add doors to material tags
d075e748e colorful itemdump
f3ba3dee0 Added WorldGameRuleChangeEvent
086d20118 Guardian beam workaround
b63c890ec Support spawning item stacks
d7d74c552 added height config for bamboo
7878e3bc2 Use setAmount for Recipe Amount
50e70697b Add EntityLoadCrossbowEvent
f344e092c Add Anti-Xray bypass permission
9fd31e675 fix for nerfed slime mobs splitting
4a7962cd1 Zombie API - breaking doors
5650a41f5 Fix interact event not being called in adventure
2c9ed4335 Add PlayerFlowerPotManipulateEvent
1f32290b6 [Auto] Updated Upstream (CraftBukkit)
d87694a20 Redact Velocity forwarding secret properly (#4980)
24a0b0206 [Auto] Updated Upstream (CraftBukkit)
7681042ef [Auto] Updated Upstream (Bukkit/CraftBukkit)
7dea3dba6 [Auto] Updated Upstream (CraftBukkit)
4b3792920 JavaDoc fixes
f13b4727e Allow disabling mob spawner spawn egg transformation
525b50737 Cache burn durations
2c37d1077 Optimized tick ready check
b4000b01a Add API to get the Material of Boats and Minecarts
f1317386d Fix sign lazy initialisation
9f61759d9 Updated Upstream (CraftBukkit/Spigot) (#4972)
aaff430b6 [CI-SKIP] Use GitHub Actions for build status
9f4055d99 Fix harming potion dupe
7bfb781ff Additional Block Material API's
0eaffd008 Micro Optimize DataBits

Tuinity Changes:
9e5cabb6e Port starlight changes
2021-01-04 15:21:27 -08:00

113 lines
3.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sat, 10 Aug 2019 22:19:56 -0500
Subject: [PATCH] AFK API
diff --git a/src/main/java/net/pl3x/purpur/event/PlayerAFKEvent.java b/src/main/java/net/pl3x/purpur/event/PlayerAFKEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..0c8b3e5e4ba412624357ea5662a78862bd9fc4be
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/event/PlayerAFKEvent.java
@@ -0,0 +1,70 @@
+package net.pl3x.purpur.event;
+
+import org.bukkit.entity.Player;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.bukkit.event.player.PlayerEvent;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class PlayerAFKEvent extends PlayerEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+ private final boolean setAfk;
+ private boolean shouldKick;
+ private String broadcast;
+ private boolean cancel;
+
+ public PlayerAFKEvent(@NotNull Player player, boolean setAfk, boolean shouldKick, @Nullable String broadcast, boolean async) {
+ super(player, async);
+ this.setAfk = setAfk;
+ this.shouldKick = shouldKick;
+ this.broadcast = broadcast;
+ }
+
+ /**
+ * Whether player is going afk or coming back
+ *
+ * @return True if going afk. False is coming back
+ */
+ public boolean isGoingAfk() {
+ return setAfk;
+ }
+
+ public boolean shouldKick() {
+ return shouldKick;
+ }
+
+ public void setShouldKick(boolean shouldKick) {
+ this.shouldKick = shouldKick;
+ }
+
+ @Nullable
+ public String getBroadcastMsg() {
+ return broadcast;
+ }
+
+ public void setBroadcastMsg(@Nullable String broadcast) {
+ this.broadcast = broadcast;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ @Override
+ @NotNull
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @NotNull
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index ea5257cc94d084fe4e0b9d9685e51d8f70cb84cb..183333a7468100271676b74709dcbb26d2b2b363 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -1927,4 +1927,25 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@Override
Spigot spigot();
// Spigot end
+
+ // Purpur start
+ /**
+ * Check if player is AFK
+ *
+ * @return True if AFK
+ */
+ boolean isAfk();
+
+ /**
+ * Set player as AFK
+ *
+ * @param setAfk Whether to set AFK or not
+ */
+ void setAfk(boolean setAfk);
+
+ /**
+ * Reset the idle timer back to 0
+ */
+ void resetIdleTimer();
+ // Purpur end
}