Skip to content

Commit 14768d2

Browse files
committed
go over map cursor lag one last time
1 parent 57de59a commit 14768d2

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/packets/MapCursorLag.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,28 @@ public MapCursorLag() {
1717
super("patches.map-cursor-lag-patch", false, PacketListenerPriority.HIGHEST, """
1818
Patches the famous stacked map cursor lag that causes both client and server lag.""");
1919
this.maxCursors = config.getInt(configPath + ".max-cursors", 32);
20-
this.disableTracking = config.getBoolean(configPath + ".disable-tracking", false,
20+
this.disableTracking = config.getBoolean(configPath + ".disable-tracking", true,
2121
"Disables all tracking on active MapViews.");
2222
}
2323

2424
@Override
2525
public void onPacketSend(PacketSendEvent event) {
2626
if (event.getPacketType() != PacketType.Play.Server.MAP_DATA) return;
27+
2728
WrapperPlayServerMapData mapData = new WrapperPlayServerMapData(event);
2829

29-
MapView bukkitMapView = ItemUtil.getMapById(mapData.getMapId());
30-
if (bukkitMapView != null && !bukkitMapView.isVirtual()) {
31-
ItemUtil.setTrackingMapPosition(bukkitMapView, !disableTracking);
30+
if (disableTracking) {
31+
MapView bukkitMapView = ItemUtil.getMapById(mapData.getMapId());
32+
if (bukkitMapView != null && !bukkitMapView.isVirtual()) {
33+
ItemUtil.setTrackingMapPosition(bukkitMapView, false);
34+
}
3235
}
3336

3437
if (mapData.getDecorations() != null) {
3538
while (mapData.getDecorations().size() > maxCursors) {
3639
mapData.getDecorations().remove(GenericUtil.RANDOM.nextInt(mapData.getDecorations().size()));
40+
event.markForReEncode(true);
3741
}
38-
event.markForReEncode(true);
3942
}
4043
}
4144
}

AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/packets/MapCursorLag.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,19 @@ public void onPacketSend(PacketSendEvent event) {
3030

3131
WrapperPlayServerMapData mapData = new WrapperPlayServerMapData(event);
3232

33-
MapView bukkitMapView = Platform.getServerVersion().isOlderThanOrEquals(ServerVersion.V_1_12_2) ?
34-
Bukkit.getMap((short) mapData.getMapId()) : ItemUtil.getMapById(mapData.getMapId());
35-
if (bukkitMapView != null && !bukkitMapView.isVirtual()) {
36-
ItemUtil.setTrackingMapPosition(bukkitMapView, !disableTracking);
33+
if (disableTracking) {
34+
MapView bukkitMapView = Platform.getServerVersion().isOlderThanOrEquals(ServerVersion.V_1_12_2) ?
35+
Bukkit.getMap((short) mapData.getMapId()) : ItemUtil.getMapById(mapData.getMapId());
36+
if (bukkitMapView != null && !bukkitMapView.isVirtual()) {
37+
ItemUtil.setTrackingMapPosition(bukkitMapView, false);
38+
}
3739
}
3840

3941
if (mapData.getDecorations() != null) {
4042
while (mapData.getDecorations().size() > maxCursors) {
4143
mapData.getDecorations().remove(GenericUtil.RANDOM.nextInt(mapData.getDecorations().size()));
44+
event.markForReEncode(true);
4245
}
43-
event.markForReEncode(true);
4446
}
4547
}
4648
}

shared/src/main/java/me/xginko/aef/utils/ItemUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ private static int getApproximateByteSizeLegacy(@NotNull BookMeta bookMeta, bool
159159
}
160160

161161
/**
162-
* Disables that a position cursor will be shown when the map is near its center.
162+
* Sets whether a position cursor should be shown when the map is near its center.
163163
*/
164-
public static void setTrackingMapPosition(@NotNull MapView mapView, boolean tracking) {
164+
public static void setTrackingMapPosition(@NotNull MapView mapView, boolean trackingPosition) {
165165
if (MAP_SET_TRACKING_POS_AVAILABLE) {
166-
mapView.setTrackingPosition(tracking);
166+
mapView.setTrackingPosition(trackingPosition);
167167
}
168168
}
169169

0 commit comments

Comments
 (0)