22
33import com .fastasyncworldedit .bukkit .FaweBukkitWorld ;
44import com .fastasyncworldedit .core .FAWEPlatformAdapterImpl ;
5+ import com .fastasyncworldedit .core .Fawe ;
56import com .fastasyncworldedit .core .math .IntPair ;
67import com .fastasyncworldedit .core .queue .IChunkGet ;
78import com .fastasyncworldedit .core .util .MathMan ;
@@ -124,6 +125,9 @@ protected static <LevelChunkSection> boolean setSectionAtomic(
124125 if (layer < 0 || layer >= sections .length ) {
125126 return false ;
126127 }
128+ if (Fawe .isMainThread ()) {
129+ return ReflectionUtils .compareAndSet (sections , expected , value , layer );
130+ }
127131 StampLockHolder holder = new StampLockHolder ();
128132 ConcurrentHashMap <IntPair , ChunkSendLock > chunks = FaweBukkitWorld .getWorldSendingChunksMap (worldName );
129133 chunks .compute (pair , (k , lock ) -> {
@@ -171,6 +175,9 @@ protected static <LevelChunkSection> boolean setSectionAtomic(
171175 * @since 2.12.0
172176 */
173177 protected static void beginChunkPacketSend (String worldName , IntPair pair , StampLockHolder stampedLock ) {
178+ if (Fawe .isMainThread ()) {
179+ return ;
180+ }
174181 ConcurrentHashMap <IntPair , ChunkSendLock > chunks = FaweBukkitWorld .getWorldSendingChunksMap (worldName );
175182 chunks .compute (pair , (k , lock ) -> {
176183 if (lock == null ) {
@@ -192,6 +199,9 @@ protected static void beginChunkPacketSend(String worldName, IntPair pair, Stamp
192199 * @since 2.12.0
193200 */
194201 protected static void endChunkPacketSend (String worldName , IntPair pair , StampLockHolder lockHolder ) {
202+ if (Fawe .isMainThread ()) {
203+ return ;
204+ }
195205 ConcurrentHashMap <IntPair , ChunkSendLock > chunks = FaweBukkitWorld .getWorldSendingChunksMap (worldName );
196206 chunks .computeIfPresent (pair , (k , lock ) -> {
197207 if (lock .lock != lockHolder .chunkLock .lock ) {
0 commit comments