Skip to content

Commit

Permalink
Fix afk command NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Mar 4, 2024
1 parent 8efd899 commit 245acd6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions patches/server/0072-Improve-Purpur-AFK-system.patch
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ 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..0818cd5912852c3ab9cdd999e02caafe1f8b94e0 100644
index 42885c7f374f619fe63d9fe22a4b7f88d68008c3..a3285a1981a45d19b7b751a3b87e9de4dfb3e47d 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2264,8 +2264,27 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2264,8 +2264,26 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
}

Expand All @@ -73,10 +73,9 @@ index 42885c7f374f619fe63d9fe22a4b7f88d68008c3..0818cd5912852c3ab9cdd999e02caafe
+ player.isCommandAfk = true;
+ if (org.purpurmc.purpur.PurpurConfig.afkCommandCooldown > 0) {
+ long currentTime = System.nanoTime();
+ long cd = (currentTime - cooldown.get(player)) / 1000000000;
+ if (cooldown.containsKey(player) && cd <= org.purpurmc.purpur.PurpurConfig.afkCommandCooldown) {
+ if (cooldown.containsKey(player) && (currentTime - cooldown.get(player)) / 1000000000 <= org.purpurmc.purpur.PurpurConfig.afkCommandCooldown) {
+ String msg = org.purpurmc.purpur.PurpurConfig.afkCooldown;
+ if (msg != null && !msg.isEmpty()) player.sendMessage(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(msg.replace("%time%", String.valueOf(org.purpurmc.purpur.PurpurConfig.afkCommandCooldown - cd))));
+ if (msg != null && !msg.isEmpty()) player.sendMessage(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(msg.replace("%time%", String.valueOf(org.purpurmc.purpur.PurpurConfig.afkCommandCooldown - (currentTime - cooldown.get(player)) / 1000000000))));
+ return;
+ } else {
+ cooldown.put(player, currentTime);
Expand Down

0 comments on commit 245acd6

Please sign in to comment.