|
| 1 | +--- a/net/minecraft/server/waypoints/ServerWaypointManager.java |
| 2 | ++++ b/net/minecraft/server/waypoints/ServerWaypointManager.java |
| 3 | +@@ -19,11 +_,19 @@ |
| 4 | + private final Set<WaypointTransmitter> waypoints = new HashSet<>(); |
| 5 | + private final Set<ServerPlayer> players = new HashSet<>(); |
| 6 | + private final Table<ServerPlayer, WaypointTransmitter, WaypointTransmitter.Connection> connections = HashBasedTable.create(); |
| 7 | ++ // Paper start - optimize ServerWaypointManager with locator bar disabled |
| 8 | ++ public boolean locatorBarEnabled; // Avoid a gamerule lookup for each player |
| 9 | ++ |
| 10 | ++ public ServerWaypointManager(net.minecraft.server.level.ServerLevel serverLevel) { |
| 11 | ++ this.locatorBarEnabled = serverLevel.getGameRules().get(GameRules.LOCATOR_BAR); |
| 12 | ++ } |
| 13 | ++ // Paper end - optimize ServerWaypointManager with locator bar disabled |
| 14 | + |
| 15 | + @Override |
| 16 | + public void trackWaypoint(final WaypointTransmitter waypoint) { |
| 17 | + this.waypoints.add(waypoint); |
| 18 | + |
| 19 | ++ if (!this.locatorBarEnabled) return; // Paper - optimize ServerWaypointManager with locator bar disabled |
| 20 | + for (ServerPlayer player : this.players) { |
| 21 | + this.createConnection(player, waypoint); |
| 22 | + } |
| 23 | +@@ -31,6 +_,7 @@ |
| 24 | + |
| 25 | + @Override |
| 26 | + public void updateWaypoint(final WaypointTransmitter waypoint) { |
| 27 | ++ if (!this.locatorBarEnabled) return; // Paper - optimize ServerWaypointManager with locator bar disabled |
| 28 | + if (this.waypoints.contains(waypoint)) { |
| 29 | + Map<ServerPlayer, WaypointTransmitter.Connection> playerConnection = Tables.transpose(this.connections).row(waypoint); |
| 30 | + SetView<ServerPlayer> potentialPlayers = Sets.difference(this.players, playerConnection.keySet()); |
| 31 | +@@ -55,9 +_,11 @@ |
| 32 | + public void addPlayer(final ServerPlayer player) { |
| 33 | + this.players.add(player); |
| 34 | + |
| 35 | ++ if (this.locatorBarEnabled) { // Paper - optimize ServerWaypointManager with locator bar disabled |
| 36 | + for (WaypointTransmitter waypoint : this.waypoints) { |
| 37 | + this.createConnection(player, waypoint); |
| 38 | + } |
| 39 | ++ } // Paper - optimize ServerWaypointManager with locator bar disabled |
| 40 | + |
| 41 | + if (player.isTransmittingWaypoint()) { |
| 42 | + this.trackWaypoint((WaypointTransmitter)player); |
| 43 | +@@ -65,6 +_,7 @@ |
| 44 | + } |
| 45 | + |
| 46 | + public void updatePlayer(final ServerPlayer player) { |
| 47 | ++ if (!this.locatorBarEnabled) return; // Paper - optimize ServerWaypointManager with locator bar disabled |
| 48 | + Map<WaypointTransmitter, WaypointTransmitter.Connection> waypointConnections = this.connections.row(player); |
| 49 | + SetView<WaypointTransmitter> potentialWaypoints = Sets.difference(this.waypoints, waypointConnections.keySet()); |
| 50 | + |
| 51 | +@@ -92,6 +_,7 @@ |
| 52 | + } |
| 53 | + |
| 54 | + public void remakeConnections(final WaypointTransmitter waypoint) { |
| 55 | ++ if (!this.locatorBarEnabled) return; // Paper - optimize ServerWaypointManager with locator bar disabled |
| 56 | + for (ServerPlayer player : this.players) { |
| 57 | + this.createConnection(player, waypoint); |
| 58 | + } |
| 59 | +@@ -101,8 +_,11 @@ |
| 60 | + return this.waypoints; |
| 61 | + } |
| 62 | + |
| 63 | +- private static boolean isLocatorBarEnabledFor(final ServerPlayer player) { |
| 64 | +- return player.level().getGameRules().get(GameRules.LOCATOR_BAR); |
| 65 | ++ // Paper start - optimize ServerWaypointManager with locator bar disabled |
| 66 | ++ // Avoid a gamerule lookup for each player |
| 67 | ++ private boolean isLocatorBarEnabledFor(final ServerPlayer player) { |
| 68 | ++ return locatorBarEnabled; |
| 69 | ++ // Paper end - optimize ServerWaypointManager with locator bar disabled |
| 70 | + } |
| 71 | + |
| 72 | + private void createConnection(final ServerPlayer player, final WaypointTransmitter waypoint) { |
0 commit comments