diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/AppliedConfigState.java b/core/src/main/java/com/seibel/distanthorizons/core/config/AppliedConfigState.java index 8c8a6be15..badbb60d0 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/AppliedConfigState.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/AppliedConfigState.java @@ -2,7 +2,7 @@ package com.seibel.distanthorizons.core.config; import com.seibel.distanthorizons.core.config.types.ConfigEntry; -// TODO: Make this intergrate with the config system +// TODO: Make this integrate with the config system public class AppliedConfigState { final ConfigEntry entry; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java b/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java index 0df37a368..4b6df2e75 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java @@ -22,7 +22,7 @@ import java.util.*; // Init the config after singletons have been blinded public class ConfigBase { - /** Our own config instance, don't modify */ + /** Our own config instance, don't modify unless you are the DH mod */ public static ConfigBase INSTANCE; public ConfigFileHandling configFileINSTANCE; @@ -31,24 +31,27 @@ public class ConfigBase public final String modName; public final int configVersion; + + /** - * What the config works with - * - * Enum - * Boolean - * Byte - * Integer - * Double - * Short - * Long - * Float - * String - * - * // Below, "T" should be a value from above - * List - * ArrayList - * Map - * HashMap + * What the config works with + *
+ *
{@link Enum} + *
{@link Boolean} + *
{@link Byte} + *
{@link Integer} + *
{@link Double} + *
{@link Short} + *
{@link Long} + *
{@link Float} + *
{@link String} + *
+ *
// Below, "T" should be a value from above + *
// Note: This is not checked, so we trust that you are doing the right thing + *
List + *
ArrayList + *
Map + *
HashMap */ public static final List> acceptableInputs = new ArrayList>() {{ @@ -102,7 +105,7 @@ public class ConfigBase } catch (IllegalAccessException exception) { - exception.printStackTrace(); + LOGGER.warn(exception); } AbstractConfigType entry = entries.get(entries.size() - 1); @@ -151,10 +154,11 @@ public class ConfigBase * @param checkEnums Checks if all the lang for the enum's exist */ // This is just to re-format the lang or check if there is something in the lang that is missing + @SuppressWarnings("unchecked") public String generateLang(boolean onlyShowNew, boolean checkEnums) { ILangWrapper langWrapper = SingletonInjector.INSTANCE.get(ILangWrapper.class); - List> enumList = new ArrayList<>(); + List>> enumList = new ArrayList<>(); String generatedLang = ""; @@ -168,7 +172,7 @@ public class ConfigBase if (checkEnums && entry.getType().isEnum() && !enumList.contains(entry.getType())) { // Put it in an enum list to work with at the end - enumList.add((Class) entry.getType()); + enumList.add((Class>) entry.getType()); } if (!onlyShowNew || langWrapper.langExists(entryPrefix)) { diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java index b53e59f89..b09954a0b 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java @@ -13,7 +13,7 @@ import java.util.Map; public class NumberUtil { // Is there no better way of doing this? - public static Map minValues = new HashMap() + public static Map, Number> minValues = new HashMap, Number>() {{ put(Byte.class, Byte.MIN_VALUE); put(Short.class, Short.MIN_VALUE); @@ -22,7 +22,7 @@ public class NumberUtil put(Double.class, Double.MIN_VALUE); put(Float.class, Float.MIN_VALUE); }}; - public static Map maxValues = new HashMap() + public static Map, Number> maxValues = new HashMap, Number>() {{ put(Byte.class, Byte.MAX_VALUE); put(Short.class, Short.MAX_VALUE); @@ -32,11 +32,11 @@ public class NumberUtil put(Float.class, Float.MAX_VALUE); }}; - public static Number getMinimum(Class c) + public static Number getMinimum(Class c) { return minValues.get(c); } - public static Number getMaximum(Class c) + public static Number getMaximum(Class c) { return maxValues.get(c); } @@ -46,7 +46,7 @@ public class NumberUtil { if (a.getClass() != b.getClass()) return false; - Class typeClass = a.getClass(); + Class typeClass = a.getClass(); if (typeClass == Byte.class) return a.byteValue() > b.byteValue(); if (typeClass == Short.class) return a.shortValue() > b.shortValue(); @@ -62,7 +62,7 @@ public class NumberUtil { if (a.getClass() != b.getClass()) return false; - Class typeClass = a.getClass(); + Class typeClass = a.getClass(); if (typeClass == Byte.class) return a.byteValue() < b.byteValue(); if (typeClass == Short.class) return a.shortValue() < b.shortValue(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigTypeConverters.java b/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigTypeConverters.java index 489c9d191..32b6e5d1e 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigTypeConverters.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigTypeConverters.java @@ -116,9 +116,11 @@ public class ConfigTypeConverters Map mapObject = (Map) item; Config jsonObject = Config.inMemory(); + Object[] keyArray = mapObject.keySet().toArray(); + for (int i = 0; i < mapObject.size(); i++) { - jsonObject.add(mapObject.keySet().toArray()[i].toString(), mapObject.get(mapObject.keySet().toArray()[i])); + jsonObject.add(keyArray[i].toString(), mapObject.get(keyArray[i])); } return JsonFormat.minimalInstance().createWriter().writeToString(jsonObject); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/AbstractConfigType.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/AbstractConfigType.java index 218d4bcc4..40a709245 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/AbstractConfigType.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/types/AbstractConfigType.java @@ -8,8 +8,9 @@ import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance * * @author coolGi */ +// Note for devs: The "S" is the class that is extending this public abstract class AbstractConfigType -{ // The S is the class that is extending this +{ public String category = ""; // This should only be set once in the init public String name; // This should only be set once in the init protected T value; @@ -74,11 +75,13 @@ public abstract class AbstractConfigType // Put this into your own builder + @SuppressWarnings("unchecked") public S setAppearance(EConfigEntryAppearance newAppearance) { this.tmpAppearance = newAppearance; return (S) this; } + @SuppressWarnings("unchecked") public S set(T newValue) { this.tmpValue = newValue; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigCategory.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigCategory.java index 07d5dea9a..0e25ff232 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigCategory.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigCategory.java @@ -8,12 +8,12 @@ import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance * * @author coolGi */ -public class ConfigCategory extends AbstractConfigType +public class ConfigCategory extends AbstractConfigType, ConfigCategory> { /** This should not be set by anything other than the config system itself */ public String destination; // Where the category goes to - private ConfigCategory(EConfigEntryAppearance appearance, Class value, String destination) + private ConfigCategory(EConfigEntryAppearance appearance, Class value, String destination) { super(appearance, value); this.destination = destination; @@ -32,7 +32,7 @@ public class ConfigCategory extends AbstractConfigType return value; } - public static class Builder extends AbstractConfigType.Builder + public static class Builder extends AbstractConfigType.Builder, Builder> { private String tmpDestination = null; diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigLinkedEntry.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigLinkedEntry.java index b4c8f275b..f7fbdcb47 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigLinkedEntry.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigLinkedEntry.java @@ -8,9 +8,9 @@ import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance * * @author coolGi */ -public class ConfigLinkedEntry extends AbstractConfigType +public class ConfigLinkedEntry extends AbstractConfigType, ConfigLinkedEntry> { - public ConfigLinkedEntry(AbstractConfigType value) + public ConfigLinkedEntry(AbstractConfigType value) { super(EConfigEntryAppearance.ONLY_IN_GUI, value); } @@ -21,10 +21,10 @@ public class ConfigLinkedEntry extends AbstractConfigType newValue) { } - public static class Builder extends AbstractConfigType.Builder + public static class Builder extends AbstractConfigType.Builder, Builder> { /** Appearance shouldn't be changed */ @Override