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 a84ea92d02d34cd48174152e0391f1af6c6b5def..023ca23e8c91a6525cc31d483d873dfe14e97da3 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2116,4 +2116,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
 }
