diff --git a/lophine-server/minecraft-patches/features/0007-Add-config-to-enable-waypoint-command-bar.patch b/lophine-server/minecraft-patches/features/0007-Add-config-to-enable-waypoint-command-bar.patch index 58f5602..984e791 100644 --- a/lophine-server/minecraft-patches/features/0007-Add-config-to-enable-waypoint-command-bar.patch +++ b/lophine-server/minecraft-patches/features/0007-Add-config-to-enable-waypoint-command-bar.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Add config to enable waypoint command & bar use concurrent method to fix it (now, they are thread safe) diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java -index 23f047a47cdccc90a96153cc52bdedf91cd15db9..9cfcac44b4d51cb5f122d7e1fa980791a23dd38f 100644 +index 0c31144e1f18fe92065f0c167aaaaa809363cc4c..65d45f7abe95d9492620ea53ab87797a0ebc0ec7 100644 --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java @@ -270,7 +270,11 @@ public class Commands { @@ -23,10 +23,10 @@ index 23f047a47cdccc90a96153cc52bdedf91cd15db9..9cfcac44b4d51cb5f122d7e1fa980791 WorldBorderCommand.register(this.dispatcher); if (JvmProfiler.INSTANCE.isAvailable()) { diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java -index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5d3f52d1d 100644 +index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..f76d3a404eb7077f1db2374303eb265cb513d848 100644 --- a/net/minecraft/server/waypoints/ServerWaypointManager.java +++ b/net/minecraft/server/waypoints/ServerWaypointManager.java -@@ -16,22 +16,31 @@ import net.minecraft.world.waypoints.WaypointManager; +@@ -16,22 +16,32 @@ import net.minecraft.world.waypoints.WaypointManager; import net.minecraft.world.waypoints.WaypointTransmitter; public class ServerWaypointManager implements WaypointManager { @@ -56,6 +56,7 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5 - Map map = Tables.transpose(this.connections).row(waypoint); - SetView set = Sets.difference(this.players, map.keySet()); + java.util.List> map = this.connections.getXZ(waypoint); // Lophine - concurrent ++ if (map.isEmpty()) return; // Lophine - concurrent + Set players1 = new HashSet<>(); // Lophine - concurrent + map.forEach((entry) -> players1.add(entry.getKey())); // Lophine - concurrent + SetView set = Sets.difference(this.players, players1); // Lophine - concurrent @@ -65,12 +66,14 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5 this.updateConnection(entry.getKey(), waypoint, entry.getValue()); } -@@ -43,26 +52,60 @@ public class ServerWaypointManager implements WaypointManager connection.disconnect()); - Tables.transpose(this.connections).row(waypoint).clear(); ++ java.util.List> map = this.connections.getXZ(waypoint); // Lophine - concurrent ++ if (map.isEmpty()) return; // Lophine - concurrent + this.connections.getXZ(waypoint).forEach((entry) -> entry.getKey().disconnect()); // Lophine - concurrent + this.connections.clearXZ(waypoint); // Lophine - concurrent this.waypoints.remove(waypoint); @@ -97,6 +100,7 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5 + // Lophine start - unsafe waypoint bar + if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return; + java.util.List> map = this.connections.getYZ(player); // Lophine - concurrent ++ if (map.isEmpty()) return; // Lophine - concurrent + Set waypoints1 = new HashSet<>();// Lophine - concurrent + map.forEach((entry) -> waypoints1.add(entry.getKey()));// Lophine - concurrent + SetView set = Sets.difference(this.waypoints, waypoints1); // Lophine - concurrent @@ -115,7 +119,9 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5 // Folia - region threading + // Lophine start - unsafe waypoint bar + if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return; -+ this.connections.getYZ(player).forEach((entry) -> entry.getValue().disconnect()); // Lophine - concurrent ++ java.util.List> map = this.connections.getYZ(player); // Lophine - concurrent ++ if (map.isEmpty()) return; // Lophine - concurrent ++ map.forEach((entry) -> entry.getValue().disconnect()); // Lophine - concurrent + this.connections.clearYZ(player); // Lophine - concurrent + this.untrackWaypoint((WaypointTransmitter)player); + this.players.remove(player); @@ -125,12 +131,14 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5 public void breakAllConnections() { - this.connections.values().forEach(WaypointTransmitter.Connection::disconnect); - this.connections.clear(); -+ this.connections.getAllZ().forEach(WaypointTransmitter.Connection::disconnect); // Lophine - concurrent ++ java.util.List map = this.connections.getAllZ(); // Lophine - concurrent ++ if (map.isEmpty()) return; // Lophine - concurrent ++ map.forEach(WaypointTransmitter.Connection::disconnect); // Lophine - concurrent + this.connections.clearAll(); // Lophine - concurrent } public void remakeConnections(WaypointTransmitter waypoint) { -@@ -83,13 +126,18 @@ public class ServerWaypointManager implements WaypointManager { @@ -144,6 +152,7 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5 - } + // Lophine start - concurrent + java.util.List c = this.connections.getZ(player, waypoint); ++ if (c.isEmpty()) return; // Lophine - concurrent + c.forEach((connection) -> { + this.connections.remove(player, waypoint, connection); + if (connection != null) { @@ -154,7 +163,7 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5 }); } } -@@ -103,10 +151,11 @@ public class ServerWaypointManager implements WaypointManager { connection1.connect(); @@ -164,6 +173,7 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5 connection.disconnect(); - this.connections.remove(player, waypoint); + java.util.List c = this.connections.getZ(player, waypoint); // Lophine - concurrent ++ if (c.isEmpty()) return; // Lophine - concurrent + c.forEach((connection1) -> this.connections.remove(player, waypoint, connection1)); // Lophine - concurrent }); } diff --git a/lophine-server/minecraft-patches/features/0022-Leaves-Fakeplayer.patch b/lophine-server/minecraft-patches/features/0022-Leaves-Fakeplayer.patch index 8155458..665002f 100644 --- a/lophine-server/minecraft-patches/features/0022-Leaves-Fakeplayer.patch +++ b/lophine-server/minecraft-patches/features/0022-Leaves-Fakeplayer.patch @@ -33,7 +33,7 @@ index d5e604bf18a223aa434bc9f78274e1f3ff7f203d..715976a49ca621ba40d9353b18d41d34 private boolean encrypted; private final java.util.concurrent.atomic.AtomicBoolean disconnectionHandled = new java.util.concurrent.atomic.AtomicBoolean(false); // Folia - region threading - may be called concurrently during configuration stage diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index e4d1f0ae66aec2cdc625e3140da094c99350687d..324f9d259c6e0fd814ffe11b62d07fb4d2197da3 100644 +index f04352738e4f703d28f3c06ff884aee7d980542c..0990879441a7d1ef97681115a6427e18eae7adef 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -425,6 +425,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop SoundEvents.BOAT_PADDLE_WATER; diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java -index 8e28afcfda7b180def81122e35920f6fd57a4574..f42697374461ab2e1c610b8c3250d3c03c0821b4 100644 +index a67901ed3bcb67fb2cab05894bc386db2f0f90f8..3456712f837f91101cc1d38c953af1d7237603b9 100644 --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java @@ -404,6 +404,7 @@ public abstract class AbstractContainerMenu {