Skip to content

Commit e7654f0

Browse files
committed
refactor: Rename userModified to seen to be more clear
1 parent 48c606b commit e7654f0

6 files changed

Lines changed: 18 additions & 18 deletions

File tree

common/src/main/java/net/blay09/mods/defaultoptions/DefaultOptionsInitializer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public class DefaultOptionsInitializer {
1414

15-
private static final Set<String> userModifiedKeys = new HashSet<>();
15+
private static final Set<String> userSeenKeys = new HashSet<>();
1616

1717
static {
1818
DefaultOptionsAPI.__internalMethods = new InternalMethodsImpl();
@@ -48,7 +48,7 @@ private static void loadDefaults(DefaultOptionsLoadStage stage) {
4848
}
4949
}
5050

51-
public static void collectUserModifiedKeys(Options options) {
51+
public static void collectSeenKeys(Options options) {
5252
try (final var reader = Files.newReader(options.getFile(), Charsets.UTF_8)) {
5353
reader.lines().forEach((line) -> {
5454
try {
@@ -57,7 +57,7 @@ public static void collectUserModifiedKeys(Options options) {
5757
if (colonIndex != -1) {
5858
final var key = line.substring(0, colonIndex);
5959
final var name = key.substring("key_".length());
60-
userModifiedKeys.add(name);
60+
userSeenKeys.add(name);
6161
}
6262
}
6363
} catch (Exception ignored) {
@@ -67,10 +67,10 @@ public static void collectUserModifiedKeys(Options options) {
6767
}
6868
}
6969

70-
public static void markUserModifiedKeys(Options options) {
70+
public static void markUserSeenKeys(Options options) {
7171
for (final var keyMapping : options.keyMappings) {
72-
if (userModifiedKeys.contains(keyMapping.getName())) {
73-
((DefaultOptionsKeyMapping) keyMapping).defaultoptions$setUserModified(true);
72+
if (userSeenKeys.contains(keyMapping.getName())) {
73+
((DefaultOptionsKeyMapping) keyMapping).defaultoptions$setSeen(true);
7474
}
7575
}
7676
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.blay09.mods.defaultoptions;
22

33
public interface DefaultOptionsKeyMapping {
4-
boolean defaultoptions$wasUserModified();
5-
void defaultoptions$setUserModified(boolean modified);
4+
boolean defaultoptions$wasSeen();
5+
void defaultoptions$setSeen(boolean seen);
66
}

common/src/main/java/net/blay09/mods/defaultoptions/keys/KeyMappingDefaultsHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public boolean shouldLoadDefaults() {
7474

7575
@Override
7676
public void loadDefaults() {
77-
DefaultOptionsInitializer.markUserModifiedKeys(Minecraft.getInstance().options);
77+
DefaultOptionsInitializer.markUserSeenKeys(Minecraft.getInstance().options);
7878

7979
// Clear old values
8080
defaultKeys.clear();
@@ -125,7 +125,7 @@ public void loadDefaults() {
125125
// If the key is still on the original default and has not yet been modified on this run (i.e. through options load),
126126
// we update it to the new default. Essentially options.txt now acts as what was previously knownkeys.txt.
127127
// That way we don't override changes the player themselves may have made already.
128-
if (!((DefaultOptionsKeyMapping) keyMapping).defaultoptions$wasUserModified()
128+
if (!((DefaultOptionsKeyMapping) keyMapping).defaultoptions$wasSeen()
129129
&& originalDefaultMapping.matches(keyMapping)
130130
&& !defaultKeyMapping.matches(keyMapping)) {
131131
KeyModifier defaultKeyModifier = PlatformBindings.INSTANCE.getDefaultKeyModifier(keyMapping);

common/src/main/java/net/blay09/mods/defaultoptions/mixin/KeyMappingMixin.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@
1111
@Mixin(KeyMapping.class)
1212
public class KeyMappingMixin implements DefaultOptionsKeyMapping {
1313

14-
private boolean defaultoptions$userModified = false;
14+
private boolean defaultoptions$seen = false;
1515

1616
@Inject(method = "setKey", at = @At("HEAD"))
1717
void setKey(InputConstants.Key key, CallbackInfo ci) {
1818
// setKey is only called when the key didn't match the default on options load, so it's not reliable.
1919
// We just track it additionally to cover all bases.
20-
defaultoptions$userModified = true;
20+
defaultoptions$seen = true;
2121
}
2222

2323
@Override
24-
public boolean defaultoptions$wasUserModified() {
25-
return defaultoptions$userModified;
24+
public boolean defaultoptions$wasSeen() {
25+
return defaultoptions$seen;
2626
}
2727

2828
@Override
29-
public void defaultoptions$setUserModified(boolean modified) {
30-
defaultoptions$userModified = modified;
29+
public void defaultoptions$setSeen(boolean seen) {
30+
defaultoptions$seen = seen;
3131
}
3232
}

common/src/main/java/net/blay09/mods/defaultoptions/mixin/OptionsMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class OptionsMixin {
1212
@Inject(method = "load()V", at = @At("HEAD"))
1313
private void load(CallbackInfo ci) {
14-
DefaultOptionsInitializer.collectUserModifiedKeys((Options) (Object) this);
14+
DefaultOptionsInitializer.collectSeenKeys((Options) (Object) this);
1515
DefaultOptionsInitializer.preLoad();
1616
}
1717
}

forge/src/main/java/net/blay09/mods/defaultoptions/mixin/ForgeKeyMappingMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ForgeKeyMappingMixin {
1616
void setKeyModifierAndCode(KeyModifier keyModifier, InputConstants.Key keyCode, CallbackInfo ci) {
1717
// setKey is only called when the key didn't match the default on options load, so it's not reliable.
1818
// We just track it additionally to cover all bases.
19-
((DefaultOptionsKeyMapping) this).defaultoptions$setUserModified(true);
19+
((DefaultOptionsKeyMapping) this).defaultoptions$setSeen(true);
2020
}
2121

2222
}

0 commit comments

Comments
 (0)