mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 17:07:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: d6f730655 Do not add passengers of entities that were above save limit (#5073) cb99288a5 Try to get a new 1.16.5 build on website now we hopefully fixed site bug 946cdd2d2 [CI-SKIP] [Auto] Rebuild Patches 8f805412b Remove class 13 from netty preload - Fixes #5066 f6d3c6811 Make ProjectileHitEvent Cancellable 97b020f13 make schedule command per world aac07a271 Return chat component with empty text instead of throwing exception. Fixes #3328 f27bc0659 Collision option for requiring a player participant 193f80148 Add StructureLocateEvent 59222b5ba Add sendOpLevel API f792973c2 [CI-SKIP] Update API to 1.16.5 (#5067) Tuinity Changes: db82b6c Update to starlight 0.0.3 b97e87f Merge branch 'master' into dev/lighting 1d169e7 Updated Upstream (Paper) 09997a6 Merge branch 'master' into dev/lighting 8954b61 Updated Upstream (Paper) 8753f47 Merge branch 'master' into dev/lighting 4743c34 Updated Upstream (Paper)
113 lines
3.1 KiB
Diff
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 cb6464c89e02d29484554a9a2184996a256925d2..7fd2085fa24779df1eab354532611d3642b37a27 100644
|
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
|
@@ -1938,4 +1938,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
|
|
}
|