Skip to content

Commit

Permalink
Fix crash with null stance in the config
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Mar 11, 2024
1 parent 1f8b52d commit b8aa61a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/main/java/eu/ha3/presencefootsteps/PFConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class PFConfig extends JsonFile {

private int maxSteppingEntities = 50;

private boolean disabled;
private boolean disabled = false;
private boolean firstRun = true;
private boolean multiplayer = true;
private boolean global = true;
Expand All @@ -47,7 +47,7 @@ public boolean toggleMultiplayer() {
}

public EntitySelector cycleTargetSelector() {
targetEntities = EntitySelector.VALUES[(targetEntities.ordinal() + 1) % EntitySelector.VALUES.length];
targetEntities = EntitySelector.VALUES[(getEntitySelector().ordinal() + 1) % EntitySelector.VALUES.length];

save();

Expand Down Expand Up @@ -75,11 +75,11 @@ public void setNotFirstRun() {
}

public Locomotion getLocomotion() {
return stance;
return stance == null ? Locomotion.NONE : stance;
}

public EntitySelector getEntitySelector() {
return targetEntities;
return targetEntities == null ? EntitySelector.ALL : targetEntities;
}

public boolean getEnabledFootwear() {
Expand Down Expand Up @@ -154,8 +154,10 @@ public float setRunningVolumeIncrease(float volume) {
}

public void populateCrashReport(CrashReportSection section) {
section.add("PF Global Volume", volume);
section.add("PF User's Selected Stance", stance);
section.add("Disabled", getDisabled());
section.add("Global Volume", volume);
section.add("User's Selected Stance", getLocomotion());
section.add("Target Selector", getEntitySelector());
section.add("Enabled Global", global);
section.add("Enabled Multiplayer", multiplayer);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package eu.ha3.presencefootsteps.sound.generator;

import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiFunction;
Expand Down Expand Up @@ -30,7 +31,7 @@ public enum Locomotion {
private final BiFunction<LivingEntity, SoundEngine, Optional<StepSoundGenerator>> constructor;

private static final String AUTO_TRANSLATION_KEY = "menu.pf.stance.auto";
private final String translationKey = "menu.pf.stance." + name().toLowerCase();
private final String translationKey = "menu.pf.stance." + name().toLowerCase(Locale.ROOT);

Locomotion() {
constructor = (entity, engine) -> Optional.empty();
Expand Down

0 comments on commit b8aa61a

Please sign in to comment.