Skip to content

Commit a459b8a

Browse files
committed
3.0.1
[Bug Fixes] /f claim add <size> power check — Fixed overclaiming exploit where the power requirement was only checked for 1 chunk regardless of the size argument. The check now correctly requires power for all (2×size−1)² chunks in the area. [Features] Info command — power warning — When a faction's current power is below the required power to sustain its claims: The "Required Power" value is now displayed in red instead of green. Another line "Not enough power to sustain your claims! Protections are currently off!" is shown (only if claimProtections is enabled in config). If claimDecayEnabled is true, an additional line warns that farthest claims will decay automatically, indicating the configured decay interval in human-readable form (e.g. "every 10 minutes"). BlueMap extruded marker Y bounds — Added two new config entries under bluemap in factions.json: markerMinY (default: -64) — bottom Y of extruded claim markers. markerMaxY (default: 320) — top Y of extruded claim markers. Previously these values were hardcoded. Old config files are handled gracefully with defaults.
1 parent 0573d27 commit a459b8a

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ yarn_mappings=1.20.1+build.10
66
loader_version=0.14.22
77

88
# Mod Properties
9-
mod_version = 3.0.0
9+
mod_version = 3.0.1
1010
maven_group = io.icker
1111
archives_base_name = factions
1212

src/main/java/io/icker/factions/command/ClaimCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ private int addSize(CommandContext<ServerCommandSource> context) throws CommandS
129129
ServerPlayerEntity player = context.getSource().getPlayerOrThrow();
130130
Faction faction = Command.getUser(player).getFaction();
131131

132+
int newChunks = (2 * size - 1) * (2 * size - 1);
132133
int requiredPower =
133-
(faction.getClaims().size() + 1) * FactionsMod.CONFIG.POWER.CLAIM_WEIGHT;
134+
(faction.getClaims().size() + newChunks) * FactionsMod.CONFIG.POWER.CLAIM_WEIGHT;
134135
int currentPower = faction.getPower();
135136

136137
if (currentPower < requiredPower) {

src/main/java/io/icker/factions/command/InfoCommand.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,24 @@ public static int info(ServerPlayerEntity player, Faction faction) {
167167
.append(Text.literal("Formula: ").formatted(Formatting.GRAY))
168168
.append(Text.literal(claimCount + " × " + claimWeight + " = " + requiredPower).formatted(Formatting.WHITE));
169169

170-
new Message(Formatting.GOLD + "Required Power: ").add(Formatting.GREEN.toString()
171-
+ requiredPower)
170+
boolean powerInsufficient = faction.getPower() < requiredPower;
171+
new Message(Formatting.GOLD + "Required Power: ").add(
172+
(powerInsufficient ? Formatting.RED : Formatting.GREEN).toString() + requiredPower)
172173
.hover(requiredHover).send(player, false);
173174

175+
if (powerInsufficient && !faction.isAdminProtected()) {
176+
if (FactionsMod.CONFIG.CLAIM_PROTECTION) {
177+
new Message(Formatting.RED + "Not enough power to sustain the claims! Protections are currently off!").send(player, false);
178+
}
179+
if (FactionsMod.CONFIG.POWER.CLAIM_DECAY_ENABLED) {
180+
int decaySeconds = FactionsMod.CONFIG.POWER.DECAY_CHECK_TICKS / 20;
181+
String decayRate = decaySeconds >= 60
182+
? (decaySeconds / 60) + " minute" + (decaySeconds / 60 == 1 ? "" : "s")
183+
: decaySeconds + " second" + (decaySeconds == 1 ? "" : "s");
184+
new Message(Formatting.RED + "Farthest claims will decay automatically every " + decayRate + ".").send(player, false);
185+
}
186+
}
187+
174188
// Show vassal information
175189
if (FactionsMod.CONFIG.VASSAL.ENABLED) {
176190
if (faction.isVassal()) {

src/main/java/io/icker/factions/config/Config.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public static Config load() {
6868
config.GODS = defaults.GODS;
6969
}
7070

71+
if (config.BLUEMAP == null) {
72+
config.BLUEMAP = defaults.BLUEMAP;
73+
}
74+
7175
if (config.VERSION != REQUIRED_VERSION) {
7276
FactionsMod.LOGGER.error(String.format(
7377
"Config file incompatible (requires version %d)", REQUIRED_VERSION));
@@ -140,6 +144,9 @@ public void save() {
140144
@SerializedName("gods")
141145
public GodsConfig GODS = new GodsConfig();
142146

147+
@SerializedName("bluemap")
148+
public BlueMapConfig BLUEMAP = new BlueMapConfig();
149+
143150
@SerializedName("_comment_maxFactionSize")
144151
public String _COMMENT_MAX_FACTION_SIZE = "Maximum members per faction (-1 = unlimited)";
145152

@@ -193,6 +200,20 @@ public static class RelationshipConfig {
193200
public compatSkillDamageProtectionfor COMPAT_SKILL_DAMAGE_PROTECTION_FOR = compatSkillDamageProtectionfor.NEUTRAL;
194201
}
195202

203+
public static class BlueMapConfig {
204+
@SerializedName("_comment_markerMinY")
205+
public String _COMMENT_MARKER_MIN_Y = "Minimum Y value for extruded claim markers on BlueMap";
206+
207+
@SerializedName("markerMinY")
208+
public int MARKER_MIN_Y = -64;
209+
210+
@SerializedName("_comment_markerMaxY")
211+
public String _COMMENT_MARKER_MAX_Y = "Maximum Y value for extruded claim markers on BlueMap";
212+
213+
@SerializedName("markerMaxY")
214+
public int MARKER_MAX_Y = 320;
215+
}
216+
196217
public static class Deserializer<T> implements JsonDeserializer<T> {
197218
final Class<T> clazz;
198219

src/main/java/io/icker/factions/util/BlueMapWrapper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ private void generateMarkers() {
125125
markerSets.put(level, markerSet);
126126
}
127127

128+
int minY = FactionsMod.CONFIG.BLUEMAP.MARKER_MIN_Y;
129+
int maxY = FactionsMod.CONFIG.BLUEMAP.MARKER_MAX_Y;
128130
ExtrudeMarker marker =
129131
ExtrudeMarker.builder()
130132
.position(
131133
(double) outlines.get(0).get(0).getX(),
132-
320,
134+
maxY,
133135
(double) outlines.get(0).get(0).getY())
134-
.shape(shapes.remove(0), -64, 320)
136+
.shape(shapes.remove(0), minY, maxY)
135137
.holes(shapes.toArray(new Shape[0]))
136138
.fillColor(
137139
new Color(

0 commit comments

Comments
 (0)