Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JustEli committed Feb 3, 2022
1 parent 5b3bf07 commit 877d9cc
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/main/java/me/justeli/coins/config/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.stream.Collectors;

/** Created by Eli on 12/14/2016. Rewritten by Eli on July 9, 2021. */
public final class Settings
Expand Down Expand Up @@ -63,6 +62,9 @@ private FileConfiguration config ()
return YamlConfiguration.loadConfiguration(config);
}

public static boolean USING_LEGACY_KEYS; // from before version 1.12
private static final Converter<String, String> LEGACY_CONVERTER = CaseFormat.LOWER_HYPHEN.converterTo(CaseFormat.LOWER_CAMEL);

public void parseConfig ()
{
FileConfiguration config = config();
Expand All @@ -78,9 +80,11 @@ public void parseConfig ()

try
{
boolean legacyChecked = false;
if (!config.contains(configKey))
{
configKey = legacyKey(configKey);
configKey = LEGACY_CONVERTER.convert(configKey);
legacyChecked = true;
}

if (!config.contains(configKey))
Expand All @@ -101,6 +105,11 @@ public void parseConfig ()
continue;
}

if (legacyChecked)
{
USING_LEGACY_KEYS = true;
}

Class<?> configClass = field.getType();
Object configValue;

Expand Down Expand Up @@ -171,15 +180,6 @@ else if (configClass == Float.class)
parseRemainingOptions();
}

public static boolean USING_LEGACY_KEYS; // from before version 1.12
private static final Converter<String, String> LEGACY_CONVERTER = CaseFormat.LOWER_HYPHEN.converterTo(CaseFormat.LOWER_CAMEL);

private String legacyKey (String key)
{
USING_LEGACY_KEYS = true;
return LEGACY_CONVERTER.convert(key);
}

private void parseRemainingOptions ()
{
Config.DROPPED_COIN_NAME = Util.color(Config.LEGACY_RAW_NAME_OF_COIN == null? Config.RAW_DROPPED_COIN_NAME : Config.LEGACY_RAW_NAME_OF_COIN);
Expand Down

0 comments on commit 877d9cc

Please sign in to comment.