From 2e8340addd535deb7694bb712eb53f788e09f7c9 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 4 Sep 2018 01:50:14 -0400
Subject: [PATCH] Fix yet another issue with concurrency with datafixers

---
 ...Fix-concurrency-issues-in-DataFixers.patch | 15 ++++++++-
 scripts/importmcdev.sh                        | 31 +++++++++++++------
 2 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/Spigot-Server-Patches/0360-Fix-concurrency-issues-in-DataFixers.patch b/Spigot-Server-Patches/0360-Fix-concurrency-issues-in-DataFixers.patch
index 59a95766c..14d7f1f60 100644
--- a/Spigot-Server-Patches/0360-Fix-concurrency-issues-in-DataFixers.patch
+++ b/Spigot-Server-Patches/0360-Fix-concurrency-issues-in-DataFixers.patch
@@ -1,4 +1,4 @@
-From 361c1cfba32b0bad5325c9f91c468fcca3cba5b5 Mon Sep 17 00:00:00 2001
+From c4c58dc229e97fd54d277807534346fc186df004 Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Mon, 3 Sep 2018 22:18:38 -0400
 Subject: [PATCH] Fix concurrency issues in DataFixers
@@ -44,6 +44,19 @@ index fb2c380f8a..c8e7a8aa10 100644
          return rules.get(key);
      }
  
+diff --git a/src/main/java/com/mojang/datafixers/functions/PointFree.java b/src/main/java/com/mojang/datafixers/functions/PointFree.java
+index 0d88490f77..028942b8ea 100644
+--- a/src/main/java/com/mojang/datafixers/functions/PointFree.java
++++ b/src/main/java/com/mojang/datafixers/functions/PointFree.java
+@@ -14,7 +14,7 @@ public abstract class PointFree<T> {
+     private Function<DynamicOps<?>, T> value;
+ 
+     @SuppressWarnings("ConstantConditions")
+-    public Function<DynamicOps<?>, T> evalCached() {
++    public synchronized Function<DynamicOps<?>, T> evalCached() { // Paper
+         if (!initialized) {
+             initialized = true;
+             value = eval();
 diff --git a/src/main/java/com/mojang/datafixers/schemas/Schema.java b/src/main/java/com/mojang/datafixers/schemas/Schema.java
 index 7c67d989e0..45f3ef5957 100644
 --- a/src/main/java/com/mojang/datafixers/schemas/Schema.java
diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh
index b509f268c..156bf3893 100755
--- a/scripts/importmcdev.sh
+++ b/scripts/importmcdev.sh
@@ -83,23 +83,36 @@ for f in $files; do
 	fi
 done
 
-# Import Libraries - these must always be mapped manually, no automatic stuff
-#             group       lib             prefix                    files
-importLibrary com.mojang datafixerupper com/mojang/datafixers \
-    schemas/Schema.java \
-    DataFixerUpper.java \
-    types/families/RecursiveTypeFamily.java
-
-
+########################################################
+########################################################
+########################################################
+#                   NMS IMPORTS
 # Temporarily add new NMS dev imports here before you run paper patch
 # but after you have paper rb'd your changes, remove the line from this file before committing.
-# we do not need any lines added to this file
+# we do not need any lines added to this file for NMS
 
 # import FileName
 
 
 
+########################################################
+########################################################
+########################################################
+#              LIBRARY IMPORTS
+# These must always be mapped manually, no automatic stuff
+#
+#             # group    # lib          # prefix               # many files
+importLibrary com.mojang datafixerupper com/mojang/datafixers \
+    schemas/Schema.java \
+    DataFixerUpper.java \
+    functions/PointFree.java \
+    types/families/RecursiveTypeFamily.java
 
+# dont forget \ at end of each line but last
+
+########################################################
+########################################################
+########################################################
 set -e
 cd "$workdir/Spigot/Spigot-Server/"
 rm -rf nms-patches applyPatches.sh makePatches.sh >/dev/null 2>&1