Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3dc7b1edb7 | |||
| ab2992a2ef | |||
| 5622d49d49 | |||
| 7fdce6aedd |
@@ -21,7 +21,7 @@ jobs:
|
|||||||
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
|
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
|
||||||
fetch-depth: 0 # a full history is required for pull request analysis
|
fetch-depth: 0 # a full history is required for pull request analysis
|
||||||
- name: 'Qodana Scan'
|
- name: 'Qodana Scan'
|
||||||
uses: JetBrains/qodana-action@v2025.2
|
uses: JetBrains/qodana-action@v2025.3
|
||||||
with:
|
with:
|
||||||
pr-mode: false
|
pr-mode: false
|
||||||
env:
|
env:
|
||||||
|
|||||||
+28
-13
@@ -23,7 +23,7 @@ index 1fb359073342a657e9e493403263b56be5b3393f..451a685782da46f5683ea6707289bbaf
|
|||||||
WorldBorderCommand.register(this.dispatcher);
|
WorldBorderCommand.register(this.dispatcher);
|
||||||
if (JvmProfiler.INSTANCE.isAvailable()) {
|
if (JvmProfiler.INSTANCE.isAvailable()) {
|
||||||
diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d188ad0489 100644
|
index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..65a4956ba2f0e38da7ae4f8cd7ed6e4b02c015a9 100644
|
||||||
--- a/net/minecraft/server/waypoints/ServerWaypointManager.java
|
--- a/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
+++ b/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,31 @@ import net.minecraft.world.waypoints.WaypointManager;
|
||||||
@@ -57,7 +57,7 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
- SetView<ServerPlayer> set = Sets.difference(this.players, map.keySet());
|
- SetView<ServerPlayer> set = Sets.difference(this.players, map.keySet());
|
||||||
+ java.util.List<Entry<ServerPlayer, WaypointTransmitter.Connection>> map = this.connections.getXZ(waypoint); // Lophine - concurrent
|
+ java.util.List<Entry<ServerPlayer, WaypointTransmitter.Connection>> map = this.connections.getXZ(waypoint); // Lophine - concurrent
|
||||||
+ Set<ServerPlayer> players1 = new HashSet<>(); // Lophine - concurrent
|
+ Set<ServerPlayer> players1 = new HashSet<>(); // Lophine - concurrent
|
||||||
+ map.forEach((entry) -> players1.add(entry.getKey())); // Lophine - concurrent
|
+ if (!map.isEmpty()) map.forEach((entry) -> players1.add(entry.getKey())); // Lophine - concurrent
|
||||||
+ SetView<ServerPlayer> set = Sets.difference(this.players, players1); // Lophine - concurrent
|
+ SetView<ServerPlayer> set = Sets.difference(this.players, players1); // Lophine - concurrent
|
||||||
|
|
||||||
- for (Entry<ServerPlayer, WaypointTransmitter.Connection> entry : ImmutableSet.copyOf(map.entrySet())) {
|
- for (Entry<ServerPlayer, WaypointTransmitter.Connection> entry : ImmutableSet.copyOf(map.entrySet())) {
|
||||||
@@ -65,14 +65,16 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
this.updateConnection(entry.getKey(), waypoint, entry.getValue());
|
this.updateConnection(entry.getKey(), waypoint, entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,26 +52,60 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
@@ -43,26 +52,65 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void untrackWaypoint(WaypointTransmitter waypoint) {
|
public void untrackWaypoint(WaypointTransmitter waypoint) {
|
||||||
- this.connections.column(waypoint).forEach((serverPlayer, connection) -> connection.disconnect());
|
- this.connections.column(waypoint).forEach((serverPlayer, connection) -> connection.disconnect());
|
||||||
- Tables.transpose(this.connections).row(waypoint).clear();
|
- Tables.transpose(this.connections).row(waypoint).clear();
|
||||||
+ this.connections.getXZ(waypoint).forEach((entry) -> entry.getKey().disconnect()); // Lophine - concurrent
|
+ this.connections.getXZ(waypoint).forEach((entry) -> {
|
||||||
+ this.connections.clearXZ(waypoint); // Lophine - concurrent
|
+ entry.getValue().disconnect();
|
||||||
|
+ this.connections.remove(entry.getKey(), waypoint, entry.getValue());
|
||||||
|
+ }); // Lophine - concurrent
|
||||||
this.waypoints.remove(waypoint);
|
this.waypoints.remove(waypoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +100,7 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
+ if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
+ if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
||||||
+ java.util.List<Entry<WaypointTransmitter, WaypointTransmitter.Connection>> map = this.connections.getYZ(player); // Lophine - concurrent
|
+ java.util.List<Entry<WaypointTransmitter, WaypointTransmitter.Connection>> map = this.connections.getYZ(player); // Lophine - concurrent
|
||||||
+ Set<WaypointTransmitter> waypoints1 = new HashSet<>();// Lophine - concurrent
|
+ Set<WaypointTransmitter> waypoints1 = new HashSet<>();// Lophine - concurrent
|
||||||
+ map.forEach((entry) -> waypoints1.add(entry.getKey()));// Lophine - concurrent
|
+ if (!map.isEmpty()) map.forEach((entry) -> waypoints1.add(entry.getKey()));// Lophine - concurrent
|
||||||
+ SetView<WaypointTransmitter> set = Sets.difference(this.waypoints, waypoints1); // Lophine - concurrent
|
+ SetView<WaypointTransmitter> set = Sets.difference(this.waypoints, waypoints1); // Lophine - concurrent
|
||||||
+
|
+
|
||||||
+ for (Entry<WaypointTransmitter, WaypointTransmitter.Connection> entry : map) { // Lophine - concurrent
|
+ for (Entry<WaypointTransmitter, WaypointTransmitter.Connection> entry : map) { // Lophine - concurrent
|
||||||
@@ -115,8 +117,10 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
// Folia - region threading
|
// Folia - region threading
|
||||||
+ // Lophine start - unsafe waypoint bar
|
+ // Lophine start - unsafe waypoint bar
|
||||||
+ if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
+ if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
||||||
+ this.connections.getYZ(player).forEach((entry) -> entry.getValue().disconnect()); // Lophine - concurrent
|
+ this.connections.getYZ(player).forEach((entry) -> {
|
||||||
+ this.connections.clearYZ(player); // Lophine - concurrent
|
+ entry.getValue().disconnect();
|
||||||
|
+ this.connections.remove(player, entry.getKey(), entry.getValue());
|
||||||
|
+ }); // Lophine - concurrent
|
||||||
+ this.untrackWaypoint((WaypointTransmitter)player);
|
+ this.untrackWaypoint((WaypointTransmitter)player);
|
||||||
+ this.players.remove(player);
|
+ this.players.remove(player);
|
||||||
+ // Lophine end - unsafe waypoint bar
|
+ // Lophine end - unsafe waypoint bar
|
||||||
@@ -125,13 +129,18 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
public void breakAllConnections() {
|
public void breakAllConnections() {
|
||||||
- this.connections.values().forEach(WaypointTransmitter.Connection::disconnect);
|
- this.connections.values().forEach(WaypointTransmitter.Connection::disconnect);
|
||||||
- this.connections.clear();
|
- 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()) map.forEach(WaypointTransmitter.Connection::disconnect); // Lophine - concurrent
|
||||||
+ this.connections.clearAll(); // Lophine - concurrent
|
+ this.connections.clearAll(); // Lophine - concurrent
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remakeConnections(WaypointTransmitter waypoint) {
|
public void remakeConnections(WaypointTransmitter waypoint) {
|
||||||
@@ -86,10 +129,15 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
@@ -83,13 +131,19 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||||
this.connections.put(player, waypoint, connection);
|
if (player != waypoint) {
|
||||||
|
if (isLocatorBarEnabledFor(player)) {
|
||||||
|
waypoint.makeWaypointConnectionWith(player).ifPresentOrElse(connection -> {
|
||||||
|
- this.connections.put(player, waypoint, connection);
|
||||||
|
+ this.connections.putOrUpdate(player, waypoint, connection);
|
||||||
connection.connect();
|
connection.connect();
|
||||||
}, () -> {
|
}, () -> {
|
||||||
- WaypointTransmitter.Connection connection = this.connections.remove(player, waypoint);
|
- WaypointTransmitter.Connection connection = this.connections.remove(player, waypoint);
|
||||||
@@ -140,6 +149,7 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
- }
|
- }
|
||||||
+ // Lophine start - concurrent
|
+ // Lophine start - concurrent
|
||||||
+ java.util.List<WaypointTransmitter.Connection> c = this.connections.getZ(player, waypoint);
|
+ java.util.List<WaypointTransmitter.Connection> c = this.connections.getZ(player, waypoint);
|
||||||
|
+ if (c.isEmpty()) return; // Lophine - concurrent
|
||||||
+ c.forEach((connection) -> {
|
+ c.forEach((connection) -> {
|
||||||
+ this.connections.remove(player, waypoint, connection);
|
+ this.connections.remove(player, waypoint, connection);
|
||||||
+ if (connection != null) {
|
+ if (connection != null) {
|
||||||
@@ -150,12 +160,17 @@ index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d1
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,7 +154,8 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
@@ -103,10 +157,12 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||||
this.connections.put(player, waypoint, connection1);
|
} else {
|
||||||
|
waypoint.makeWaypointConnectionWith(player).ifPresentOrElse(connection1 -> {
|
||||||
|
connection1.connect();
|
||||||
|
- this.connections.put(player, waypoint, connection1);
|
||||||
|
+ this.connections.putOrUpdate(player, waypoint, connection1);
|
||||||
}, () -> {
|
}, () -> {
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
- this.connections.remove(player, waypoint);
|
- this.connections.remove(player, waypoint);
|
||||||
+ java.util.List<WaypointTransmitter.Connection> c = this.connections.getZ(player, waypoint); // Lophine - concurrent
|
+ 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
|
+ c.forEach((connection1) -> this.connections.remove(player, waypoint, connection1)); // Lophine - concurrent
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ index 8e2775e873c92beed6a0e4e8ce1304ab8ca6e8d1..580f114fd99b017403c61e994d0c947d
|
|||||||
|
|
||||||
public boolean canBypassPlayerLimit(GameProfile profile) {
|
public boolean canBypassPlayerLimit(GameProfile profile) {
|
||||||
diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
index 55cb2d16e22e4d8745da539177b636d188ad0489..ce0942793c4098a1274b8ef5736e824a6eec0152 100644
|
index 65a4956ba2f0e38da7ae4f8cd7ed6e4b02c015a9..044ded5ec81905e38efe8812ff6d50259d761385 100644
|
||||||
--- a/net/minecraft/server/waypoints/ServerWaypointManager.java
|
--- a/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
+++ b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
+++ b/net/minecraft/server/waypoints/ServerWaypointManager.java
|
||||||
@@ -24,6 +24,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
@@ -24,6 +24,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||||
@@ -526,7 +526,7 @@ index 55cb2d16e22e4d8745da539177b636d188ad0489..ce0942793c4098a1274b8ef5736e824a
|
|||||||
this.waypoints.add(waypoint);
|
this.waypoints.add(waypoint);
|
||||||
|
|
||||||
for (ServerPlayer serverPlayer : this.players) {
|
for (ServerPlayer serverPlayer : this.players) {
|
||||||
@@ -61,6 +66,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
@@ -63,6 +68,11 @@ public class ServerWaypointManager implements WaypointManager<WaypointTransmitte
|
||||||
// Folia - region threading
|
// Folia - region threading
|
||||||
// Lophine start - unsafe waypoint bar
|
// Lophine start - unsafe waypoint bar
|
||||||
if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
if (!fun.bm.lophine.config.modules.experiment.CommandConfig.waypoint) return;
|
||||||
|
|||||||
+2
@@ -4,6 +4,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class AbstractConcurrentTable<X, Y, Z> {
|
public abstract class AbstractConcurrentTable<X, Y, Z> {
|
||||||
|
public abstract void putOrUpdate(X x, Y y, Z z);
|
||||||
|
|
||||||
public abstract void put(X x, Y y, Z z);
|
public abstract void put(X x, Y y, Z z);
|
||||||
|
|
||||||
public abstract void remove(X x, Y y, Z z);
|
public abstract void remove(X x, Y y, Z z);
|
||||||
|
|||||||
@@ -10,6 +10,17 @@ import java.util.function.Predicate;
|
|||||||
public class ConcurrentTable<X, Y, Z> extends AbstractConcurrentTable<X, Y, Z> {
|
public class ConcurrentTable<X, Y, Z> extends AbstractConcurrentTable<X, Y, Z> {
|
||||||
protected final ConcurrentLinkedDeque<TableEntry<X, Y, Z>> data = new ConcurrentLinkedDeque<>();
|
protected final ConcurrentLinkedDeque<TableEntry<X, Y, Z>> data = new ConcurrentLinkedDeque<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putOrUpdate(X x, Y y, Z z) {
|
||||||
|
for (TableEntry<X, Y, Z> entry : data) {
|
||||||
|
if (entry.getX().equals(x) && entry.getY().equals(y)) {
|
||||||
|
entry.setZ(z);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.put(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(X x, Y y, Z z) {
|
public void put(X x, Y y, Z z) {
|
||||||
data.add(new TableEntry<>(x, y, z));
|
data.add(new TableEntry<>(x, y, z));
|
||||||
|
|||||||
+31
-2
@@ -11,8 +11,30 @@ public class OptimizedConcurrentTable<X, Y, Z> extends ConcurrentTable<X, Y, Z>
|
|||||||
private final ConcurrentHashMap<Z, ConcurrentHashMap<X, Set<Y>>> zxIndex = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Z, ConcurrentHashMap<X, Set<Y>>> zxIndex = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(X x, Y y, Z z) {
|
public void putOrUpdate(X x, Y y, Z z) {
|
||||||
super.put(x, y, z);
|
boolean updated = false;
|
||||||
|
|
||||||
|
for (TableEntry<X, Y, Z> entry : data) {
|
||||||
|
if (entry.getX().equals(x) && entry.getY().equals(y)) {
|
||||||
|
removeFromIndex(xyIndex, entry.getX(), entry.getY(), entry.getZ());
|
||||||
|
removeFromIndex(yzIndex, entry.getY(), entry.getZ(), entry.getX());
|
||||||
|
removeFromIndex(zxIndex, entry.getZ(), entry.getX(), entry.getY());
|
||||||
|
|
||||||
|
entry.setZ(z);
|
||||||
|
|
||||||
|
putData(x, y, z);
|
||||||
|
|
||||||
|
updated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!updated) {
|
||||||
|
this.put(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void putData(X x, Y y, Z z) {
|
||||||
xyIndex.computeIfAbsent(x, k -> new ConcurrentHashMap<>())
|
xyIndex.computeIfAbsent(x, k -> new ConcurrentHashMap<>())
|
||||||
.computeIfAbsent(y, k -> ConcurrentHashMap.newKeySet()).add(z);
|
.computeIfAbsent(y, k -> ConcurrentHashMap.newKeySet()).add(z);
|
||||||
yzIndex.computeIfAbsent(y, k -> new ConcurrentHashMap<>())
|
yzIndex.computeIfAbsent(y, k -> new ConcurrentHashMap<>())
|
||||||
@@ -21,6 +43,13 @@ public class OptimizedConcurrentTable<X, Y, Z> extends ConcurrentTable<X, Y, Z>
|
|||||||
.computeIfAbsent(x, k -> ConcurrentHashMap.newKeySet()).add(y);
|
.computeIfAbsent(x, k -> ConcurrentHashMap.newKeySet()).add(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void put(X x, Y y, Z z) {
|
||||||
|
super.put(x, y, z);
|
||||||
|
putData(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(X x, Y y, Z z) {
|
public void remove(X x, Y y, Z z) {
|
||||||
super.remove(x, y, z);
|
super.remove(x, y, z);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package fun.bm.lophine.utils.concurrent;
|
|||||||
public class TableEntry<X, Y, Z> {
|
public class TableEntry<X, Y, Z> {
|
||||||
private final X x;
|
private final X x;
|
||||||
private final Y y;
|
private final Y y;
|
||||||
private final Z z;
|
private Z z;
|
||||||
|
|
||||||
public TableEntry(X x, Y y, Z z) {
|
public TableEntry(X x, Y y, Z z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@@ -22,4 +22,8 @@ public class TableEntry<X, Y, Z> {
|
|||||||
public Z getZ() {
|
public Z getZ() {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setZ(Z z) {
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user