Skip to content

Commit

Permalink
fix: Fix default keys not loading correctly, add some helpful logging
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jun 29, 2024
1 parent 442088f commit 7991ea2
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class KeyMappingDefaultsHandler implements DefaultOptionsHandler {

private static final Pattern KEY_PATTERN = Pattern.compile("key_([^:]+):([^:]+)(?::(.+))?");
private static final Pattern KEY_PATTERN = Pattern.compile("key_([^:]+):([^:]+)(?::(.+)?)?");
private static final Map<String, DefaultKeyMapping> defaultKeys = new HashMap<>();
private static final List<String> knownKeys = new ArrayList<>();

Expand Down Expand Up @@ -56,7 +56,7 @@ public void saveCurrentOptionsAsDefault() {
.map(KeyModifier::name)
.collect(Collectors.joining(",")));
}
} catch (IOException e) {
} catch (Exception e) {
DefaultOptions.logger.error("Failed to save default key mappings", e);
}

Expand Down Expand Up @@ -117,11 +117,13 @@ public void loadDefaults() {
knownKeys.add(line);
}
}
} catch (IOException e) {
} catch (Exception e) {
DefaultOptions.logger.error("Error loading known key bindings", e);
}
}

DefaultOptions.logger.info("Found {} default keys and {} known keys", defaultKeys.size(), knownKeys.size());

// Override the default mappings and set the initial key codes, if the key is not known yet
for (KeyMapping keyMapping : Minecraft.getInstance().options.keyMappings) {
if (defaultKeys.containsKey(keyMapping.getName())) {
Expand Down

0 comments on commit 7991ea2

Please sign in to comment.