aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0367-Backport-the-dupe-uuid-and-entity-log-changes.patch
blob: ded65a7d5417bb3b83f35e00ebdc20be8f1003ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
From 11cf0fdfd5befaac8c2e5fbdb29a834a1dc69d1f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 12 Oct 2018 01:37:54 -0400
Subject: [PATCH] Backport the dupe uuid and entity log changes


diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index ed14753512..ba299afc40 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -543,7 +543,7 @@ public class PaperWorldConfig {
     }
 
     public enum DuplicateUUIDMode {
-        SAFE_REGEN, REGEN, DELETE, NOTHING, WARN
+        SAFE_REGEN, DELETE, NOTHING, WARN
     }
     public DuplicateUUIDMode duplicateUUIDMode = DuplicateUUIDMode.SAFE_REGEN;
     public int duplicateUUIDDeleteRange = 32;
@@ -553,13 +553,10 @@ public class PaperWorldConfig {
         switch (desiredMode.toLowerCase()) {
             case "saferegen":
             case "saferegenerate":
-                duplicateUUIDMode = DuplicateUUIDMode.SAFE_REGEN;
-                log("Duplicate UUID Resolve: Safer Regenerate New UUID (Delete likely duplicates within " + duplicateUUIDDeleteRange + " blocks)");
-                break;
             case "regen":
             case "regenerate":
-                duplicateUUIDMode = DuplicateUUIDMode.REGEN;
-                log("Duplicate UUID Resolve: Regenerate New UUID");
+                duplicateUUIDMode = DuplicateUUIDMode.SAFE_REGEN;
+                log("Duplicate UUID Resolve: Safer Regenerate New UUID (Delete likely duplicates within " + duplicateUUIDDeleteRange + " blocks)");
                 break;
             case "remove":
             case "delete":
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 6541f5af47..00c46fe50f 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -888,7 +888,7 @@ public class Chunk {
             List entityslice = aentityslice[j]; // Spigot
             // Paper start
             DuplicateUUIDMode mode = world.paperConfig.duplicateUUIDMode;
-            if (mode == DuplicateUUIDMode.WARN || mode == DuplicateUUIDMode.DELETE || mode == DuplicateUUIDMode.REGEN || mode == DuplicateUUIDMode.SAFE_REGEN) {
+            if (mode == DuplicateUUIDMode.WARN || mode == DuplicateUUIDMode.DELETE || mode == DuplicateUUIDMode.SAFE_REGEN) {
                 Map<UUID, Entity> thisChunk = new HashMap<>();
                 for (Iterator<Entity> iterator = ((List<Entity>) entityslice).iterator(); iterator.hasNext(); ) {
                     Entity entity = iterator.next();
@@ -903,27 +903,26 @@ public class Chunk {
                         && java.util.Objects.equals(other.getSaveID(), entity.getSaveID())
                         && entity.getBukkitEntity().getLocation().distance(other.getBukkitEntity().getLocation()) < world.paperConfig.duplicateUUIDDeleteRange
                     ) {
-                        logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", deleted entity " + entity + " because it was near the duplicate and likely an actual duplicate. See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about.");
+                        if (World.DEBUG_ENTITIES) logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", deleted entity " + entity + " because it was near the duplicate and likely an actual duplicate. See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about.");
                         entity.die();
                         iterator.remove();
                         continue;
                     }
                     if (other != null && !other.dead) {
                         switch (mode) {
-                            case SAFE_REGEN:
-                            case REGEN: {
+                            case SAFE_REGEN: {
                                 entity.setUUID(UUID.randomUUID());
-                                logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", regenerated UUID for " + entity + ". See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about.");
+                                if (World.DEBUG_ENTITIES) logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", regenerated UUID for " + entity + ". See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about.");
                                 break;
                             }
                             case DELETE: {
-                                logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", deleted entity " + entity + ". See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about.");
+                                if (World.DEBUG_ENTITIES) logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", deleted entity " + entity + ". See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about.");
                                 entity.die();
                                 iterator.remove();
                                 break;
                             }
                             default:
-                                logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", doing nothing to " + entity + ". See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about.");
+                                if (World.DEBUG_ENTITIES) logger.warn("[DUPE-UUID] Duplicate UUID found used by " + other + ", doing nothing to " + entity + ". See https://github.com/PaperMC/Paper/issues/1223 for discussion on what this is about.");
                                 break;
                         }
                     }
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index bcbdadbd3a..7633a61342 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -45,6 +45,7 @@ public abstract class World implements IBlockAccess {
     private int a = 63;
     protected boolean d;
     // Spigot start - guard entity list from removals
+    public static final boolean DEBUG_ENTITIES = Boolean.getBoolean("debug.entities"); // Paper
     public final List<Entity> entityList = new java.util.ArrayList<Entity>()
     {
         @Override
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index b19942e0f1..d29420dd49 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -54,7 +54,6 @@ public class WorldServer extends World implements IAsyncTaskHandler {
     private final List<NextTickListEntry> W = Lists.newArrayList();
 
     // CraftBukkit start
-    private static final boolean DEBUG_ENTITIES = Boolean.getBoolean("debug.entities"); // Paper
     private static Throwable getAddToWorldStackTrace(Entity entity) {
         return new Throwable(entity + " Added to world at " + new Date());
     }
@@ -1164,8 +1163,10 @@ public class WorldServer extends World implements IAsyncTaskHandler {
 
     private boolean j(Entity entity) {
         if (entity.dead) {
-            WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.a(entity)); // CraftBukkit // Paper
-            if (DEBUG_ENTITIES) getAddToWorldStackTrace(entity).printStackTrace();
+            if (DEBUG_ENTITIES) {
+                WorldServer.a.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.a(entity)); // CraftBukkit // Paper
+                getAddToWorldStackTrace(entity).printStackTrace();
+            }
             return false;
         } else {
             UUID uuid = entity.getUniqueID();
@@ -1178,9 +1179,10 @@ public class WorldServer extends World implements IAsyncTaskHandler {
                 } else {
                     if (!(entity instanceof EntityHuman)) {
                         if (entity.world.paperConfig.duplicateUUIDMode != com.destroystokyo.paper.PaperWorldConfig.DuplicateUUIDMode.NOTHING) {
-                            WorldServer.a.error("Keeping entity {} that already exists with UUID {}", entity1, uuid.toString()); // CraftBukkit // Paper
-                            WorldServer.a.error("Duplicate entity {} will not be added to the world. See paper.yml duplicate-uuid-resolver and set this to either regen, delete or nothing to get rid of this message", entity); // Paper
                             if (DEBUG_ENTITIES) {
+                                WorldServer.a.error("Keeping entity {} that already exists with UUID {}", entity1, uuid.toString()); // CraftBukkit // Paper
+                                WorldServer.a.error("Duplicate entity {} will not be added to the world. See paper.yml duplicate-uuid-resolver and set this to either regen, delete or nothing to get rid of this message", entity); // Paper
+
                                 if (entity1.addedToWorldStack != null) {
                                     entity1.addedToWorldStack.printStackTrace();
                                 }
@@ -1211,8 +1213,8 @@ public class WorldServer extends World implements IAsyncTaskHandler {
         Entity old = this.entitiesByUUID.put(entity.getUniqueID(), entity);
         if (old != null && old.getId() != entity.getId() && old.valid && entity.world.paperConfig.duplicateUUIDMode != com.destroystokyo.paper.PaperWorldConfig.DuplicateUUIDMode.NOTHING) {
             Logger logger = LogManager.getLogger();
-            logger.error("Overwrote an existing entity " + old + " with " + entity);
             if (DEBUG_ENTITIES) {
+                logger.error("Overwrote an existing entity " + old + " with " + entity);
                 if (old.addedToWorldStack != null) {
                     old.addedToWorldStack.printStackTrace();
                 } else {
-- 
2.19.1