From 9489e5448f5efce2b20f03d82ae583f51d6eba9a Mon Sep 17 00:00:00 2001 From: Jordan Date: Sun, 22 Oct 2023 08:01:44 +0100 Subject: [PATCH] fix: there is no need to synchronise chunk sending to the chunk GET instance (#2463) --- .../adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java | 7 +++++-- .../adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks.java | 7 +++++-- .../adapter/impl/fawe/v1_19_R3/PaperweightGetBlocks.java | 7 +++++-- .../adapter/impl/fawe/v1_20_R1/PaperweightGetBlocks.java | 7 +++++-- .../adapter/impl/fawe/v1_20_R2/PaperweightGetBlocks.java | 7 +++++-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java index d7a1be074..7b01ccca1 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_17_R1_2/PaperweightGetBlocks.java @@ -98,6 +98,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc private final int maxHeight; private final int minSectionPosition; private final int maxSectionPosition; + private final Object sendLock = new Object(); private LevelChunkSection[] sections; private LevelChunk levelChunk; private DataLayer[] blockLight; @@ -841,8 +842,10 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc } @Override - public synchronized void send(int mask, boolean lighting) { - PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); + public void send(int mask, boolean lighting) { + synchronized (sendLock) { + PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); + } } /** diff --git a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks.java b/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks.java index fba567a5b..0c76df36a 100644 --- a/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks.java +++ b/worldedit-bukkit/adapters/adapter-1_18_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_18_R2/PaperweightGetBlocks.java @@ -104,6 +104,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc private final int maxSectionPosition; private final Registry biomeRegistry; private final IdMap> biomeHolderIdMap; + private final Object sendLock = new Object(); private LevelChunkSection[] sections; private LevelChunk levelChunk; private DataLayer[] blockLight; @@ -892,8 +893,10 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc } @Override - public synchronized void send(int mask, boolean lighting) { - PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); + public void send(int mask, boolean lighting) { + synchronized (sendLock) { + PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); + } } /** diff --git a/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightGetBlocks.java b/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightGetBlocks.java index 0840b4aac..0171832aa 100644 --- a/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightGetBlocks.java +++ b/worldedit-bukkit/adapters/adapter-1_19_4/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_19_R3/PaperweightGetBlocks.java @@ -104,6 +104,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc private final int maxSectionPosition; private final Registry biomeRegistry; private final IdMap> biomeHolderIdMap; + private final Object sendLock = new Object(); private LevelChunkSection[] sections; private LevelChunk levelChunk; private DataLayer[] blockLight; @@ -892,8 +893,10 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc } @Override - public synchronized void send(int mask, boolean lighting) { - PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); + public void send(int mask, boolean lighting) { + synchronized (sendLock) { + PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); + } } /** diff --git a/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightGetBlocks.java b/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightGetBlocks.java index e0e746109..e983a8e70 100644 --- a/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightGetBlocks.java +++ b/worldedit-bukkit/adapters/adapter-1_20/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R1/PaperweightGetBlocks.java @@ -104,6 +104,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc private final int maxSectionPosition; private final Registry biomeRegistry; private final IdMap> biomeHolderIdMap; + private final Object sendLock = new Object(); private LevelChunkSection[] sections; private LevelChunk levelChunk; private DataLayer[] blockLight; @@ -890,8 +891,10 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc } @Override - public synchronized void send(int mask, boolean lighting) { - PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); + public void send(int mask, boolean lighting) { + synchronized (sendLock) { + PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); + } } /** diff --git a/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightGetBlocks.java b/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightGetBlocks.java index cbfd90ae2..c8ae9c80f 100644 --- a/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightGetBlocks.java +++ b/worldedit-bukkit/adapters/adapter-1_20_2/src/main/java/com/sk89q/worldedit/bukkit/adapter/impl/fawe/v1_20_R2/PaperweightGetBlocks.java @@ -83,6 +83,7 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc private final int maxSectionPosition; private final Registry biomeRegistry; private final IdMap> biomeHolderIdMap; + private final Object sendLock = new Object(); private LevelChunkSection[] sections; private LevelChunk levelChunk; private DataLayer[] blockLight; @@ -877,8 +878,10 @@ public class PaperweightGetBlocks extends CharGetBlocks implements BukkitGetBloc } @Override - public synchronized void send(int mask, boolean lighting) { - PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); + public void send(int mask, boolean lighting) { + synchronized (sendLock) { + PaperweightPlatformAdapter.sendChunk(serverLevel, chunkX, chunkZ, lighting); + } } /**