2018-08-17 22:01:37 +00:00
|
|
|
From 08a7dc49c5a6a7b0742f31d1aaa6a29c1d892924 Mon Sep 17 00:00:00 2001
|
2018-07-23 23:41:41 +00:00
|
|
|
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
|
2018-08-17 22:01:37 +00:00
|
|
|
index ca1516f2a..94ba21f92 100644
|
2018-07-23 23:41:41 +00:00
|
|
|
--- 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;
|
2018-08-11 04:12:25 +00:00
|
|
|
@@ -86,7 +88,13 @@ public class ChunkTaskScheduler extends Scheduler<ChunkCoordIntPair, ChunkStatus
|
2018-07-23 23:41:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2018-08-11 04:12:25 +00:00
|
|
|
@@ -94,6 +102,7 @@ public class ChunkTaskScheduler extends Scheduler<ChunkCoordIntPair, ChunkStatus
|
2018-07-23 23:41:41 +00:00
|
|
|
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
|
|
|
|
|