diff --git a/leaf-server/minecraft-patches/features/0134-Cache-player-profileResult.patch b/leaf-server/minecraft-patches/features/0134-Cache-player-profileResult.patch deleted file mode 100644 index 8d2fd25c..00000000 --- a/leaf-server/minecraft-patches/features/0134-Cache-player-profileResult.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> -Date: Thu, 28 Mar 2024 13:36:09 -0400 -Subject: [PATCH] Cache player profileResult - -This patch includes code that references the Caffeine caching library, -which is licensed under the Apache License, Version 2.0. - -Caffeine (https://github.com/ben-manes/caffeine) -Copyright (c) Ben Manes - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index f68923c5f6fbecd8f1c10a30dbd06ed0dfee8b84..2e014cd543a6a790a0023835199b0e956e49fd1f 100644 ---- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -71,6 +71,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - public @Nullable java.util.UUID requestedUuid; // Paper - private final io.papermc.paper.connection.PaperPlayerLoginConnection paperLoginConnection; // Paper - Config API - private volatile boolean disconnecting = false; // Paper - Fix disconnect still ticking login -+ // Leaf start - Cache player profileResult -+ private static final com.github.benmanes.caffeine.cache.Cache playerProfileResultCache = com.github.benmanes.caffeine.cache.Caffeine.newBuilder() -+ .expireAfterWrite(org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResultTimeout, java.util.concurrent.TimeUnit.MINUTES) -+ .build(); -+ private static final com.github.benmanes.caffeine.cache.Cache playerSession = com.github.benmanes.caffeine.cache.Caffeine.newBuilder() -+ .expireAfterWrite(org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResultTimeout, java.util.concurrent.TimeUnit.MINUTES) -+ .build(); -+ // Leaf end - Cache player profileResult - - public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) { - this.server = server; -@@ -269,9 +277,30 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - String string1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized"); - - try { -- ProfileResult profileResult = ServerLoginPacketListenerImpl.this.server -- .getSessionService() -- .hasJoinedServer(string1, string, this.getAddress()); -+ // Leaf start - Cache player profileResult -+ ProfileResult profileResult; -+ if (org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResult) { -+ profileResult = playerProfileResultCache.getIfPresent(string1); -+ -+ InetAddress address = this.getAddress(); -+ InetAddress lastAddress = playerSession.getIfPresent(string1); -+ if (isInvalidSession(address, lastAddress)) { -+ // Send request to mojang server to verify session -+ // Result will be null if is invalid and will do disconnect logic below -+ profileResult = ServerLoginPacketListenerImpl.this.server -+ .getSessionService() -+ .hasJoinedServer(string1, string, address); -+ if (profileResult != null && address != null) { -+ playerProfileResultCache.put(string1, profileResult); -+ playerSession.put(string1, address); -+ } -+ } -+ } else { -+ profileResult = ServerLoginPacketListenerImpl.this.server -+ .getSessionService() -+ .hasJoinedServer(string1, string, this.getAddress()); -+ } -+ // Leaf end - Cache player profileResult - if (profileResult != null) { - GameProfile gameProfile = profileResult.profile(); - // CraftBukkit start - fire PlayerPreLoginEvent -@@ -316,6 +345,20 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - // Paper end - Cache authenticator threads - } - -+ // Leaf start - Cache player profileResult -+ private static boolean isInvalidSession(@org.jetbrains.annotations.Nullable InetAddress currAddress, @org.jetbrains.annotations.Nullable InetAddress lastAddress) { -+ // Invalid address or non-public IP address -+ if (currAddress == null || -+ currAddress.isAnyLocalAddress() || -+ currAddress.isLinkLocalAddress() || -+ currAddress.isLoopbackAddress() || -+ currAddress.isSiteLocalAddress()) { -+ return true; -+ } -+ return !currAddress.equals(lastAddress); -+ } -+ // Leaf end - Cache player profileResult -+ - // CraftBukkit start - private GameProfile callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception { // Paper - Add more fields to AsyncPlayerPreLoginEvent - // Paper start - Add Velocity IP Forwarding Support diff --git a/leaf-server/minecraft-patches/features/0135-Matter-Secure-Seed.patch b/leaf-server/minecraft-patches/features/0134-Matter-Secure-Seed.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0135-Matter-Secure-Seed.patch rename to leaf-server/minecraft-patches/features/0134-Matter-Secure-Seed.patch diff --git a/leaf-server/minecraft-patches/features/0136-Matter-Secure-Seed-command.patch b/leaf-server/minecraft-patches/features/0135-Matter-Secure-Seed-command.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0136-Matter-Secure-Seed-command.patch rename to leaf-server/minecraft-patches/features/0135-Matter-Secure-Seed-command.patch diff --git a/leaf-server/minecraft-patches/features/0137-Faster-random-generator.patch b/leaf-server/minecraft-patches/features/0136-Faster-random-generator.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0137-Faster-random-generator.patch rename to leaf-server/minecraft-patches/features/0136-Faster-random-generator.patch index 4818423e..814f40a2 100644 --- a/leaf-server/minecraft-patches/features/0137-Faster-random-generator.patch +++ b/leaf-server/minecraft-patches/features/0136-Faster-random-generator.patch @@ -97,7 +97,7 @@ index 8516d47b0ba79d91638837199e7ae0fb6cb44a79..4f4b55dd099dd2c2fea118b18b535881 RandomSource fork(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 0cdd3eb97e74aa3955f014a1f8f6a7d1580d323f..574be7359a2ad62c95a42c46c7a0f3c7a42eb44e 100644 +index ce331618d70d3dcfa576994e3f67f8c81fd6e8cc..2bed05da7e5ba52e85d437460679a7b81293fe5b 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -155,7 +155,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaf-server/minecraft-patches/features/0138-Don-t-save-primed-tnt-entity.patch b/leaf-server/minecraft-patches/features/0137-Don-t-save-primed-tnt-entity.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0138-Don-t-save-primed-tnt-entity.patch rename to leaf-server/minecraft-patches/features/0137-Don-t-save-primed-tnt-entity.patch diff --git a/leaf-server/minecraft-patches/features/0139-Don-t-save-falling-block-entity.patch b/leaf-server/minecraft-patches/features/0138-Don-t-save-falling-block-entity.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0139-Don-t-save-falling-block-entity.patch rename to leaf-server/minecraft-patches/features/0138-Don-t-save-falling-block-entity.patch diff --git a/leaf-server/minecraft-patches/features/0140-Configurable-connection-message.patch b/leaf-server/minecraft-patches/features/0139-Configurable-connection-message.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0140-Configurable-connection-message.patch rename to leaf-server/minecraft-patches/features/0139-Configurable-connection-message.patch diff --git a/leaf-server/minecraft-patches/features/0141-Configurable-unknown-command-message.patch b/leaf-server/minecraft-patches/features/0140-Configurable-unknown-command-message.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0141-Configurable-unknown-command-message.patch rename to leaf-server/minecraft-patches/features/0140-Configurable-unknown-command-message.patch diff --git a/leaf-server/minecraft-patches/features/0142-Remove-stream-in-BlockBehaviour-cache-blockstate.patch b/leaf-server/minecraft-patches/features/0141-Remove-stream-in-BlockBehaviour-cache-blockstate.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0142-Remove-stream-in-BlockBehaviour-cache-blockstate.patch rename to leaf-server/minecraft-patches/features/0141-Remove-stream-in-BlockBehaviour-cache-blockstate.patch diff --git a/leaf-server/minecraft-patches/features/0143-Remove-stream-in-entity-visible-effects-filter.patch b/leaf-server/minecraft-patches/features/0142-Remove-stream-in-entity-visible-effects-filter.patch similarity index 93% rename from leaf-server/minecraft-patches/features/0143-Remove-stream-in-entity-visible-effects-filter.patch rename to leaf-server/minecraft-patches/features/0142-Remove-stream-in-entity-visible-effects-filter.patch index 238af3b2..9e499c74 100644 --- a/leaf-server/minecraft-patches/features/0143-Remove-stream-in-entity-visible-effects-filter.patch +++ b/leaf-server/minecraft-patches/features/0142-Remove-stream-in-entity-visible-effects-filter.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Remove stream in entity visible effects filter diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 34460363c4a5fbd274fee0f26d3731333c990072..df52963414f6c3b626eaed0f36a6cabdad68f398 100644 +index d8c3f05d36916e122bfd47d761b4d91ab54fd8f5..a75f8f86ebd3bb73b5fbeb389137344256e1175f 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -1013,12 +1013,15 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin diff --git a/leaf-server/minecraft-patches/features/0144-Remove-stream-and-double-iteration-in-enough-deep-sl.patch b/leaf-server/minecraft-patches/features/0143-Remove-stream-and-double-iteration-in-enough-deep-sl.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0144-Remove-stream-and-double-iteration-in-enough-deep-sl.patch rename to leaf-server/minecraft-patches/features/0143-Remove-stream-and-double-iteration-in-enough-deep-sl.patch diff --git a/leaf-server/minecraft-patches/features/0145-Remove-stream-in-trial-spawner-ticking.patch b/leaf-server/minecraft-patches/features/0144-Remove-stream-in-trial-spawner-ticking.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0145-Remove-stream-in-trial-spawner-ticking.patch rename to leaf-server/minecraft-patches/features/0144-Remove-stream-in-trial-spawner-ticking.patch diff --git a/leaf-server/minecraft-patches/features/0146-Remove-stream-in-Brain.patch b/leaf-server/minecraft-patches/features/0145-Remove-stream-in-Brain.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0146-Remove-stream-in-Brain.patch rename to leaf-server/minecraft-patches/features/0145-Remove-stream-in-Brain.patch diff --git a/leaf-server/minecraft-patches/features/0147-Remove-stream-in-BehaviorUtils.patch b/leaf-server/minecraft-patches/features/0146-Remove-stream-in-BehaviorUtils.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0147-Remove-stream-in-BehaviorUtils.patch rename to leaf-server/minecraft-patches/features/0146-Remove-stream-in-BehaviorUtils.patch diff --git a/leaf-server/minecraft-patches/features/0148-Remove-stream-in-YieldJobSite.patch b/leaf-server/minecraft-patches/features/0147-Remove-stream-in-YieldJobSite.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0148-Remove-stream-in-YieldJobSite.patch rename to leaf-server/minecraft-patches/features/0147-Remove-stream-in-YieldJobSite.patch diff --git a/leaf-server/minecraft-patches/features/0149-Remove-stream-in-PlayerSensor.patch b/leaf-server/minecraft-patches/features/0148-Remove-stream-in-PlayerSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0149-Remove-stream-in-PlayerSensor.patch rename to leaf-server/minecraft-patches/features/0148-Remove-stream-in-PlayerSensor.patch diff --git a/leaf-server/minecraft-patches/features/0150-Remove-stream-in-GolemSensor.patch b/leaf-server/minecraft-patches/features/0149-Remove-stream-in-GolemSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0150-Remove-stream-in-GolemSensor.patch rename to leaf-server/minecraft-patches/features/0149-Remove-stream-in-GolemSensor.patch diff --git a/leaf-server/minecraft-patches/features/0151-Remove-stream-in-GateBehavior.patch b/leaf-server/minecraft-patches/features/0150-Remove-stream-in-GateBehavior.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0151-Remove-stream-in-GateBehavior.patch rename to leaf-server/minecraft-patches/features/0150-Remove-stream-in-GateBehavior.patch diff --git a/leaf-server/minecraft-patches/features/0152-Remove-stream-in-matchingSlot.patch b/leaf-server/minecraft-patches/features/0151-Remove-stream-in-matchingSlot.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0152-Remove-stream-in-matchingSlot.patch rename to leaf-server/minecraft-patches/features/0151-Remove-stream-in-matchingSlot.patch diff --git a/leaf-server/minecraft-patches/features/0153-Remove-stream-in-entity-mountedOrDismounted-changes-.patch b/leaf-server/minecraft-patches/features/0152-Remove-stream-in-entity-mountedOrDismounted-changes-.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0153-Remove-stream-in-entity-mountedOrDismounted-changes-.patch rename to leaf-server/minecraft-patches/features/0152-Remove-stream-in-entity-mountedOrDismounted-changes-.patch diff --git a/leaf-server/minecraft-patches/features/0154-Replace-Entity-active-effects-map-with-optimized-col.patch b/leaf-server/minecraft-patches/features/0153-Replace-Entity-active-effects-map-with-optimized-col.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0154-Replace-Entity-active-effects-map-with-optimized-col.patch rename to leaf-server/minecraft-patches/features/0153-Replace-Entity-active-effects-map-with-optimized-col.patch index 5fcbf028..d9affe7b 100644 --- a/leaf-server/minecraft-patches/features/0154-Replace-Entity-active-effects-map-with-optimized-col.patch +++ b/leaf-server/minecraft-patches/features/0153-Replace-Entity-active-effects-map-with-optimized-col.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Replace Entity active effects map with optimized collection Dreeam TODO: check this diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index df52963414f6c3b626eaed0f36a6cabdad68f398..4fc9b64bce70ef1169cf361d1414553f63f047ec 100644 +index a75f8f86ebd3bb73b5fbeb389137344256e1175f..1df69848c60a724b14bb6230a67ecd7cac1a0e03 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -208,6 +208,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin diff --git a/leaf-server/minecraft-patches/features/0155-Replace-criterion-map-with-optimized-collection.patch b/leaf-server/minecraft-patches/features/0154-Replace-criterion-map-with-optimized-collection.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0155-Replace-criterion-map-with-optimized-collection.patch rename to leaf-server/minecraft-patches/features/0154-Replace-criterion-map-with-optimized-collection.patch diff --git a/leaf-server/minecraft-patches/features/0156-Replace-brain-with-optimized-collection.patch b/leaf-server/minecraft-patches/features/0155-Replace-brain-with-optimized-collection.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0156-Replace-brain-with-optimized-collection.patch rename to leaf-server/minecraft-patches/features/0155-Replace-brain-with-optimized-collection.patch diff --git a/leaf-server/minecraft-patches/features/0157-Reduce-worldgen-allocations.patch b/leaf-server/minecraft-patches/features/0156-Reduce-worldgen-allocations.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0157-Reduce-worldgen-allocations.patch rename to leaf-server/minecraft-patches/features/0156-Reduce-worldgen-allocations.patch diff --git a/leaf-server/minecraft-patches/features/0158-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch b/leaf-server/minecraft-patches/features/0157-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch similarity index 97% rename from leaf-server/minecraft-patches/features/0158-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch rename to leaf-server/minecraft-patches/features/0157-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch index b6585b19..a75566aa 100644 --- a/leaf-server/minecraft-patches/features/0158-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch +++ b/leaf-server/minecraft-patches/features/0157-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch @@ -23,7 +23,7 @@ See the License for the specific language governing permissions and limitations under the License. diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index b3c138e78552ba348d67c37343c6684d37f2e10f..3f8b0c9f0d2172b1ffaee6c1065a91ff34b35953 100644 +index 0c73d4919e58b9282a8a6fc24fc7ab8e87b97b74..070fc3b4ec0558c597eb411db5b22edc447fe976 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java @@ -342,17 +342,12 @@ public class ServerGamePacketListenerImpl diff --git a/leaf-server/minecraft-patches/features/0159-Do-not-place-player-if-the-server-is-full.patch b/leaf-server/minecraft-patches/features/0158-Do-not-place-player-if-the-server-is-full.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0159-Do-not-place-player-if-the-server-is-full.patch rename to leaf-server/minecraft-patches/features/0158-Do-not-place-player-if-the-server-is-full.patch diff --git a/leaf-server/minecraft-patches/features/0160-Fix-MC-65198.patch b/leaf-server/minecraft-patches/features/0159-Fix-MC-65198.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0160-Fix-MC-65198.patch rename to leaf-server/minecraft-patches/features/0159-Fix-MC-65198.patch diff --git a/leaf-server/minecraft-patches/features/0161-Fix-MC-200418.patch b/leaf-server/minecraft-patches/features/0160-Fix-MC-200418.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0161-Fix-MC-200418.patch rename to leaf-server/minecraft-patches/features/0160-Fix-MC-200418.patch diff --git a/leaf-server/minecraft-patches/features/0162-Fix-MC-119417.patch b/leaf-server/minecraft-patches/features/0161-Fix-MC-119417.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0162-Fix-MC-119417.patch rename to leaf-server/minecraft-patches/features/0161-Fix-MC-119417.patch diff --git a/leaf-server/minecraft-patches/features/0163-Fix-MC-223153.patch b/leaf-server/minecraft-patches/features/0162-Fix-MC-223153.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0163-Fix-MC-223153.patch rename to leaf-server/minecraft-patches/features/0162-Fix-MC-223153.patch diff --git a/leaf-server/minecraft-patches/features/0164-Configurable-player-knockback-zombie.patch b/leaf-server/minecraft-patches/features/0163-Configurable-player-knockback-zombie.patch similarity index 95% rename from leaf-server/minecraft-patches/features/0164-Configurable-player-knockback-zombie.patch rename to leaf-server/minecraft-patches/features/0163-Configurable-player-knockback-zombie.patch index 25a2b11c..e7c18f07 100644 --- a/leaf-server/minecraft-patches/features/0164-Configurable-player-knockback-zombie.patch +++ b/leaf-server/minecraft-patches/features/0163-Configurable-player-knockback-zombie.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable player knockback zombie diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 4fc9b64bce70ef1169cf361d1414553f63f047ec..d81d1303fc3d23b35dbc177dd6a4c7f489eb5381 100644 +index 1df69848c60a724b14bb6230a67ecd7cac1a0e03..f63d0af0f6dc8a634f56f329d256affeaeac17da 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -2111,6 +2111,8 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin diff --git a/leaf-server/minecraft-patches/features/0165-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch b/leaf-server/minecraft-patches/features/0164-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0165-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch rename to leaf-server/minecraft-patches/features/0164-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch diff --git a/leaf-server/minecraft-patches/features/0166-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch b/leaf-server/minecraft-patches/features/0165-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0166-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch rename to leaf-server/minecraft-patches/features/0165-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch diff --git a/leaf-server/minecraft-patches/features/0167-PaperPR-Fix-some-beacon-event-issues.patch b/leaf-server/minecraft-patches/features/0166-PaperPR-Fix-some-beacon-event-issues.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0167-PaperPR-Fix-some-beacon-event-issues.patch rename to leaf-server/minecraft-patches/features/0166-PaperPR-Fix-some-beacon-event-issues.patch diff --git a/leaf-server/minecraft-patches/features/0168-Dont-send-useless-entity-packets.patch b/leaf-server/minecraft-patches/features/0167-Dont-send-useless-entity-packets.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0168-Dont-send-useless-entity-packets.patch rename to leaf-server/minecraft-patches/features/0167-Dont-send-useless-entity-packets.patch diff --git a/leaf-server/minecraft-patches/features/0169-Multithreaded-Tracker.patch b/leaf-server/minecraft-patches/features/0168-Multithreaded-Tracker.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0169-Multithreaded-Tracker.patch rename to leaf-server/minecraft-patches/features/0168-Multithreaded-Tracker.patch diff --git a/leaf-server/minecraft-patches/features/0170-Nitori-Async-playerdata-saving.patch b/leaf-server/minecraft-patches/features/0169-Nitori-Async-playerdata-saving.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0170-Nitori-Async-playerdata-saving.patch rename to leaf-server/minecraft-patches/features/0169-Nitori-Async-playerdata-saving.patch diff --git a/leaf-server/minecraft-patches/features/0171-Optimize-nearby-alive-players-for-spawning.patch b/leaf-server/minecraft-patches/features/0170-Optimize-nearby-alive-players-for-spawning.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0171-Optimize-nearby-alive-players-for-spawning.patch rename to leaf-server/minecraft-patches/features/0170-Optimize-nearby-alive-players-for-spawning.patch diff --git a/leaf-server/minecraft-patches/features/0172-Cache-blockstate-cache-array.patch b/leaf-server/minecraft-patches/features/0171-Cache-blockstate-cache-array.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0172-Cache-blockstate-cache-array.patch rename to leaf-server/minecraft-patches/features/0171-Cache-blockstate-cache-array.patch diff --git a/leaf-server/minecraft-patches/features/0173-Asynchronous-locator.patch b/leaf-server/minecraft-patches/features/0172-Asynchronous-locator.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0173-Asynchronous-locator.patch rename to leaf-server/minecraft-patches/features/0172-Asynchronous-locator.patch diff --git a/leaf-server/minecraft-patches/features/0174-Smart-sort-entities-in-NearestLivingEntitySensor.patch b/leaf-server/minecraft-patches/features/0173-Smart-sort-entities-in-NearestLivingEntitySensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0174-Smart-sort-entities-in-NearestLivingEntitySensor.patch rename to leaf-server/minecraft-patches/features/0173-Smart-sort-entities-in-NearestLivingEntitySensor.patch diff --git a/leaf-server/minecraft-patches/features/0175-Further-reduce-memory-footprint-of-CompoundTag.patch b/leaf-server/minecraft-patches/features/0174-Further-reduce-memory-footprint-of-CompoundTag.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0175-Further-reduce-memory-footprint-of-CompoundTag.patch rename to leaf-server/minecraft-patches/features/0174-Further-reduce-memory-footprint-of-CompoundTag.patch diff --git a/leaf-server/minecraft-patches/features/0176-Optimize-Entity-distanceToSqr.patch b/leaf-server/minecraft-patches/features/0175-Optimize-Entity-distanceToSqr.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0176-Optimize-Entity-distanceToSqr.patch rename to leaf-server/minecraft-patches/features/0175-Optimize-Entity-distanceToSqr.patch diff --git a/leaf-server/minecraft-patches/features/0177-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch b/leaf-server/minecraft-patches/features/0176-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0177-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch rename to leaf-server/minecraft-patches/features/0176-EMC-Don-t-use-snapshots-for-TileEntity-getOwner.patch diff --git a/leaf-server/minecraft-patches/features/0178-Cache-tile-entity-position.patch b/leaf-server/minecraft-patches/features/0177-Cache-tile-entity-position.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0178-Cache-tile-entity-position.patch rename to leaf-server/minecraft-patches/features/0177-Cache-tile-entity-position.patch diff --git a/leaf-server/minecraft-patches/features/0179-TT20-Lag-compensation.patch b/leaf-server/minecraft-patches/features/0178-TT20-Lag-compensation.patch similarity index 97% rename from leaf-server/minecraft-patches/features/0179-TT20-Lag-compensation.patch rename to leaf-server/minecraft-patches/features/0178-TT20-Lag-compensation.patch index f2c38fce..d825871e 100644 --- a/leaf-server/minecraft-patches/features/0179-TT20-Lag-compensation.patch +++ b/leaf-server/minecraft-patches/features/0178-TT20-Lag-compensation.patch @@ -7,7 +7,7 @@ Original license: AGPL-3.0 Original project: https://github.com/snackbag/TT20 diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 07943aa3be4222ab7a63b09a6625f7a003da8725..3c45e6eac0403c9cb13409c8e0e9c1653fd531ba 100644 +index 6c1a8925b1e13a0ebddc1b45a980fe8bdd8676cf..169d4c5e317af201a2d5ad0d82d39805376c2e9e 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -1541,6 +1541,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { this.awardStat(Stats.WALK_UNDER_WATER_ONE_CM, rounded); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index ab0cf0bff7b477327fd92a20e6c7bc7d62f418d2..ceede6519645cb488ea4152842e00751eef53a6c 100644 +index f70fff36ba616afbd1869caeee1b20d4c1579a19..e054c2416919fe8814412e6e06cd82e4ea537c84 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -288,7 +288,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaf-server/minecraft-patches/features/0252-Cache-block-path-type.patch b/leaf-server/minecraft-patches/features/0251-Cache-block-path-type.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0252-Cache-block-path-type.patch rename to leaf-server/minecraft-patches/features/0251-Cache-block-path-type.patch diff --git a/leaf-server/minecraft-patches/features/0253-optimize-getEntityStatus.patch b/leaf-server/minecraft-patches/features/0252-optimize-getEntityStatus.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0253-optimize-getEntityStatus.patch rename to leaf-server/minecraft-patches/features/0252-optimize-getEntityStatus.patch diff --git a/leaf-server/minecraft-patches/features/0254-Rail-Optimization-optimized-PoweredRailBlock-logic.patch b/leaf-server/minecraft-patches/features/0253-Rail-Optimization-optimized-PoweredRailBlock-logic.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0254-Rail-Optimization-optimized-PoweredRailBlock-logic.patch rename to leaf-server/minecraft-patches/features/0253-Rail-Optimization-optimized-PoweredRailBlock-logic.patch diff --git a/leaf-server/minecraft-patches/features/0255-optimise-ChunkGenerator-getMobsAt.patch b/leaf-server/minecraft-patches/features/0254-optimise-ChunkGenerator-getMobsAt.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0255-optimise-ChunkGenerator-getMobsAt.patch rename to leaf-server/minecraft-patches/features/0254-optimise-ChunkGenerator-getMobsAt.patch diff --git a/leaf-server/minecraft-patches/features/0256-cache-getBiome.patch b/leaf-server/minecraft-patches/features/0255-cache-getBiome.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0256-cache-getBiome.patch rename to leaf-server/minecraft-patches/features/0255-cache-getBiome.patch diff --git a/leaf-server/minecraft-patches/features/0257-optimize-mob-spawning.patch b/leaf-server/minecraft-patches/features/0256-optimize-mob-spawning.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0257-optimize-mob-spawning.patch rename to leaf-server/minecraft-patches/features/0256-optimize-mob-spawning.patch diff --git a/leaf-server/minecraft-patches/features/0258-optimize-structure-map.patch b/leaf-server/minecraft-patches/features/0257-optimize-structure-map.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0258-optimize-structure-map.patch rename to leaf-server/minecraft-patches/features/0257-optimize-structure-map.patch diff --git a/leaf-server/minecraft-patches/features/0259-throttle-mob-spawning.patch b/leaf-server/minecraft-patches/features/0258-throttle-mob-spawning.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0259-throttle-mob-spawning.patch rename to leaf-server/minecraft-patches/features/0258-throttle-mob-spawning.patch diff --git a/leaf-server/minecraft-patches/features/0260-Add-BlockExplosionHitEvent.patch b/leaf-server/minecraft-patches/features/0259-Add-BlockExplosionHitEvent.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0260-Add-BlockExplosionHitEvent.patch rename to leaf-server/minecraft-patches/features/0259-Add-BlockExplosionHitEvent.patch diff --git a/leaf-server/minecraft-patches/features/0261-Old-Blast-Protection-explosion-knockback.patch b/leaf-server/minecraft-patches/features/0260-Old-Blast-Protection-explosion-knockback.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0261-Old-Blast-Protection-explosion-knockback.patch rename to leaf-server/minecraft-patches/features/0260-Old-Blast-Protection-explosion-knockback.patch diff --git a/leaf-server/minecraft-patches/features/0262-Use-UUID-for-cure-reputation.patch b/leaf-server/minecraft-patches/features/0261-Use-UUID-for-cure-reputation.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0262-Use-UUID-for-cure-reputation.patch rename to leaf-server/minecraft-patches/features/0261-Use-UUID-for-cure-reputation.patch diff --git a/leaf-server/minecraft-patches/features/0263-Fix-crash-during-parsing-unknown-command-message.patch b/leaf-server/minecraft-patches/features/0262-Fix-crash-during-parsing-unknown-command-message.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0263-Fix-crash-during-parsing-unknown-command-message.patch rename to leaf-server/minecraft-patches/features/0262-Fix-crash-during-parsing-unknown-command-message.patch diff --git a/leaf-server/minecraft-patches/features/0264-optimize-random-tick.patch b/leaf-server/minecraft-patches/features/0263-optimize-random-tick.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0264-optimize-random-tick.patch rename to leaf-server/minecraft-patches/features/0263-optimize-random-tick.patch diff --git a/leaf-server/minecraft-patches/features/0265-do-not-log-invalid-flatten-text-component-parse.patch b/leaf-server/minecraft-patches/features/0264-do-not-log-invalid-flatten-text-component-parse.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0265-do-not-log-invalid-flatten-text-component-parse.patch rename to leaf-server/minecraft-patches/features/0264-do-not-log-invalid-flatten-text-component-parse.patch diff --git a/leaf-server/minecraft-patches/features/0266-Fast-BiomeManager-seed-obfuscation.patch b/leaf-server/minecraft-patches/features/0265-Fast-BiomeManager-seed-obfuscation.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0266-Fast-BiomeManager-seed-obfuscation.patch rename to leaf-server/minecraft-patches/features/0265-Fast-BiomeManager-seed-obfuscation.patch diff --git a/leaf-server/minecraft-patches/features/0267-Replace-EntitySelectorOptions-map-with-optimized-col.patch b/leaf-server/minecraft-patches/features/0266-Replace-EntitySelectorOptions-map-with-optimized-col.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0267-Replace-EntitySelectorOptions-map-with-optimized-col.patch rename to leaf-server/minecraft-patches/features/0266-Replace-EntitySelectorOptions-map-with-optimized-col.patch diff --git a/leaf-server/minecraft-patches/features/0268-optimize-no-action-time.patch b/leaf-server/minecraft-patches/features/0267-optimize-no-action-time.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0268-optimize-no-action-time.patch rename to leaf-server/minecraft-patches/features/0267-optimize-no-action-time.patch diff --git a/leaf-server/minecraft-patches/features/0269-optimize-waypoint.patch b/leaf-server/minecraft-patches/features/0268-optimize-waypoint.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0269-optimize-waypoint.patch rename to leaf-server/minecraft-patches/features/0268-optimize-waypoint.patch index 9faccfc8..8b737ead 100644 --- a/leaf-server/minecraft-patches/features/0269-optimize-waypoint.patch +++ b/leaf-server/minecraft-patches/features/0268-optimize-waypoint.patch @@ -5,7 +5,7 @@ Subject: [PATCH] optimize waypoint diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index e054c2416919fe8814412e6e06cd82e4ea537c84..a253d714670f932d67e2c44fdf895716b6b595ec 100644 +index ceede6519645cb488ea4152842e00751eef53a6c..5eaaeb6f6a87d3a2d851b1840c4f3acbc47a0766 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -5144,6 +5144,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaf-server/minecraft-patches/features/0270-Paw-optimization.patch b/leaf-server/minecraft-patches/features/0269-Paw-optimization.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0270-Paw-optimization.patch rename to leaf-server/minecraft-patches/features/0269-Paw-optimization.patch index d35e99e0..042f4a63 100644 --- a/leaf-server/minecraft-patches/features/0270-Paw-optimization.patch +++ b/leaf-server/minecraft-patches/features/0269-Paw-optimization.patch @@ -132,7 +132,7 @@ index 964c97a394122083a2f3c77b8ca529592c826080..a58ba94171b54feee82e4ec3d68d23f4 private void tickPassenger(Entity ridingEntity, Entity passengerEntity, final boolean isActive) { // Paper - EAR 2 diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index a253d714670f932d67e2c44fdf895716b6b595ec..641ad9779e7822d29d35a199fed8766887e62a8e 100644 +index 5eaaeb6f6a87d3a2d851b1840c4f3acbc47a0766..30a8c865bc754216266a1d1932130972f2fd67a2 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -1170,16 +1170,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaf-server/minecraft-patches/features/0271-Fix-Paper-config-fixClimbingBypassingCrammingRule.patch b/leaf-server/minecraft-patches/features/0270-Fix-Paper-config-fixClimbingBypassingCrammingRule.patch similarity index 95% rename from leaf-server/minecraft-patches/features/0271-Fix-Paper-config-fixClimbingBypassingCrammingRule.patch rename to leaf-server/minecraft-patches/features/0270-Fix-Paper-config-fixClimbingBypassingCrammingRule.patch index c0cf0696..2eea5860 100644 --- a/leaf-server/minecraft-patches/features/0271-Fix-Paper-config-fixClimbingBypassingCrammingRule.patch +++ b/leaf-server/minecraft-patches/features/0270-Fix-Paper-config-fixClimbingBypassingCrammingRule.patch @@ -19,7 +19,7 @@ index 5307e80f6e84df7a053e7132883d8338bbd751a0..d6be86981219f0fe0db15d36d9c85e9a // Leaf end - Only player pushable if (!pushableEntities.isEmpty()) { diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 9b4e6fdbedfa378ea436cdd5f1a36e2b3d94be17..645fad313ed3cd6ea5afe25c5d29dce828993371 100644 +index 06b46b973df84b16842a28f73df75613d09e75c9..f1f2775b56caf4820e03aa87f895c6570b271187 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -1909,7 +1909,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl diff --git a/leaf-server/minecraft-patches/features/0272-Skip-inactive-entity-for-execute.patch b/leaf-server/minecraft-patches/features/0271-Skip-inactive-entity-for-execute.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0272-Skip-inactive-entity-for-execute.patch rename to leaf-server/minecraft-patches/features/0271-Skip-inactive-entity-for-execute.patch diff --git a/leaf-server/minecraft-patches/features/0273-Optimise-getEntities.patch b/leaf-server/minecraft-patches/features/0272-Optimise-getEntities.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0273-Optimise-getEntities.patch rename to leaf-server/minecraft-patches/features/0272-Optimise-getEntities.patch diff --git a/leaf-server/minecraft-patches/features/0274-fix-MC-298464.patch b/leaf-server/minecraft-patches/features/0273-fix-MC-298464.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0274-fix-MC-298464.patch rename to leaf-server/minecraft-patches/features/0273-fix-MC-298464.patch diff --git a/leaf-server/minecraft-patches/features/0275-Re-route-SetClosestHomeAsWalkTarget-s-poi-finding-to.patch b/leaf-server/minecraft-patches/features/0274-Re-route-SetClosestHomeAsWalkTarget-s-poi-finding-to.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0275-Re-route-SetClosestHomeAsWalkTarget-s-poi-finding-to.patch rename to leaf-server/minecraft-patches/features/0274-Re-route-SetClosestHomeAsWalkTarget-s-poi-finding-to.patch diff --git a/leaf-server/minecraft-patches/features/0276-optimize-checkInsideBlocks-calls.patch b/leaf-server/minecraft-patches/features/0275-optimize-checkInsideBlocks-calls.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0276-optimize-checkInsideBlocks-calls.patch rename to leaf-server/minecraft-patches/features/0275-optimize-checkInsideBlocks-calls.patch index 2b09f2d0..a7ba6ec6 100644 --- a/leaf-server/minecraft-patches/features/0276-optimize-checkInsideBlocks-calls.patch +++ b/leaf-server/minecraft-patches/features/0275-optimize-checkInsideBlocks-calls.patch @@ -11,7 +11,7 @@ Subject: [PATCH] optimize checkInsideBlocks calls License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 641ad9779e7822d29d35a199fed8766887e62a8e..4a6f3e060496c831f8d810148e4f36a57f5e9f5d 100644 +index 30a8c865bc754216266a1d1932130972f2fd67a2..e7b375720c1bb78a9c3edf6d49c973eba1fcf115 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -1733,8 +1733,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaf-server/minecraft-patches/features/0277-Op-lock.patch b/leaf-server/minecraft-patches/features/0276-Op-lock.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0277-Op-lock.patch rename to leaf-server/minecraft-patches/features/0276-Op-lock.patch diff --git a/leaf-server/paper-patches/features/0063-cache-profile-data.patch b/leaf-server/paper-patches/features/0063-cache-profile-data.patch new file mode 100644 index 00000000..a3c4a493 --- /dev/null +++ b/leaf-server/paper-patches/features/0063-cache-profile-data.patch @@ -0,0 +1,146 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Taiyou06 +Date: Tue, 22 Jul 2025 01:24:40 +0200 +Subject: [PATCH] cache profile data + +This patch includes code that references the Caffeine caching library, +which is licensed under the Apache License, Version 2.0. + +Caffeine (https://github.com/ben-manes/caffeine) +Copyright (c) Ben Manes + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +Aside from the Caffeine cache, the code is licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) + +diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java +index d2d16055df7ca3c625a720dfca5b4cd090e2972e..db43329d57144471d0c9ce0eed92d2f1bd05f120 100644 +--- a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java ++++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java +@@ -35,6 +35,13 @@ public class CraftPlayerProfile implements PlayerProfile, SharedPlayerProfile { + private GameProfile profile; + private final PropertySet properties = new PropertySet(); + ++ // Leaf start - cache profile data ++ private static final com.github.benmanes.caffeine.cache.Cache PROFILE_DATA_CACHE = com.github.benmanes.caffeine.cache.Caffeine.newBuilder() ++ .expireAfterWrite(org.dreeam.leaf.config.modules.misc.CacheProfileLookup.timeout, java.util.concurrent.TimeUnit.MINUTES) ++ .maximumSize(org.dreeam.leaf.config.modules.misc.CacheProfileLookup.maxSize) ++ .build(); ++ // Leaf end - cache profile data ++ + public CraftPlayerProfile(CraftPlayer player) { + this.profile = player.getHandle().getGameProfile(); + } +@@ -195,11 +202,7 @@ public class CraftPlayerProfile implements PlayerProfile, SharedPlayerProfile { + + @Override + public @NotNull CompletableFuture update() { +- return CompletableFuture.supplyAsync(() -> { +- final CraftPlayerProfile clone = clone(); +- clone.complete(true); +- return clone; +- }, Util.PROFILE_EXECUTOR); ++ return CompletableFuture.supplyAsync(this::getNewProfile, Util.PROFILE_EXECUTOR); // Leaf - cache profile data + } + + @Override +@@ -260,7 +263,7 @@ public class CraftPlayerProfile implements PlayerProfile, SharedPlayerProfile { + MinecraftServer server = MinecraftServer.getServer(); + boolean isCompleteFromCache = this.completeFromCache(true, onlineMode); + if (onlineMode && (!isCompleteFromCache || (textures && !hasTextures()))) { +- ProfileResult result = server.getSessionService().fetchProfile(this.profile.getId(), true); ++ ProfileResult result = this.fetchProfile(server); // Leaf - cache profile data + if (result != null && result.profile() != null) { + copyProfileProperties(result.profile(), this.profile, true); + } +@@ -271,6 +274,80 @@ public class CraftPlayerProfile implements PlayerProfile, SharedPlayerProfile { + return this.isComplete() && (!onlineMode || !textures || hasTextures()); + } + ++ // Leaf start - cache profile data ++ // com.destroystokyo.paper.profile.CraftPlayerProfile#update is never used in server internal ++ // Probably only very rare plugins may use this. So here is just for cache update consistency. ++ // getNewProfile originally copied from org.bukkit.craftbukkit.profile.CraftPlayerProfile#getUpdatedProfile ++ private CraftPlayerProfile getNewProfile() { ++ MinecraftServer server = MinecraftServer.getServer(); ++ GameProfile currentProfile = this.buildGameProfile(); ++ ++ // Try to get profile from cache if UUID is not set ++ if (currentProfile.getId().equals(Util.NIL_UUID) && server.getProfileCache() != null) { ++ currentProfile = server.getProfileCache().get(currentProfile.getName()).orElse(currentProfile); ++ } ++ ++ // Fetch profile data if we have a valid UUID ++ if (!currentProfile.getId().equals(Util.NIL_UUID)) { ++ if (org.dreeam.leaf.config.modules.misc.CacheProfileLookup.enabled && ++ PROFILE_DATA_CACHE.asMap().containsKey(currentProfile.getId())) { ++ ++ ProfileResult cachedData = PROFILE_DATA_CACHE.getIfPresent(currentProfile.getId()); ++ if (cachedData != null) { ++ currentProfile = cachedData.profile(); ++ } ++ } else { ++ ProfileResult fetchedData = server.getSessionService().fetchProfile(currentProfile.getId(), true); ++ if (org.dreeam.leaf.config.modules.misc.CacheProfileLookup.enabled && fetchedData != null) { ++ PROFILE_DATA_CACHE.put(currentProfile.getId(), fetchedData); ++ } ++ if (fetchedData != null) { ++ currentProfile = fetchedData.profile(); ++ } ++ } ++ } ++ ++ return new CraftPlayerProfile(currentProfile); ++ } ++ ++ private ProfileResult fetchProfile(MinecraftServer server) { ++ GameProfile targetProfile = this.buildGameProfile(); ++ ++ // Resolve UUID from name cache if needed ++ if (targetProfile.getId().equals(Util.NIL_UUID) && server.getProfileCache() != null) { ++ targetProfile = server.getProfileCache().get(targetProfile.getName()).orElse(targetProfile); ++ } ++ ++ // Skip if still no valid UUID ++ if (targetProfile.getId().equals(Util.NIL_UUID)) { ++ return null; ++ } ++ ++ // Check cache first if enabled ++ if (org.dreeam.leaf.config.modules.misc.CacheProfileLookup.enabled) { ++ ProfileResult cachedResult = PROFILE_DATA_CACHE.getIfPresent(targetProfile.getId()); ++ if (cachedResult != null) { ++ return cachedResult; ++ } ++ } ++ ++ // Fetch fresh data from Mojang ++ ProfileResult fetchedResult = server.getSessionService().fetchProfile(targetProfile.getId(), true); ++ ++ // Cache the result if caching is enabled and data was fetched successfully ++ if (org.dreeam.leaf.config.modules.misc.CacheProfileLookup.enabled && fetchedResult != null) { ++ PROFILE_DATA_CACHE.put(targetProfile.getId(), fetchedResult); ++ } ++ ++ return fetchedResult; ++ } ++ ++ @Override ++ public boolean hasTextures() { ++ return this.profile.getProperties().containsKey("textures"); ++ } ++ // Leaf end - cache profile data ++ + private static void copyProfileProperties(GameProfile source, GameProfile target) { + copyProfileProperties(source, target, false); + } diff --git a/leaf-server/src/main/java/org/dreeam/leaf/config/modules/misc/Cache.java b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/misc/Cache.java deleted file mode 100644 index d7d6e7fc..00000000 --- a/leaf-server/src/main/java/org/dreeam/leaf/config/modules/misc/Cache.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.dreeam.leaf.config.modules.misc; - -import org.dreeam.leaf.config.ConfigModules; -import org.dreeam.leaf.config.EnumConfigCategory; - -public class Cache extends ConfigModules { - - public String getBasePath() { - return EnumConfigCategory.MISC.getBaseKeyName() + ".cache"; - } - - public static boolean cachePlayerProfileResult = false; - public static int cachePlayerProfileResultTimeout = 1440; - - @Override - public void onLoaded() { - cachePlayerProfileResult = config.getBoolean(getBasePath() + ".cache-player-profile-result", cachePlayerProfileResult, config.pickStringRegionBased(""" - Cache the player profile result on they first join. - It's useful if Mojang's verification server is down.""", - """ - 玩家首次加入时缓存 PlayerProfile. - 正版验证服务器宕机时非常有用.""")); - cachePlayerProfileResultTimeout = config.getInt(getBasePath() + ".cache-player-profile-result-timeout", cachePlayerProfileResultTimeout, - config.pickStringRegionBased( - "The timeout of the cache. Unit: Minutes.", - "缓存过期时间. 单位: 分钟." - )); - } -} diff --git a/leaf-server/src/main/java/org/dreeam/leaf/config/modules/misc/CacheProfileLookup.java b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/misc/CacheProfileLookup.java new file mode 100644 index 00000000..c21c107b --- /dev/null +++ b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/misc/CacheProfileLookup.java @@ -0,0 +1,31 @@ +package org.dreeam.leaf.config.modules.misc; + +import org.dreeam.leaf.config.ConfigModules; +import org.dreeam.leaf.config.EnumConfigCategory; + +public class CacheProfileLookup extends ConfigModules { + + public String getBasePath() { + return EnumConfigCategory.MISC.getBaseKeyName() + ".cache.profile-lookup"; + } + + public static boolean enabled = false; + public static int timeout = 1440; // 24 hours in minutes + public static int maxSize = 8192; + + @Override + public void onLoaded() { + enabled = config.getBoolean(getBasePath() + ".enabled", enabled, config.pickStringRegionBased(""" + Cache profile data lookups (skins, textures, etc.) to reduce API calls to Mojang.""", + """ + 缓存玩家资料查询 (皮肤, 材质等) 以减少对 Mojang API 的调用.""")); + timeout = config.getInt(getBasePath() + ".timeout", timeout, config.pickStringRegionBased( + "The timeout for profile lookup cache. Unit: Minutes.", + "玩家资料查询缓存过期时间. 单位: 分钟. (推荐: 1440 = 24小时)" + )); + maxSize = config.getInt(getBasePath() + ".max-size", maxSize, config.pickStringRegionBased( + "Maximum number of profiles to cache. Higher values use more memory (not that much).", + "最大缓存的玩家资料数量. 更高的值会使用更多内存." + )); + } +}