diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index bc95438c7..838bef885 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -28,7 +28,6 @@ import net.minecraft.util.text.ITextComponent; import java.awt.*; import java.lang.reflect.Field; -import java.lang.reflect.Parameter; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.*; @@ -850,9 +849,9 @@ public final class Settings { Settings() { Field[] temp = getClass().getFields(); - Map> tmpByName = new HashMap<>(); - List> tmpAll = new ArrayList<>(); - Map, Type> tmpSettingTypes = new HashMap<>(); + Map> tmpByName = new HashMap<>(); + List> tmpAll = new ArrayList<>(); + Map, Type> tmpSettingTypes = new HashMap<>(); try { for (Field field : temp) { @@ -872,8 +871,8 @@ public final class Settings { } catch (IllegalAccessException e) { throw new IllegalStateException(e); } - byLowerName = Collections.unmodifiableMap(tmpByName); - allSettings = Collections.unmodifiableList(tmpAll); + byLowerName = Collections.unmodifiableMap(tmpByName); + allSettings = Collections.unmodifiableList(tmpAll); settingTypes = Collections.unmodifiableMap(tmpSettingTypes); } diff --git a/src/api/java/baritone/api/utils/SettingsUtil.java b/src/api/java/baritone/api/utils/SettingsUtil.java index b4436bc25..8667f554e 100644 --- a/src/api/java/baritone/api/utils/SettingsUtil.java +++ b/src/api/java/baritone/api/utils/SettingsUtil.java @@ -30,7 +30,8 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.nio.file.Files; import java.nio.file.Path; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.function.Consumer; import java.util.function.Function; @@ -131,7 +132,7 @@ public class SettingsUtil { throw new IllegalStateException("No setting by that name"); } Class intendedType = setting.getValueClass(); - Parser ioMethod = Parser.getParser(setting.getType()); + ISettingParser ioMethod = Parser.getParser(setting.getType()); Object parsed = ioMethod.parse(new ParserContext(setting), settingValue); if (!intendedType.isInstance(parsed)) { throw new IllegalStateException(ioMethod + " parser returned incorrect type, expected " + intendedType + " got " + parsed + " which is " + parsed.getClass()); @@ -166,7 +167,7 @@ public class SettingsUtil { DOUBLE(Double.class, Double::parseDouble), BOOLEAN(Boolean.class, Boolean::parseBoolean), INTEGER(Integer.class, Integer::parseInt), - FLOAT(Float.class,Float::parseFloat), + FLOAT(Float.class, Float::parseFloat), LONG(Long.class, Long::parseLong), ENUMFACING(EnumFacing.class, EnumFacing::byName), COLOR( @@ -176,16 +177,15 @@ public class SettingsUtil { ), BLOCK( Block.class, - BlockUtils::stringToBlockRequired, + str -> BlockUtils.stringToBlockRequired(str.trim()), BlockUtils::blockToString ), ITEM( Item.class, - Item::getByNameOrId, + str -> Item.getByNameOrId(str.trim()), item -> Item.REGISTRY.getNameForObject(item).toString() ), LIST() { - @Override public Object parse(ParserContext context, String raw) { Type type = ((ParameterizedType) context.getSetting().getType()).getActualTypeArguments()[0];