Scissors/patches/server/0051-Prevent-player-banning-using-duplicate-UUIDs.patch

27 lines
1.3 KiB
Diff
Raw Normal View History

2023-04-28 21:36:42 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 28 Apr 2023 18:25:56 -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 a002713686e66faf0d18662586a7a236c27ca7d2..795d72084ff196c5f4a0ff4bafd3ac88257fc379 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1354,7 +1354,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (entity != null) {
ServerLevel.LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID().toString());
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.entityManager.addNewEntity(player); // CraftBukkit - decompile error