Skip to content

Commit 816346e

Browse files
committed
Make mod overrides higher priority than user configuration
Prevents players inadvertently enabling incompatible options
1 parent 4c484f5 commit 816346e

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ private void readProperties(Properties props) {
285285
continue;
286286
}
287287

288-
option.setEnabled(enabled, true);
288+
if(!option.isModDefined())
289+
option.setEnabled(enabled, true);
290+
else
291+
LOGGER.warn("Option '{}' already disabled by a mod. Ignoring user configuration", key);
289292
}
290293
}
291294

common/src/main/java/org/embeddedt/modernfix/screen/OptionList.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,20 @@ public OptionEntry(String optionName, Option option) {
128128
this.option.setEnabled(!this.option.isEnabled(), !this.option.isUserDefined());
129129
ModernFix.LOGGER.error("Unable to save config", e);
130130
}
131+
}, (btn, gfx, x, y) -> {
132+
if(this.option.isModDefined()) {
133+
String disablingMods = String.join(", ", this.option.getDefiningMods());
134+
OptionList.this.mainScreen.renderTooltip(
135+
gfx,
136+
new TranslatableComponent("modernfix.option." + (this.option.isEnabled() ? "enabled" : "disabled"))
137+
.append(new TranslatableComponent("modernfix.option.mod_override", disablingMods)),
138+
x,
139+
y
140+
);
141+
}
131142
});
143+
if(this.option.isModDefined())
144+
this.toggleButton.active = false;
132145
this.helpButton = new Button(75, 0, 20, 20, new TextComponent("?"), (arg) -> {
133146
Minecraft.getInstance().setScreen(new ModernFixOptionInfoScreen(mainScreen, optionName));
134147
});

common/src/main/resources/assets/modernfix/lang/en_us.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"modernfix.config.done_restart": "Done (restart required)",
1010
"modernfix.option.on": "on",
1111
"modernfix.option.off": "off",
12+
"modernfix.option.disabled": "disabled",
13+
"modernfix.option.enabled": "enabled",
14+
"modernfix.option.mod_override": " by mods [%s]",
1215
"modernfix.config.not_default": " (modified)",
1316
"asynclocator.map.locating": "Map (Locating...)",
1417
"asynclocator.map.none": "Map (No nearby feature found)",

0 commit comments

Comments
 (0)