mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 18:45:54 +01:00
[CI-SKIP] Delete handled removed patches
This commit is contained in:
parent
729551d7e0
commit
eee4bcaec2
@ -1,234 +0,0 @@
|
||||
From e82072ef380eb0d17fb93cee8bf8275fb11f29de Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 19 Sep 2016 23:16:39 -0400
|
||||
Subject: [PATCH] Auto Save Improvements
|
||||
|
||||
Makes Auto Save Rate setting configurable per-world. If the auto save rate is left -1, the global bukkit.yml value will be used.
|
||||
|
||||
Process auto save every tick instead of once per auto tick interval, so that chunk saves will distribute over many ticks instead of all at once.
|
||||
|
||||
Re-introduce a cap per tick for auto save (Spigot disabled the vanilla cap) and make it configurable.
|
||||
|
||||
Adds incremental player auto saving too
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
index fb7ada8139..17b4e01aa4 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -269,4 +269,15 @@ public class PaperConfig {
|
||||
flyingKickPlayerMessage = getString("messages.kick.flying-player", flyingKickPlayerMessage);
|
||||
flyingKickVehicleMessage = getString("messages.kick.flying-vehicle", flyingKickVehicleMessage);
|
||||
}
|
||||
+
|
||||
+ public static int playerAutoSaveRate = -1;
|
||||
+ public static int maxPlayerAutoSavePerTick = 10;
|
||||
+ private static void playerAutoSaveRate() {
|
||||
+ playerAutoSaveRate = getInt("settings.player-auto-save-rate", -1);
|
||||
+ maxPlayerAutoSavePerTick = getInt("settings.max-player-auto-save-per-tick", -1);
|
||||
+ if (maxPlayerAutoSavePerTick == -1) { // -1 Automatic / "Recommended"
|
||||
+ // 10 should be safe for everyone unless your mass spamming player auto save
|
||||
+ maxPlayerAutoSavePerTick = (playerAutoSaveRate == -1 || playerAutoSaveRate > 100) ? 10 : 20;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index c70771614d..6e28410c37 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -2,6 +2,7 @@ package com.destroystokyo.paper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.spigotmc.SpigotWorldConfig;
|
||||
|
||||
@@ -324,4 +325,19 @@ public class PaperWorldConfig {
|
||||
private void skipEntityTickingInChunksScheduledForUnload() {
|
||||
skipEntityTickingInChunksScheduledForUnload = getBoolean("skip-entity-ticking-in-chunks-scheduled-for-unload", skipEntityTickingInChunksScheduledForUnload);
|
||||
}
|
||||
+
|
||||
+ public int autoSavePeriod = -1;
|
||||
+ private void autoSavePeriod() {
|
||||
+ autoSavePeriod = getInt("auto-save-interval", -1);
|
||||
+ if (autoSavePeriod > 0) {
|
||||
+ log("Auto Save Interval: " +autoSavePeriod + " (" + (autoSavePeriod / 20) + "s)");
|
||||
+ } else if (autoSavePeriod < 0) {
|
||||
+ autoSavePeriod = MinecraftServer.getServer().autosavePeriod;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public int maxAutoSaveChunksPerTick = 24;
|
||||
+ private void maxAutoSaveChunksPerTick() {
|
||||
+ maxAutoSaveChunksPerTick = getInt("max-auto-save-chunks-per-tick", 24);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index bdf922db50..0bf614ce57 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -53,9 +53,9 @@ public class Chunk implements IChunkAccess {
|
||||
private final TickList<Block> s;
|
||||
private final TickList<FluidType> t;
|
||||
private boolean u;
|
||||
- private boolean v;
|
||||
+ private boolean v;public boolean hasEntities() { return v; } // Paper - OBFHELPER
|
||||
private long lastSaved;
|
||||
- private boolean x;
|
||||
+ private boolean x; public boolean isModified() { return x; } // Paper - OBFHELPER
|
||||
private int y;
|
||||
private long z;
|
||||
private int A;
|
||||
@@ -1071,11 +1071,11 @@ public class Chunk implements IChunkAccess {
|
||||
if (this.v && this.world.getTime() != this.lastSaved || this.x) {
|
||||
return true;
|
||||
}
|
||||
- } else if (this.v && this.world.getTime() >= this.lastSaved + MinecraftServer.getServer().autosavePeriod * 4) { // Spigot - Only save if we've passed 2 auto save intervals without modification
|
||||
- return true;
|
||||
}
|
||||
-
|
||||
- return this.x;
|
||||
+ // Paper start - Make world configurable and incremental
|
||||
+ // This !flag section should say if isModified or hasEntities, then check auto save
|
||||
+ return ((isModified() || hasEntities()) && this.world.getTime() >= this.lastSaved + world.paperConfig.autoSavePeriod);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
index d0bf0f72da..fbc69b5ba5 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
|
||||
@@ -243,7 +243,7 @@ public class ChunkProviderServer implements IChunkProvider {
|
||||
this.saveChunk(chunk, false); // Spigot
|
||||
chunk.a(false);
|
||||
++i;
|
||||
- if (i == 24 && !flag && false) { // Spigot
|
||||
+ if (!flag && i >= world.paperConfig.maxAutoSaveChunksPerTick) { // Spigot - // Paper - Incremental Auto Save - cap max
|
||||
return false;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
index 621e79bc53..260fa3e678 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
||||
@@ -34,6 +34,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
private static final Logger cc = LogManager.getLogger();
|
||||
public String locale = null; // CraftBukkit - lowercase // Paper - default to null
|
||||
+ public long lastSave = MinecraftServer.currentTick; // Paper
|
||||
public PlayerConnection playerConnection;
|
||||
public final MinecraftServer server;
|
||||
public final PlayerInteractManager playerInteractManager;
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 7ffb061414..6283c774d6 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -143,6 +143,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
||||
public org.bukkit.command.RemoteConsoleCommandSender remoteConsole;
|
||||
public ConsoleReader reader;
|
||||
public static int currentTick = 0; // Paper - Further improve tick loop
|
||||
+ public boolean serverAutoSave = false; // Paper
|
||||
public final Thread primaryThread;
|
||||
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
||||
public int autosavePeriod;
|
||||
@@ -938,22 +939,30 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
|
||||
this.m.b().a(agameprofile);
|
||||
}
|
||||
|
||||
- if (autosavePeriod > 0 && this.ticks % autosavePeriod == 0) { // CraftBukkit
|
||||
this.methodProfiler.enter("save");
|
||||
- this.playerList.savePlayers();
|
||||
+
|
||||
+ serverAutoSave = (autosavePeriod > 0 && this.ticks % autosavePeriod == 0); // Paper
|
||||
+ int playerSaveInterval = com.destroystokyo.paper.PaperConfig.playerAutoSaveRate;
|
||||
+ if (playerSaveInterval < 0) {
|
||||
+ playerSaveInterval = autosavePeriod;
|
||||
+ }
|
||||
+ if (playerSaveInterval > 0) { // CraftBukkit // Paper
|
||||
+ this.playerList.savePlayers(playerSaveInterval);
|
||||
// Spigot Start
|
||||
+ } // Paper - Incremental Auto Saving
|
||||
+
|
||||
// We replace this with saving each individual world as this.saveChunks(...) is broken,
|
||||
// and causes the main thread to sleep for random amounts of time depending on chunk activity
|
||||
// Also pass flag to only save modified chunks
|
||||
server.playerCommandState = true;
|
||||
for (World world : getWorlds()) {
|
||||
- world.getWorld().save(false);
|
||||
+ if (world.paperConfig.autoSavePeriod > 0) world.getWorld().save(false); // Paper - Incremental / Configurable Auto Saving
|
||||
}
|
||||
server.playerCommandState = false;
|
||||
// this.saveChunks(true);
|
||||
// Spigot End
|
||||
this.methodProfiler.exit();
|
||||
- }
|
||||
+ //} // Paper - Incremental Auto Saving
|
||||
|
||||
this.methodProfiler.enter("snooper");
|
||||
if (getSnooperEnabled() && !this.snooper.d() && this.ticks > 100) { // Spigot
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
index 79641a73a8..fe6649224a 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
||||
@@ -341,6 +341,7 @@ public abstract class PlayerList {
|
||||
|
||||
protected void savePlayerFile(EntityPlayer entityplayer) {
|
||||
if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit
|
||||
+ entityplayer.lastSave = MinecraftServer.currentTick; // Paper
|
||||
this.playerFileData.save(entityplayer);
|
||||
ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit
|
||||
|
||||
@@ -1207,13 +1208,25 @@ public abstract class PlayerList {
|
||||
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
public void savePlayers() {
|
||||
+ savePlayers(null);
|
||||
+ }
|
||||
+
|
||||
+ public void savePlayers(Integer interval) {
|
||||
+ long now = MinecraftServer.currentTick;
|
||||
MinecraftTimings.savePlayers.startTiming(); // Paper
|
||||
+ int numSaved = 0; // Paper
|
||||
for (int i = 0; i < this.players.size(); ++i) {
|
||||
- this.savePlayerFile((EntityPlayer) this.players.get(i));
|
||||
+ EntityPlayer entityplayer = this.players.get(i);
|
||||
+ if (interval == null || now - entityplayer.lastSave >= interval) {
|
||||
+ this.savePlayerFile(entityplayer);
|
||||
+ if (interval != null && ++numSaved <= com.destroystokyo.paper.PaperConfig.maxPlayerAutoSavePerTick) { break; } // Paper
|
||||
+ }
|
||||
}
|
||||
MinecraftTimings.savePlayers.stopTiming(); // Paper
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
public WhiteList getWhitelist() {
|
||||
return this.whitelist;
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 639068d2dc..49c5b0b5cc 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -855,8 +855,9 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkProvider();
|
||||
|
||||
if (chunkproviderserver.d()) {
|
||||
- org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit
|
||||
+ if (flag) org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit // Paper - Incremental Auto Saving - Only fire event on full save
|
||||
timings.worldSave.startTiming(); // Paper
|
||||
+ if (flag || server.serverAutoSave) { // Paper
|
||||
if (iprogressupdate != null) {
|
||||
iprogressupdate.a(new ChatMessage("menu.savingLevel", new Object[0]));
|
||||
}
|
||||
@@ -865,6 +866,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
if (iprogressupdate != null) {
|
||||
iprogressupdate.c(new ChatMessage("menu.savingChunks", new Object[0]));
|
||||
}
|
||||
+ } // Paper
|
||||
|
||||
timings.worldSaveChunks.startTiming(); // Paper
|
||||
chunkproviderserver.a(flag);
|
||||
--
|
||||
2.21.0
|
||||
|
@ -1,32 +0,0 @@
|
||||
From ee210a06121210a6975b810dbbbe28f8f98944d7 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 26 Sep 2016 01:51:30 -0400
|
||||
Subject: [PATCH] Disable Vanilla Chunk GC
|
||||
|
||||
Bukkit has its own system for this.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 49c5b0b5cc..15736f7575 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -872,6 +872,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
chunkproviderserver.a(flag);
|
||||
timings.worldSaveChunks.stopTiming(); // Paper
|
||||
// CraftBukkit - ArrayList -> Collection
|
||||
+ /* //Paper start - disable vanilla chunk GC
|
||||
java.util.Collection<Chunk> list = chunkproviderserver.a();
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
@@ -881,7 +882,8 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
if (chunk != null && !this.manager.a(chunk.locX, chunk.locZ)) {
|
||||
chunkproviderserver.unload(chunk);
|
||||
}
|
||||
- }
|
||||
+ }*/
|
||||
+ // Paper end
|
||||
timings.worldSave.stopTiming(); // Paper
|
||||
}
|
||||
}
|
||||
--
|
||||
2.21.0
|
||||
|
@ -1,223 +0,0 @@
|
||||
From d4952e11a8163210b2a750f4c22b03b57a118632 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 21 Jul 2018 14:27:34 -0400
|
||||
Subject: [PATCH] Duplicate UUID Resolve Option
|
||||
|
||||
Due to a bug in https://github.com/PaperMC/Paper/commit/2e29af3df05ec0a383f48be549d1c03200756d24
|
||||
which was added all the way back in March of 2016, it was unknown (potentially not at the time)
|
||||
that an entity might actually change the seed of the random object.
|
||||
|
||||
At some point, EntitySquid did start setting the seed. Due to this shared random, this caused
|
||||
every entity to use a Random object with a predictable seed.
|
||||
|
||||
This has caused entities to potentially generate with the same UUID....
|
||||
|
||||
Over the years, servers have had entities disappear, but no sign of trouble
|
||||
because CraftBukkit removed the log lines indicating that something was wrong.
|
||||
|
||||
We have fixed the root issue causing duplicate UUID's, however we now have chunk
|
||||
files full of entities that have the same UUID as another entity!
|
||||
|
||||
When these chunks load, the 2nd entity will not be added to the world correctly.
|
||||
|
||||
If that chunk loads in a different order in the future, then it will reverse and the
|
||||
missing one is now the one added to the world and not the other. This results in very
|
||||
inconsistent entity behavior.
|
||||
|
||||
This change allows you to recover any duplicate entity by generating a new UUID for it.
|
||||
This also lets you delete them instead if you don't want to risk having new entities added to
|
||||
the world that you previously did not see.
|
||||
|
||||
But for those who are ok with leaving this inconsistent behavior, you may use WARN or NOTHING options.
|
||||
|
||||
It is recommended you regenerate the entities, as these were legit entities, and deserve your love.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index f5b2e88f3b..8c4ff18868 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -463,4 +463,43 @@ public class PaperWorldConfig {
|
||||
log("Bed Search Radius: " + bedSearchRadius);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ public enum DuplicateUUIDMode {
|
||||
+ SAFE_REGEN, DELETE, NOTHING, WARN
|
||||
+ }
|
||||
+ public DuplicateUUIDMode duplicateUUIDMode = DuplicateUUIDMode.SAFE_REGEN;
|
||||
+ public int duplicateUUIDDeleteRange = 32;
|
||||
+ private void repairDuplicateUUID() {
|
||||
+ String desiredMode = getString("duplicate-uuid-resolver", "saferegen").toLowerCase().trim();
|
||||
+ duplicateUUIDDeleteRange = getInt("duplicate-uuid-saferegen-delete-range", duplicateUUIDDeleteRange);
|
||||
+ switch (desiredMode.toLowerCase()) {
|
||||
+ case "regen":
|
||||
+ case "regenerate":
|
||||
+ case "saferegen":
|
||||
+ case "saferegenerate":
|
||||
+ duplicateUUIDMode = DuplicateUUIDMode.SAFE_REGEN;
|
||||
+ log("Duplicate UUID Resolve: Regenerate New UUID if distant (Delete likely duplicates within " + duplicateUUIDDeleteRange + " blocks)");
|
||||
+ break;
|
||||
+ case "remove":
|
||||
+ case "delete":
|
||||
+ duplicateUUIDMode = DuplicateUUIDMode.DELETE;
|
||||
+ log("Duplicate UUID Resolve: Delete Entity");
|
||||
+ break;
|
||||
+ case "silent":
|
||||
+ case "nothing":
|
||||
+ duplicateUUIDMode = DuplicateUUIDMode.NOTHING;
|
||||
+ logError("Duplicate UUID Resolve: Do Nothing (no logs) - Warning, may lose indication of bad things happening");
|
||||
+ break;
|
||||
+ case "log":
|
||||
+ case "warn":
|
||||
+ duplicateUUIDMode = DuplicateUUIDMode.WARN;
|
||||
+ log("Duplicate UUID Resolve: Warn (do nothing but log it happened, may be spammy)");
|
||||
+ break;
|
||||
+ default:
|
||||
+ duplicateUUIDMode = DuplicateUUIDMode.WARN;
|
||||
+ logError("Warning: Invalid duplicate-uuid-resolver config " + desiredMode + " - must be one of: regen, delete, nothing, warn");
|
||||
+ log("Duplicate UUID Resolve: Warn (do nothing but log it happened, may be spammy)");
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index c2f12f92b0..e8c06e01b4 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -1,5 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// Paper start
|
||||
+import com.destroystokyo.paper.PaperWorldConfig.DuplicateUUIDMode;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.UUID;
|
||||
+// Paper end
|
||||
import com.destroystokyo.paper.exception.ServerInternalException;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Queues;
|
||||
@@ -41,6 +46,7 @@ public class Chunk implements IChunkAccess {
|
||||
public final World world;
|
||||
public final Map<HeightMap.Type, HeightMap> heightMap;
|
||||
public Long scheduledForUnload; // Paper - delay chunk unloads
|
||||
+ private static final Logger logger = LogManager.getLogger(); // Paper
|
||||
public final int locX;
|
||||
public final int locZ;
|
||||
private boolean l;
|
||||
@@ -691,6 +697,7 @@ public class Chunk implements IChunkAccess {
|
||||
if (i != this.locX || j != this.locZ) {
|
||||
Chunk.d.warn("Wrong location! ({}, {}) should be ({}, {}), {}", i, j, this.locX, this.locZ, entity);
|
||||
entity.die();
|
||||
+ return; // Paper
|
||||
}
|
||||
|
||||
int k = MathHelper.floor(entity.locY / 16.0D);
|
||||
@@ -879,6 +886,50 @@ public class Chunk implements IChunkAccess {
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
List<Entity> entityslice = aentityslice[j]; // Spigot
|
||||
+ // Paper start
|
||||
+ DuplicateUUIDMode mode = world.paperConfig.duplicateUUIDMode;
|
||||
+ 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();
|
||||
+ if (entity.dead || entity.valid) continue;
|
||||
+ Entity other = ((WorldServer) world).entitiesByUUID.get(entity.uniqueID);
|
||||
+ if (other == null || other.dead || world.getEntityUnloadQueue().contains(other)) {
|
||||
+ other = thisChunk.get(entity.uniqueID);
|
||||
+ }
|
||||
+
|
||||
+ if (mode == DuplicateUUIDMode.SAFE_REGEN && other != null && !other.dead &&
|
||||
+ !world.getEntityUnloadQueue().contains(other)
|
||||
+ && java.util.Objects.equals(other.getSaveID(), entity.getSaveID())
|
||||
+ && entity.getBukkitEntity().getLocation().distance(other.getBukkitEntity().getLocation()) < world.paperConfig.duplicateUUIDDeleteRange
|
||||
+ ) {
|
||||
+ 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: {
|
||||
+ entity.setUUID(UUID.randomUUID());
|
||||
+ 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: {
|
||||
+ 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:
|
||||
+ 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;
|
||||
+ }
|
||||
+ }
|
||||
+ thisChunk.put(entity.uniqueID, entity);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
// CraftBukkit start
|
||||
List<Entity> toRemove = new LinkedList<>();
|
||||
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
||||
index b6c46e01d9..6598b87eef 100644
|
||||
--- a/src/main/java/net/minecraft/server/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/server/Entity.java
|
||||
@@ -2739,6 +2739,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
||||
});
|
||||
}
|
||||
|
||||
+ public void setUUID(UUID uuid) { a(uuid); } // Paper - OBFHELPER
|
||||
public void a(UUID uuid) {
|
||||
this.uniqueID = uuid;
|
||||
this.au = this.uniqueID.toString();
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 1496125ddf..a5f4b9ad94 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -70,7 +70,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
||||
}
|
||||
};
|
||||
// Spigot end
|
||||
- protected final Set<Entity> g = com.google.common.collect.Sets.newHashSet(); // Paper
|
||||
+ protected final Set<Entity> g = com.google.common.collect.Sets.newHashSet(); public Set<Entity> getEntityUnloadQueue() { return g; };// Paper - OBFHELPER
|
||||
//public final List<TileEntity> tileEntityList = Lists.newArrayList(); // Paper - remove unused list
|
||||
public final List<TileEntity> tileEntityListTick = Lists.newArrayList();
|
||||
private final List<TileEntity> c = Lists.newArrayList();
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
index 6d1f70b39e..293818b196 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
||||
@@ -37,7 +37,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
private final MinecraftServer server;
|
||||
public EntityTracker tracker;
|
||||
private final PlayerChunkMap manager;
|
||||
- private final Map<UUID, Entity> entitiesByUUID = Maps.newHashMap();
|
||||
+ public final Map<UUID, Entity> entitiesByUUID = Maps.newHashMap(); // Paper
|
||||
public boolean savingDisabled;
|
||||
private boolean J;
|
||||
private int emptyTime;
|
||||
@@ -971,7 +971,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
this.g.remove(entity1);
|
||||
} else {
|
||||
if (!(entity instanceof EntityHuman)) {
|
||||
- if (DEBUG_ENTITIES) {
|
||||
+ if (DEBUG_ENTITIES && 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("Deleting duplicate entity {}", entity); // Paper
|
||||
|
||||
@@ -1002,7 +1002,7 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
}
|
||||
|
||||
Entity old = this.entitiesByUUID.put(entity.getUniqueID(), entity);
|
||||
- if (old != null && old.getId() != entity.getId() && old.valid) {
|
||||
+ 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) {
|
||||
--
|
||||
2.21.0
|
||||
|
Loading…
Reference in New Issue
Block a user