mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Fix
This commit is contained in:
@@ -5,10 +5,10 @@ Subject: [PATCH] Cache player profileResult
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||||
index 069477e524a28b20a0289221858bdc802704a890..c25f5b92b16f45b960d9b405b2fe1c40ec4e1124 100644
|
index 069477e524a28b20a0289221858bdc802704a890..114b25f933c6a1b011523581a5a02a5a2c1e827e 100644
|
||||||
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||||
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||||
@@ -71,6 +71,12 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
@@ -71,6 +71,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||||
private net.minecraft.server.level.ServerPlayer player; // CraftBukkit
|
private net.minecraft.server.level.ServerPlayer player; // CraftBukkit
|
||||||
public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding
|
public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding
|
||||||
private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support
|
private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support
|
||||||
@@ -16,12 +16,14 @@ index 069477e524a28b20a0289221858bdc802704a890..c25f5b92b16f45b960d9b405b2fe1c40
|
|||||||
+ private static final com.github.benmanes.caffeine.cache.Cache<String, ProfileResult> playerProfileResultCache = com.github.benmanes.caffeine.cache.Caffeine.newBuilder()
|
+ 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)
|
+ .expireAfterWrite(org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResultTimeout, java.util.concurrent.TimeUnit.MINUTES)
|
||||||
+ .build();
|
+ .build();
|
||||||
+ public static final java.util.Map<String, InetAddress> playerSession = new java.util.concurrent.ConcurrentHashMap<>();
|
+ 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
|
+ // Leaf end - Cache player profileResult
|
||||||
|
|
||||||
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) {
|
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
@@ -304,9 +310,30 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
@@ -304,9 +312,30 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||||
String string1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized");
|
String string1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -34,14 +36,14 @@ index 069477e524a28b20a0289221858bdc802704a890..c25f5b92b16f45b960d9b405b2fe1c40
|
|||||||
+ profileResult = playerProfileResultCache.getIfPresent(string1);
|
+ profileResult = playerProfileResultCache.getIfPresent(string1);
|
||||||
+
|
+
|
||||||
+ InetAddress address = this.getAddress();
|
+ InetAddress address = this.getAddress();
|
||||||
+ InetAddress lastAddress = playerSession.get(string1);
|
+ InetAddress lastAddress = playerSession.getIfPresent(string1);
|
||||||
+ if (isInvalidSession(address, lastAddress)) {
|
+ if (isInvalidSession(address, lastAddress)) {
|
||||||
+ // Send request to mojang server to verify session
|
+ // Send request to mojang server to verify session
|
||||||
+ // Result will be null if is invalid and will do disconnect logic below
|
+ // Result will be null if is invalid and will do disconnect logic below
|
||||||
+ profileResult = ServerLoginPacketListenerImpl.this.server
|
+ profileResult = ServerLoginPacketListenerImpl.this.server
|
||||||
+ .getSessionService()
|
+ .getSessionService()
|
||||||
+ .hasJoinedServer(string1, string, address);
|
+ .hasJoinedServer(string1, string, address);
|
||||||
+ if (profileResult != null) {
|
+ if (profileResult != null && address != null) {
|
||||||
+ playerProfileResultCache.put(string1, profileResult);
|
+ playerProfileResultCache.put(string1, profileResult);
|
||||||
+ playerSession.put(string1, address);
|
+ playerSession.put(string1, address);
|
||||||
+ }
|
+ }
|
||||||
@@ -55,7 +57,7 @@ index 069477e524a28b20a0289221858bdc802704a890..c25f5b92b16f45b960d9b405b2fe1c40
|
|||||||
if (profileResult != null) {
|
if (profileResult != null) {
|
||||||
GameProfile gameProfile = profileResult.profile();
|
GameProfile gameProfile = profileResult.profile();
|
||||||
// CraftBukkit start - fire PlayerPreLoginEvent
|
// CraftBukkit start - fire PlayerPreLoginEvent
|
||||||
@@ -351,6 +378,20 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
@@ -351,6 +380,20 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||||
// Paper end - Cache authenticator threads
|
// Paper end - Cache authenticator threads
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,15 +78,3 @@ index 069477e524a28b20a0289221858bdc802704a890..c25f5b92b16f45b960d9b405b2fe1c40
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
private GameProfile callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception { // Paper - Add more fields to AsyncPlayerPreLoginEvent
|
private GameProfile callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception { // Paper - Add more fields to AsyncPlayerPreLoginEvent
|
||||||
// Paper start - Add Velocity IP Forwarding Support
|
// Paper start - Add Velocity IP Forwarding Support
|
||||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
|
||||||
index e8683f45823cac55e3e68ccc500f10f0632e72fd..f71debc88c1d16c09546c026817aa192faac8fc6 100644
|
|
||||||
--- a/net/minecraft/server/players/PlayerList.java
|
|
||||||
+++ b/net/minecraft/server/players/PlayerList.java
|
|
||||||
@@ -669,6 +669,7 @@ public abstract class PlayerList {
|
|
||||||
// Paper end - Fix kick event leave message not being sent
|
|
||||||
org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar
|
|
||||||
net.minecraft.server.network.ServerGamePacketListenerImpl.afkCooldown.remove(player.getBukkitEntity().getUniqueId()); // Leaf - Improve Purpur AFK system
|
|
||||||
+ net.minecraft.server.network.ServerLoginPacketListenerImpl.playerSession.remove(player.getBukkitEntity().getName()); // Leaf - Cache player profileResult
|
|
||||||
ServerLevel serverLevel = player.serverLevel();
|
|
||||||
player.awardStat(Stats.LEAVE_GAME);
|
|
||||||
// CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Configurable connection message
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||||
index f71debc88c1d16c09546c026817aa192faac8fc6..4fa7952c30408e898cc2e3ce41d5b0f44f19ae31 100644
|
index e8683f45823cac55e3e68ccc500f10f0632e72fd..5c88d51920481235145bb7fd8cf148607b2dbed0 100644
|
||||||
--- a/net/minecraft/server/players/PlayerList.java
|
--- a/net/minecraft/server/players/PlayerList.java
|
||||||
+++ b/net/minecraft/server/players/PlayerList.java
|
+++ b/net/minecraft/server/players/PlayerList.java
|
||||||
@@ -434,7 +434,7 @@ public abstract class PlayerList {
|
@@ -434,7 +434,7 @@ public abstract class PlayerList {
|
||||||
@@ -26,7 +26,7 @@ index f71debc88c1d16c09546c026817aa192faac8fc6..4fa7952c30408e898cc2e3ce41d5b0f4
|
|||||||
joinMessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(jm); // Paper - Adventure
|
joinMessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(jm); // Paper - Adventure
|
||||||
this.server.getPlayerList().broadcastSystemMessage(joinMessage, false); // Paper - Adventure
|
this.server.getPlayerList().broadcastSystemMessage(joinMessage, false); // Paper - Adventure
|
||||||
}
|
}
|
||||||
@@ -678,7 +678,7 @@ public abstract class PlayerList {
|
@@ -677,7 +677,7 @@ public abstract class PlayerList {
|
||||||
player.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason
|
player.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ index f71debc88c1d16c09546c026817aa192faac8fc6..4fa7952c30408e898cc2e3ce41d5b0f4
|
|||||||
this.cserver.getPluginManager().callEvent(playerQuitEvent);
|
this.cserver.getPluginManager().callEvent(playerQuitEvent);
|
||||||
player.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
player.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||||
|
|
||||||
@@ -1674,4 +1674,38 @@ public abstract class PlayerList {
|
@@ -1673,4 +1673,38 @@ public abstract class PlayerList {
|
||||||
public boolean isAllowCommandsForAllPlayers() {
|
public boolean isAllowCommandsForAllPlayers() {
|
||||||
return this.allowCommandsForAllPlayers;
|
return this.allowCommandsForAllPlayers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Subject: [PATCH] Do not place player if the server is full
|
|||||||
Fix https://github.com/PaperMC/Paper/issues/10668
|
Fix https://github.com/PaperMC/Paper/issues/10668
|
||||||
|
|
||||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||||
index 4fa7952c30408e898cc2e3ce41d5b0f44f19ae31..6be59ddf2584455de0955b34d8ba1a053103f684 100644
|
index 5c88d51920481235145bb7fd8cf148607b2dbed0..75fb49f1596f475278d12c8c7aea9ad4952b6056 100644
|
||||||
--- a/net/minecraft/server/players/PlayerList.java
|
--- a/net/minecraft/server/players/PlayerList.java
|
||||||
+++ b/net/minecraft/server/players/PlayerList.java
|
+++ b/net/minecraft/server/players/PlayerList.java
|
||||||
@@ -341,6 +341,13 @@ public abstract class PlayerList {
|
@@ -341,6 +341,13 @@ public abstract class PlayerList {
|
||||||
@@ -23,7 +23,7 @@ index 4fa7952c30408e898cc2e3ce41d5b0f44f19ae31..6be59ddf2584455de0955b34d8ba1a05
|
|||||||
|
|
||||||
org.bukkit.Location loc = ev.getSpawnLocation();
|
org.bukkit.Location loc = ev.getSpawnLocation();
|
||||||
serverLevel = ((org.bukkit.craftbukkit.CraftWorld) loc.getWorld()).getHandle();
|
serverLevel = ((org.bukkit.craftbukkit.CraftWorld) loc.getWorld()).getHandle();
|
||||||
@@ -836,7 +843,7 @@ public abstract class PlayerList {
|
@@ -835,7 +842,7 @@ public abstract class PlayerList {
|
||||||
// return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameProfile)
|
// return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameProfile)
|
||||||
// ? Component.translatable("multiplayer.disconnect.server_full")
|
// ? Component.translatable("multiplayer.disconnect.server_full")
|
||||||
// : null;
|
// : null;
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ index 4f01b53bf801f99253efd27df6216912705d18af..82a1715fea41e6a41c4ff441ea89f424
|
|||||||
level.addDuringTeleport(this);
|
level.addDuringTeleport(this);
|
||||||
this.triggerDimensionChangeTriggers(serverLevel);
|
this.triggerDimensionChangeTriggers(serverLevel);
|
||||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||||
index 6be59ddf2584455de0955b34d8ba1a053103f684..66cb015de63949ca5add9dc3456db9c638b78048 100644
|
index 75fb49f1596f475278d12c8c7aea9ad4952b6056..b17c8a2f5294ac28cc05fb05c84a041b2c6c8721 100644
|
||||||
--- a/net/minecraft/server/players/PlayerList.java
|
--- a/net/minecraft/server/players/PlayerList.java
|
||||||
+++ b/net/minecraft/server/players/PlayerList.java
|
+++ b/net/minecraft/server/players/PlayerList.java
|
||||||
@@ -956,11 +956,11 @@ public abstract class PlayerList {
|
@@ -955,11 +955,11 @@ public abstract class PlayerList {
|
||||||
byte b = (byte)(keepInventory ? 1 : 0);
|
byte b = (byte)(keepInventory ? 1 : 0);
|
||||||
ServerLevel serverLevel = serverPlayer.serverLevel();
|
ServerLevel serverLevel = serverPlayer.serverLevel();
|
||||||
LevelData levelData = serverLevel.getLevelData();
|
LevelData levelData = serverLevel.getLevelData();
|
||||||
|
|||||||
@@ -867,7 +867,7 @@ index 8362def0dc61496a087bd859052bd80ebba83185..09f517059aa47ca67329bc913243d4fd
|
|||||||
// Paper end - Inventory close reason
|
// Paper end - Inventory close reason
|
||||||
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
|
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
|
||||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||||
index 66cb015de63949ca5add9dc3456db9c638b78048..1009421bfd289734b50a528bfca8d957e4610159 100644
|
index b17c8a2f5294ac28cc05fb05c84a041b2c6c8721..3591de34443069f3f163f8d17df6372c3068611d 100644
|
||||||
--- a/net/minecraft/server/players/PlayerList.java
|
--- a/net/minecraft/server/players/PlayerList.java
|
||||||
+++ b/net/minecraft/server/players/PlayerList.java
|
+++ b/net/minecraft/server/players/PlayerList.java
|
||||||
@@ -252,6 +252,8 @@ public abstract class PlayerList {
|
@@ -252,6 +252,8 @@ public abstract class PlayerList {
|
||||||
@@ -879,7 +879,7 @@ index 66cb015de63949ca5add9dc3456db9c638b78048..1009421bfd289734b50a528bfca8d957
|
|||||||
player.isRealPlayer = true; // Paper
|
player.isRealPlayer = true; // Paper
|
||||||
player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed
|
player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed
|
||||||
GameProfile gameProfile = player.getGameProfile();
|
GameProfile gameProfile = player.getGameProfile();
|
||||||
@@ -892,6 +894,15 @@ public abstract class PlayerList {
|
@@ -891,6 +893,15 @@ public abstract class PlayerList {
|
||||||
return this.respawn(player, keepInventory, reason, eventReason, null);
|
return this.respawn(player, keepInventory, reason, eventReason, null);
|
||||||
}
|
}
|
||||||
public ServerPlayer respawn(ServerPlayer player, boolean keepInventory, Entity.RemovalReason reason, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason eventReason, org.bukkit.Location location) {
|
public ServerPlayer respawn(ServerPlayer player, boolean keepInventory, Entity.RemovalReason reason, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason eventReason, org.bukkit.Location location) {
|
||||||
@@ -895,7 +895,7 @@ index 66cb015de63949ca5add9dc3456db9c638b78048..1009421bfd289734b50a528bfca8d957
|
|||||||
player.stopRiding(); // CraftBukkit
|
player.stopRiding(); // CraftBukkit
|
||||||
this.players.remove(player);
|
this.players.remove(player);
|
||||||
this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot
|
this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot
|
||||||
@@ -903,6 +914,7 @@ public abstract class PlayerList {
|
@@ -902,6 +913,7 @@ public abstract class PlayerList {
|
||||||
ServerPlayer serverPlayer = player;
|
ServerPlayer serverPlayer = player;
|
||||||
Level fromWorld = player.level();
|
Level fromWorld = player.level();
|
||||||
player.wonGame = false;
|
player.wonGame = false;
|
||||||
|
|||||||
@@ -118,10 +118,10 @@ index 2e9eb04c7c4342393c05339906c267bca9ff29b1..53b9daa909c2b89046d5af515e17afe0
|
|||||||
try {
|
try {
|
||||||
PlayerList playerList = this.server.getPlayerList();
|
PlayerList playerList = this.server.getPlayerList();
|
||||||
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||||
index c25f5b92b16f45b960d9b405b2fe1c40ec4e1124..005fee891cdabc7105033be051389557631fb6d2 100644
|
index 114b25f933c6a1b011523581a5a02a5a2c1e827e..5907f1c75002be5e2ef1f9875974e665f964db7a 100644
|
||||||
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||||
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||||
@@ -492,11 +492,31 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
@@ -494,11 +494,31 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||||
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
this.disconnect(ServerCommonPacketListenerImpl.DISCONNECT_UNEXPECTED_QUERY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user