Paper/Spigot-Server-Patches/0308-Thread-Safe-Iteration-of-Chunk-Scheduler.patch
Aikar f835a91d15
Updated Upstream (Bukkit/CraftBukkit), deprecate SentientNPC API
Upstream has added the equivalent of our SentientNPC API, with exception to the EnderDragon.

We've added Mob to the EnderDragon, and our SentientNPC API should behave the same.

Vex#getOwner has been deprecated and a replacement Vex#getSummoner has been added using Mob.

However, since 1.13 is not production ready, SentientNPC API is subject for removal in 1.13.1 since
1.13 API is not compatible with 1.12.

Please move to the Mob interface ASAP.

This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
c5ab54d8 Expand GameRule API
ab9a606c Improve entity hierarchy by adding Mob interface.

CraftBukkit Changes:
29e75648 Expand GameRule API
50e6858b Improve entity hierarchy by adding Mob interface.
0e1d79b4 Correct error in previous patch
2018-08-10 22:20:59 -04:00

48 lines
1.9 KiB
Diff

From 58232527da5cfef622e6c0dbbd9df9ca88c7f412 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 23 Jul 2018 19:13:06 -0400
Subject: [PATCH] Thread Safe Iteration of Chunk Scheduler
diff --git a/src/main/java/net/minecraft/server/ChunkTaskScheduler.java b/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
index 7629e0d054..5ee8bedf34 100644
--- a/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
+++ b/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
@@ -1,8 +1,10 @@
package net.minecraft.server;
+import com.google.common.collect.Lists;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.EnumMap;
import java.util.Map;
import java.util.function.Consumer;
@@ -85,7 +87,13 @@ public class ChunkTaskScheduler extends Scheduler<ChunkCoordIntPair, ChunkStatus
}
public void a() {
- this.g.values().forEach((scheduler_a) -> {
+ // Paper start
+ ArrayList<Scheduler.a> list;
+ synchronized (this.g) {
+ list = Lists.newArrayList(this.g.values());
+ }
+ list.forEach((scheduler_a) -> {
+ // Paper end
ProtoChunk protochunk = (ProtoChunk) scheduler_a.a();
if (protochunk.h() && protochunk.i().d() == ChunkStatus.Type.PROTOCHUNK) {
@@ -93,6 +101,7 @@ public class ChunkTaskScheduler extends Scheduler<ChunkCoordIntPair, ChunkStatus
protochunk.setLastSaved(this.c.getTime());
this.e.saveChunk(this.c, protochunk);
protochunk.a(false);
+
} catch (IOException ioexception) {
ChunkTaskScheduler.b.error("Couldn\'t save chunk", ioexception);
} catch (ExceptionWorldConflict exceptionworldconflict) {
--
2.18.0