Scissors/patches/server/0040-Prevent-player-banning-using-duplicate-UUIDs.patch
2023-10-19 02:03:56 -05:00

26 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 28 Apr 2023 16:44:50 -0300
Subject: [PATCH] Prevent player banning using duplicate UUIDs
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 3f26fdcc5cbf0a684ad724ab8c042d0053cc187e..c6f36a6b967aeb6ffdf5b099b2692e038401dc79 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1664,7 +1664,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (entity != null) {
ServerLevel.LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID());
entity.unRide();
- this.removePlayerImmediately((ServerPlayer) entity, Entity.RemovalReason.DISCARDED);
+ // Scissors start - Prevent player banning using duplicate UUIDs
+ if (entity instanceof ServerPlayer serverPlayer) {
+ this.removePlayerImmediately(serverPlayer, Entity.RemovalReason.DISCARDED);
+ } else {
+ entity.discard();
+ }
+ // Scissors end
}
this.entityLookup.addNewEntity(player); // Paper - rewite chunk system