mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-29 20:09:17 +00:00
Drop old Cache player profileResult
This commit is contained in:
@@ -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 069477e524a28b20a0289221858bdc802704a890..114b25f933c6a1b011523581a5a02a5a2c1e827e 100644
|
||||
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -71,6 +71,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
private net.minecraft.server.level.ServerPlayer player; // CraftBukkit
|
||||
public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding
|
||||
private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support
|
||||
+ // Leaf start - Cache player profileResult
|
||||
+ private static final com.github.benmanes.caffeine.cache.Cache<String, ProfileResult> 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<String, InetAddress> 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;
|
||||
@@ -304,9 +312,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
|
||||
@@ -351,6 +380,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
|
||||
@@ -36,7 +36,7 @@ index 5748658abf0b90812005ae9d426df92daf5532f0..4a0eed7d7645ed539857592d233214e9
|
||||
this.get("generator-settings", property -> GsonHelper.parse(!property.isEmpty() ? property : "{}"), new JsonObject()),
|
||||
this.get("level-type", property -> property.toLowerCase(Locale.ROOT), WorldPresets.NORMAL.location().toString())
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 54895ed9ad9b9b2c4c12cfcce89af453c430e3e6..721d89144074c5749642feb0a08d21fbcce4b2fe 100644
|
||||
index c49eced5b0187bcec1d8d7543f63f1294e25ee44..32005b9d01169c6ad391a66101fdf26edb02fabc 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -710,6 +710,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -48,7 +48,7 @@ index 54895ed9ad9b9b2c4c12cfcce89af453c430e3e6..721d89144074c5749642feb0a08d21fb
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index f8bd39ddd7b6948734254acfb8b0235eff774133..3c92508724bd2c8244ee4591c6b00b01657216f2 100644
|
||||
index 7eff4de2a491033d84a192c96af1fc2942845e37..e413e8e68d162d7296180bbe65ed73b29ffb11ac 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -633,6 +633,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -14,7 +14,7 @@ ThreadUnsafeRandom (Moonrise): 102,265,100 ns
|
||||
SimpleThreadUnsafeRandom (Moonrise): 97,054,600 ns
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 4070a6eb52f6097e38c2d85c231d39ea3785cf46..bb76dbf98979fdc725676c98dafe64ea941cb290 100644
|
||||
index 32005b9d01169c6ad391a66101fdf26edb02fabc..20388a43937a460f817c7186d2acbc0c1beee78c 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -150,7 +150,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -27,7 +27,7 @@ index 4070a6eb52f6097e38c2d85c231d39ea3785cf46..bb76dbf98979fdc725676c98dafe64ea
|
||||
final ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData chunkData = ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkHolder)((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)levelChunk).moonrise$getChunkAndHolder().holder())
|
||||
.moonrise$getRealChunkHolder().holderData;
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index 3c92508724bd2c8244ee4591c6b00b01657216f2..0290e1f0c45677d337f77a0c8269894b32a43ca9 100644
|
||||
index e413e8e68d162d7296180bbe65ed73b29ffb11ac..275b640f4536366152f59acf071dd4eba15696c8 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -902,7 +902,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
@@ -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 ca1d8c9ea018368cc85da46185aee71df8d48ce0..a307ee08f12cb21d17cfbaf969db7c46f10040fb 100644
|
||||
index a0886253c20099795a50d8f45db3f7a2b5273d4d..d29b0000d799db839bd0e0be8928b22369f854ac 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -988,12 +988,15 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -46,7 +46,7 @@ index 6c7edbbf3935c40ccb78bee680ea75431718b9bd..a1b4dc70d555cce5e06c0298736d8b89
|
||||
public String toString() {
|
||||
return "Reference{" + this.key + "=" + this.value + "}";
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 970420761b2c3b82a60479c556e76e385bf211e1..4d88aa70c01e03baf8aea897b00f335c7be91f46 100644
|
||||
index 18dfaa60da8de12aea95cda21ee55636bf66f487..7f23b2fdf69d25b3f9a67f3ec945198602ca33fb 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1984,7 +1984,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -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 a307ee08f12cb21d17cfbaf969db7c46f10040fb..4f0da30fa659ecabdfbd1d17e50888c32501b6e7 100644
|
||||
index d29b0000d799db839bd0e0be8928b22369f854ac..f56d279cab4922136ebc95cb57f3803b1af3d9cc 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -211,6 +211,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Replace criterion map with optimized collection
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/PlayerAdvancements.java b/net/minecraft/server/PlayerAdvancements.java
|
||||
index e4ea26ae84efde7ce54e08a246a6ea2ae2a17151..ddd1eac136fc3327aea8286769efd2d7309f67ec 100644
|
||||
index 0a4bcc4c44fed2ededafaf0641315e072b7ba771..d2159a747fe42aa95cfc6bca0e55e3f4485847bb 100644
|
||||
--- a/net/minecraft/server/PlayerAdvancements.java
|
||||
+++ b/net/minecraft/server/PlayerAdvancements.java
|
||||
@@ -60,7 +60,7 @@ public class PlayerAdvancements {
|
||||
@@ -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 24aca7ba2cc3ec5f05bb4ea7d373feb730d8dd90..c30e017e6cffa6aa828b0f6e8889885dbaaa4680 100644
|
||||
index 4c39a5d0ee3bf532fd536884232df542154e8a48..327b3bc89920c4ab02c1126dc63bca05ce3abefe 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -330,17 +330,12 @@ public class ServerGamePacketListenerImpl
|
||||
@@ -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 4f0da30fa659ecabdfbd1d17e50888c32501b6e7..f744c9dca670cbbcc7549be17bf51eb683dd1ae0 100644
|
||||
index f56d279cab4922136ebc95cb57f3803b1af3d9cc..d502325d693539842fd6f5485365e0e9b786b7aa 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1998,6 +1998,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -8,7 +8,7 @@ Original project: https://github.com/PaperMC/Paper
|
||||
Paper pull request: https://github.com/PaperMC/Paper/pull/10990
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java
|
||||
index 8b3dfb1385a2252a4aaead5558c0ffbd5c204971..c32086ddf90fafcc55600f9e0724b9f915671482 100644
|
||||
index 73e88f96abee63bd8397575308baac018d12cf26..faf05f0c8f273bc723bbe54c70aebdd26c479a6b 100644
|
||||
--- a/net/minecraft/world/entity/Mob.java
|
||||
+++ b/net/minecraft/world/entity/Mob.java
|
||||
@@ -219,6 +219,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
@@ -9,7 +9,7 @@ Original license: MIT
|
||||
Original project: https://github.com/PurpurMC/Purpur
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
|
||||
index ddf2a5e2cfeaa666a081dd857d6a6003d65d0e00..d8298c7925e3bcea07ead4d438478cc51abcfa16 100644
|
||||
index 51b35808fcef8dd497d7ed6dc9d47940f2ddf88b..1dee20436fc29537319ee456756a8e8f7b6fe66a 100644
|
||||
--- a/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -199,6 +199,8 @@ public class ServerEntity {
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Don't spawn if lastSpawnState is null
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 6c031f6b1d9c762c8ce7c39a002f9f151347d3a1..6735f9e23c8972b7cf1438a2f3b49d780c1ff78c 100644
|
||||
index 20388a43937a460f817c7186d2acbc0c1beee78c..0fd51020ca9480be2855eb58a7d4d43511829512 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -661,7 +661,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -8,7 +8,7 @@ avoids multiple casting in Entity#distanceTo, using Math#sqrt directly instead o
|
||||
these methods more able to be inlined by the JIT compiler.
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 4d88aa70c01e03baf8aea897b00f335c7be91f46..4544dd876d3cbcdb9b774b4a1f0c4737f3124bc5 100644
|
||||
index 7f23b2fdf69d25b3f9a67f3ec945198602ca33fb..80ad278eac81aac72d6ec7737287ad018eff7c54 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -2194,31 +2194,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -12,7 +12,7 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index 0ac8b7bd9d899daf61aeb58f80bdcebe87974d51..eb79e6984810410c646d7b1910694d7df75dccba 100644
|
||||
index a99527409e9aae6c8b321a5ed100b2645151087e..cbd68d1d5b92e426062776658a6bf525553ecb1b 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2739,6 +2739,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
@@ -11,7 +11,7 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
||||
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/core/Direction.java b/net/minecraft/core/Direction.java
|
||||
index 216f97207dac88cc1dc3df59c6ee8a62c7614b4a..3a76b1ec8570e4c9f328e9d362b41057b092be45 100644
|
||||
index e5738ed10b58cf00e58c7b210be7fea3c09f2a02..1ed78ac66ae766262131921f03af2bf1b9d0eff0 100644
|
||||
--- a/net/minecraft/core/Direction.java
|
||||
+++ b/net/minecraft/core/Direction.java
|
||||
@@ -217,7 +217,7 @@ public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.pa
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Replace brain activity maps with optimized collection
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java
|
||||
index 0f50db187e04582e9b66a63201af987f6db74939..b143cd6d5636dc61458a864cd548c886d14cd30c 100644
|
||||
index 10986e50bd3307f81074c4cb371eb4d7defc9cfc..636a945ce2a91b8bf73b790e0e9e412368b3fe71 100644
|
||||
--- a/net/minecraft/world/entity/ai/Brain.java
|
||||
+++ b/net/minecraft/world/entity/ai/Brain.java
|
||||
@@ -390,8 +390,8 @@ public class Brain<E extends LivingEntity> {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user