Skip to content

Commit

Permalink
Fix potential incompatibility with plugins having afk
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Mar 4, 2024
1 parent 245acd6 commit 4bfdd82
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions patches/server/0072-Improve-Purpur-AFK-system.patch
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ index 9950580f3d0387b142576bfdb6a8f74365c12878..4270b24734affdeff0cd49ab494b7fad
}

diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 42885c7f374f619fe63d9fe22a4b7f88d68008c3..a3285a1981a45d19b7b751a3b87e9de4dfb3e47d 100644
index 42885c7f374f619fe63d9fe22a4b7f88d68008c3..66dfd4fc717a47ec2583f51500f4e923403a93d8 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2264,8 +2264,26 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2264,8 +2264,32 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
}

+ private final Map<ServerPlayer, Long> cooldown = new java.util.concurrent.ConcurrentHashMap<>(); // Purpur
+ private Map<ServerPlayer, Long> cooldown = new java.util.concurrent.ConcurrentHashMap<>(); // Purpur
+
@Override
public void handleChatCommand(ServerboundChatCommandPacket packet) {
+ // Purpur start
+ if (packet.command().equals("afk")) {
+ if (this.server.getPlayerIdleTimeout() > 0 && packet.command().equals("afk")) {
+ player.commandAfkStatus = player.isAfk();
+ player.isCommandAfk = true;
+ if (org.purpurmc.purpur.PurpurConfig.afkCommandCooldown > 0) {
Expand All @@ -80,6 +80,12 @@ index 42885c7f374f619fe63d9fe22a4b7f88d68008c3..a3285a1981a45d19b7b751a3b87e9de4
+ } else {
+ cooldown.put(player, currentTime);
+ }
+ // Dreeam - is this necessary?
+ /*
+ if (cooldown.size() > 200) {
+ cooldown = new java.util.concurrent.ConcurrentHashMap<>();
+ }
+ */
+ }
+ }
+ // Purpur end
Expand Down

0 comments on commit 4bfdd82

Please sign in to comment.