mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes:26c37d99d5create random seeds for features using SecureRandom589bf2f1bfUpgrade gson to 2.8.8 (Closes #6370)0a6103597bGet entity default attributes (#6449)40057019e0Correctly inflate villager activation bounding box (#6798)e5f9241d15Left handed API (#6775)40ee63496cAdd advancement display API (#6175)9d570042edAdd ItemFactory#getMonsterEgg API (#6772)55ca459515rename method to getSpawnEggbb397ba74cAdd critical damage API (#6275)f47aeafe00Add Horse Animation API (#5599)7a0886180fAT & Mapping fixes (#6809)5553432644docs: Update gradle instructions for Java 16 (#6811) [ci skip]a1f49e4c60Fix command suggestion leak (#6592)9472d38f3cFix method name for Critical damage (#6813)
112 lines
3.1 KiB
Diff
112 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 56ffd7b4d791e5656447d11a47446a4759e775e3..6619d9109089d427e3eaec1f8c18dce23d6b7802 100644
|
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
|
@@ -2303,5 +2303,24 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
|
* @return True if Player uses Purpur Client
|
|
*/
|
|
public boolean usesPurpurClient();
|
|
+
|
|
+ /**
|
|
+ * 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
|
|
}
|