Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Use caffeine cache kickPermission instead of using google.common.cache
Browse files Browse the repository at this point in the history
  • Loading branch information
404Setup committed Aug 27, 2024
1 parent 92c5723 commit 5752ff3
Show file tree
Hide file tree
Showing 46 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Sun, 23 Jun 2024 11:26:20 +0800
Subject: [PATCH] Leaf: Use caffeine cache kickPermission instead of using
google.common.cache


diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index ee8f2fce3b6b2ddd6fb7a767a30dcf4d0e4888e7..9a4f53ebee1c7be2b61ddb203a4d36e138886a52 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -333,19 +333,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
private boolean justTeleported = false;
// CraftBukkit end

- // Purpur start
- private final com.google.common.cache.LoadingCache<CraftPlayer, Boolean> kickPermissionCache = com.google.common.cache.CacheBuilder.newBuilder()
+ // Purpur start // Leaf start - Use caffeine cache kickPermission instead of using google.common.cache
+ private final com.github.benmanes.caffeine.cache.LoadingCache<CraftPlayer, Boolean> kickPermissionCache = com.github.benmanes.caffeine.cache.Caffeine.newBuilder()
.maximumSize(1000)
.expireAfterWrite(1, java.util.concurrent.TimeUnit.MINUTES)
- .build(
- new com.google.common.cache.CacheLoader<>() {
- @Override
- public Boolean load(CraftPlayer player) {
- return player.hasPermission("purpur.bypassIdleKick");
- }
- }
- );
- // Purpur end
+ .build(player -> player.hasPermission("purpur.bypassIdleKick"));
+ // Purpur end // Leaf - Use caffeine cache kickPermission instead of using google.common.cache

@Override
public void tick() {
@@ -416,7 +409,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits
// Purpur start
this.player.setAfk(true);
- if (!this.player.level().purpurConfig.idleTimeoutKick || (!Boolean.parseBoolean(System.getenv("PURPUR_FORCE_IDLE_KICK")) && kickPermissionCache.getUnchecked(this.player.getBukkitEntity()))) {
+ if (!this.player.level().purpurConfig.idleTimeoutKick || (!Boolean.parseBoolean(System.getenv("PURPUR_FORCE_IDLE_KICK")) && kickPermissionCache.get(this.player.getBukkitEntity()))) { // Leaf - Use caffeine cache kickPermission instead of using google.common.cache
return;
}
// Purpur end
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ index 0e1dedb9baf70bd788a665e3cd7e53aa5f55def3..6c57a4bb3e30f906fddf84957533868a

public static long getCoordinateKey(final ChunkPos pair) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 24c4140e44b021728e39310f4e8bb93ada4adc0f..1390bc0f51ea2c957e470135eba1564f02840de9 100644
index 54065a663adeec4f8d429a14dd1e4f5fd47a6f48..e1b63e185f054b35b1ba522407541b21247e2e1f 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -315,7 +315,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ As part of: Akarin (https://github.com/Akarin-project/Akarin)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)

diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 34fbfdd87e7a7ddcaa22813a55142a559235af51..a806b1ca018091ceef1aa22a03a54d6de45efcd8 100644
index ca9d63cd2212191ff41b1161f683876c90f701d9..a14906340a6278ee2740b6f0d1a160f8555ba13a 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2229,8 +2229,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ index ee8e9c0e3690e78f3cc621ddfca89ea4256d4803..0466b04f24830539f2c927481c1c7995
}

diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 5d34f5a52219474d8ef91a9f030dde4f0c3aa8e5..95ca447e102e505d37a61f5c98f625bc1490a3fb 100644
index a14906340a6278ee2740b6f0d1a160f8555ba13a..dbbb5db2764098d677ad730652ff43ce9e4e3ca4 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -542,6 +542,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
Expand Down

0 comments on commit 5752ff3

Please sign in to comment.