fix: refix waypoint
related issue: https://github.com/LuminolMC/Lophine/issues/110
This commit is contained in:
+18
-8
@@ -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<WaypointTransmitter> {
|
||||
@@ -56,6 +56,7 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5
|
||||
- Map<ServerPlayer, WaypointTransmitter.Connection> map = Tables.transpose(this.connections).row(waypoint);
|
||||
- SetView<ServerPlayer> set = Sets.difference(this.players, map.keySet());
|
||||
+ java.util.List<Entry<ServerPlayer, WaypointTransmitter.Connection>> map = this.connections.getXZ(waypoint); // Lophine - concurrent
|
||||
+ if (map.isEmpty()) return; // Lophine - concurrent
|
||||
+ Set<ServerPlayer> players1 = new HashSet<>(); // Lophine - concurrent
|
||||
+ map.forEach((entry) -> players1.add(entry.getKey())); // Lophine - concurrent
|
||||
+ SetView<ServerPlayer> 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<WaypointTransmitte
|
||||
@@ -43,26 +53,67 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||
|
||||
@Override
|
||||
public void untrackWaypoint(WaypointTransmitter waypoint) {
|
||||
- this.connections.column(waypoint).forEach((serverPlayer, connection) -> connection.disconnect());
|
||||
- Tables.transpose(this.connections).row(waypoint).clear();
|
||||
+ java.util.List<Entry<ServerPlayer, WaypointTransmitter.Connection>> 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<Entry<WaypointTransmitter, WaypointTransmitter.Connection>> map = this.connections.getYZ(player); // Lophine - concurrent
|
||||
+ if (map.isEmpty()) return; // Lophine - concurrent
|
||||
+ Set<WaypointTransmitter> waypoints1 = new HashSet<>();// Lophine - concurrent
|
||||
+ map.forEach((entry) -> waypoints1.add(entry.getKey()));// Lophine - concurrent
|
||||
+ SetView<WaypointTransmitter> 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<Entry<WaypointTransmitter, WaypointTransmitter.Connection>> 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<WaypointTransmitter.Connection> 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<WaypointTransmitte
|
||||
@@ -83,13 +134,19 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||
if (player != waypoint) {
|
||||
if (isLocatorBarEnabledFor(player)) {
|
||||
waypoint.makeWaypointConnectionWith(player).ifPresentOrElse(connection -> {
|
||||
@@ -144,6 +152,7 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5
|
||||
- }
|
||||
+ // Lophine start - concurrent
|
||||
+ java.util.List<WaypointTransmitter.Connection> 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<WaypointTransmitte
|
||||
@@ -103,10 +160,12 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||
} else {
|
||||
waypoint.makeWaypointConnectionWith(player).ifPresentOrElse(connection1 -> {
|
||||
connection1.connect();
|
||||
@@ -164,6 +173,7 @@ index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..d2c0b532200f274e44f18147d294dfe5
|
||||
connection.disconnect();
|
||||
- this.connections.remove(player, waypoint);
|
||||
+ java.util.List<WaypointTransmitter.Connection> 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
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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<TickTa
|
||||
@@ -398,7 +398,7 @@ index 1a43bdcb4c37df4ad1c4dfe6ebb84470832e910f..daff493e4ea944afa91ce99a3596931a
|
||||
+ // Leaves end - player operation limiter
|
||||
}
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index 66e7b62a57eada0f0db7d9cc1be6362ac1e3ee85..95e7d3245bb38bf33a401648143522d3c96739a6 100644
|
||||
index 0d322ef4aa3e70c9edbb9fa8ba368bef916eb93d..293b154dc027694acd2dceaf00c61b3e42cf7a1c 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -317,6 +317,19 @@ public abstract class PlayerList {
|
||||
@@ -485,7 +485,7 @@ index 66e7b62a57eada0f0db7d9cc1be6362ac1e3ee85..95e7d3245bb38bf33a401648143522d3
|
||||
|
||||
public @Nullable ServerPlayer getPlayer(String name) {
|
||||
diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||
index d2c0b532200f274e44f18147d294dfe5d3f52d1d..55133071b97400dfb3ed6615c30006003de492c5 100644
|
||||
index f76d3a404eb7077f1db2374303eb265cb513d848..2e0e17a59fa2864dc9a2f2dafd18158cae6dae04 100644
|
||||
--- a/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||
+++ b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||
@@ -24,6 +24,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||
@@ -500,7 +500,7 @@ index d2c0b532200f274e44f18147d294dfe5d3f52d1d..55133071b97400dfb3ed6615c3000600
|
||||
this.waypoints.add(waypoint);
|
||||
|
||||
for (ServerPlayer serverPlayer : this.players) {
|
||||
@@ -61,6 +66,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||
@@ -64,6 +69,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||
// Folia - region threading
|
||||
// Lophine start - unsafe waypoint bar
|
||||
if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
||||
@@ -668,7 +668,7 @@ index fc1b3501114108d0166256c514a225337955e461..56bc87fefc82c77077bfed50accbde77
|
||||
return switch (this.getStatus()) {
|
||||
case IN_WATER, UNDER_WATER, UNDER_FLOWING_WATER -> 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 {
|
||||
|
||||
Reference in New Issue
Block a user