diff --git a/common/src/main/java/net/blay09/mods/defaultoptions/keys/KeyMappingDefaultsHandler.java b/common/src/main/java/net/blay09/mods/defaultoptions/keys/KeyMappingDefaultsHandler.java index 457cf6b..2c3a79c 100644 --- a/common/src/main/java/net/blay09/mods/defaultoptions/keys/KeyMappingDefaultsHandler.java +++ b/common/src/main/java/net/blay09/mods/defaultoptions/keys/KeyMappingDefaultsHandler.java @@ -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 defaultKeys = new HashMap<>(); private static final List knownKeys = new ArrayList<>(); @@ -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); } @@ -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())) {