Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/main/java/com/mcprotector/client/FactionMapClientData.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

public final class FactionMapClientData {
private static MapSnapshot snapshot = MapSnapshot.empty();
private static boolean backgroundEnabledPreference = true;
private static int zoomPreference = Integer.MIN_VALUE;

private FactionMapClientData() {
}
Expand Down Expand Up @@ -39,18 +37,11 @@ public static void requestUpdate() {
public static void cycleBackgroundMode() {
MapBackgroundState state = snapshot.backgroundState();
boolean enabled = !(state != null && state.enabled());
backgroundEnabledPreference = enabled;
snapshot = snapshot.withBackgroundState(state.withEnabled(enabled));
}

public static void adjustZoom(int delta) {
MapBackgroundState state = snapshot.backgroundState();
if (state == null || state.providerType() == MapBackgroundProviderType.NONE) {
return;
}
int zoom = Math.max(state.minZoom(), Math.min(state.maxZoom(), state.zoom() + delta));
zoomPreference = zoom;
snapshot = snapshot.withBackgroundState(state.withZoom(zoom));
// Background zoom controls were removed.
}

public record MapSnapshot(int centerChunkX, int centerChunkZ, int radius,
Expand All @@ -59,6 +50,10 @@ public record MapSnapshot(int centerChunkX, int centerChunkZ, int radius,
public static MapSnapshot empty() {
return new MapSnapshot(0, 0, 0, new HashMap<>(), MapBackgroundState.none());
}

public MapSnapshot withBackgroundState(MapBackgroundState newBackgroundState) {
return new MapSnapshot(centerChunkX, centerChunkZ, radius, claims, newBackgroundState);
}
}

public enum MapBackgroundProviderType {
Expand All @@ -77,5 +72,9 @@ public static MapBackgroundState auto() {
? new MapBackgroundState(MapBackgroundProviderType.XAERO, true)
: none();
}

public MapBackgroundState withEnabled(boolean value) {
return new MapBackgroundState(providerType, value);
}
}
}
15 changes: 1 addition & 14 deletions src/main/java/com/mcprotector/client/gui/FactionMainScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ public class FactionMainScreen extends Screen {
private EditBox safeZoneFactionField;
private Button claimTypeButton;
private Button submitClaimsButton;
private Button mapBackgroundButton;
private Button mapZoomOutButton;
private Button mapZoomInButton;
private int roleIndex;
private int permissionIndex;
private int memberRoleIndex;
Expand Down Expand Up @@ -852,7 +849,6 @@ private void updateClaimTypeOptions(FactionClientData.FactionSnapshot snapshot)
selectedClaimType = options.get(0);
}
updateClaimTypeButtonLabel(snapshot);
updateMapBackgroundControls();
}

private void updateClaimTypeButtonLabel() {
Expand Down Expand Up @@ -1162,7 +1158,6 @@ private void renderFactionMap(GuiGraphics guiGraphics, FactionClientData.Faction
FactionMapRenderer.renderMapTooltip(guiGraphics, mapSnapshot, hovered, mouseX, mouseY, this.font);
}
renderMapLegend(guiGraphics, region);
renderMapBackgroundStatus(guiGraphics, region, mapSnapshot.backgroundState());
mapClaimsScrollOffset = renderMapClaimsList(guiGraphics, snapshot.claims(), region, mapClaimsScrollOffset);
if (!selectedChunks.isEmpty()) {
guiGraphics.drawString(this.font, "Selected " + selectedChunks.size() + " chunk(s)",
Expand Down Expand Up @@ -1296,17 +1291,9 @@ private void updateMapControlLayout() {
claimTypeButton.setY(controlsY);
submitClaimsButton.setX(claimTypeButton.getX() + claimTypeWidth + claimGap);
submitClaimsButton.setY(controlsY);
int backgroundControlsY = Math.max(panelTop + CONTROL_TOP_OFFSET, controlsY - 18);
int bgX = getPanelLeft();
mapBackgroundButton.setX(bgX);
mapBackgroundButton.setY(backgroundControlsY);
mapZoomOutButton.setX(bgX + mapBackgroundButton.getWidth() + 4);
mapZoomOutButton.setY(backgroundControlsY);
mapZoomInButton.setX(bgX + mapBackgroundButton.getWidth() + 24);
mapZoomInButton.setY(backgroundControlsY);
updateMapBackgroundControls();
}


private enum ClaimType {
FACTION("Faction"),
PERSONAL("Personal"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static void renderMapGrid(GuiGraphics guiGraphics, FactionMapClientData.M
int halfCell = Math.max(1, region.cellSize() / 2);
guiGraphics.fill(x, y, x + halfCell, y + halfCell, 0x18FFFFFF);
guiGraphics.fill(x + halfCell, y + halfCell, x + region.cellSize(), y + region.cellSize(), 0x18000000);
int gridColor = shadeColor(guiColor, 0.75f);
int gridColor = shadeColor(color, 0.75f);
guiGraphics.renderOutline(x, y, region.cellSize(), region.cellSize(), gridColor);
}
}
Expand Down

This file was deleted.

24 changes: 0 additions & 24 deletions src/main/java/com/mcprotector/config/FactionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,6 @@ public static final class Server {
public final ModConfigSpec.ConfigValue<Boolean> dynmapFullSyncOnStart;
public final ModConfigSpec.ConfigValue<Integer> claimMapRadiusChunks;
public final ModConfigSpec.ConfigValue<Boolean> claimMapFullSync;
public final ModConfigSpec.ConfigValue<Boolean> squaremapUiBackgroundEnabled;
public final ModConfigSpec.ConfigValue<String> squaremapUiTileUrlTemplate;
public final ModConfigSpec.ConfigValue<Integer> squaremapUiMinZoom;
public final ModConfigSpec.ConfigValue<Integer> squaremapUiMaxZoom;
public final ModConfigSpec.ConfigValue<Integer> squaremapUiDefaultZoom;
public final ModConfigSpec.ConfigValue<Integer> squaremapUiTileBlockSpan;
public final ModConfigSpec.ConfigValue<List<? extends String>> safeZoneDimensions;
public final ModConfigSpec.ConfigValue<List<? extends String>> warZoneDimensions;

Expand Down Expand Up @@ -380,24 +374,6 @@ private Server(ModConfigSpec.Builder builder) {
claimMapFullSync = builder
.comment("Send all claims to clients instead of only the radius (for larger map views).")
.define("claimMapFullSync", false);
squaremapUiBackgroundEnabled = builder
.comment("Enable Squaremap tile metadata for the in-game faction map background.")
.define("squaremapUiBackgroundEnabled", false);
squaremapUiTileUrlTemplate = builder
.comment("Tile URL template with placeholders {world}, {z}, {x}, {y}.")
.define("squaremapUiTileUrlTemplate", "");
squaremapUiMinZoom = builder
.comment("Minimum zoom level for in-game Squaremap background tiles.")
.defineInRange("squaremapUiMinZoom", 0, 0, 8);
squaremapUiMaxZoom = builder
.comment("Maximum zoom level for in-game Squaremap background tiles.")
.defineInRange("squaremapUiMaxZoom", 4, 0, 12);
squaremapUiDefaultZoom = builder
.comment("Default zoom level for in-game Squaremap background tiles.")
.defineInRange("squaremapUiDefaultZoom", 2, 0, 12);
squaremapUiTileBlockSpan = builder
.comment("Block span represented by a tile at zoom 0 for in-game background rendering.")
.defineInRange("squaremapUiTileBlockSpan", 256, 16, 4096);
safeZoneDimensions = builder
.comment("Dimensions treated as safe zones (no PvP, no claim interactions).")
.defineListAllowEmpty("safeZoneDimensions", List.of(), value -> value instanceof String);
Expand Down
21 changes: 1 addition & 20 deletions src/main/java/com/mcprotector/network/FactionClaimMapPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.mcprotector.data.Faction;
import com.mcprotector.data.FactionData;
import com.mcprotector.data.FactionRelation;
import com.mcprotector.webmap.SquaremapBridge;
import net.minecraft.ChatFormatting;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
Expand Down Expand Up @@ -179,25 +178,7 @@ public MapBackgroundMetadata background() {


private static MapBackgroundMetadata resolveBackgroundMetadata(net.minecraft.server.level.ServerLevel level) {
if (!FactionConfig.SERVER.squaremapUiBackgroundEnabled.get()) {
return MapBackgroundMetadata.none();
}
if (!SquaremapBridge.isAvailable()) {
return MapBackgroundMetadata.none();
}
String template = FactionConfig.SERVER.squaremapUiTileUrlTemplate.get();
if (template == null || template.isBlank()) {
return MapBackgroundMetadata.none();
}
int minZoom = FactionConfig.SERVER.squaremapUiMinZoom.get();
int maxZoom = FactionConfig.SERVER.squaremapUiMaxZoom.get();
int defaultZoom = FactionConfig.SERVER.squaremapUiDefaultZoom.get();
int tileBlockSpan = FactionConfig.SERVER.squaremapUiTileBlockSpan.get();
int clampedMin = Math.max(0, Math.min(minZoom, maxZoom));
int clampedMax = Math.max(clampedMin, maxZoom);
int clampedDefault = Math.max(clampedMin, Math.min(clampedMax, defaultZoom));
String worldName = level.dimension().location().toString();
return new MapBackgroundMetadata(true, "SQUAREMAP", template, worldName, clampedMin, clampedMax, clampedDefault, tileBlockSpan);
return MapBackgroundMetadata.none();
}

private static String resolveName(net.minecraft.server.MinecraftServer server, UUID playerId) {
Expand Down
Loading