Hopefully fix enum defaults
This commit is contained in:
parent
3fa12ce181
commit
1db554cb5a
|
@ -6,7 +6,7 @@ minecraft_version=1.17
|
||||||
yarn_mappings=build.1
|
yarn_mappings=build.1
|
||||||
loader_version=0.11.3
|
loader_version=0.11.3
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=2.1.0
|
mod_version=2.1.1
|
||||||
maven_group=io.gitlab.jfronny
|
maven_group=io.gitlab.jfronny
|
||||||
archives_base_name=respackopts
|
archives_base_name=respackopts
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package io.gitlab.jfronny.respackopts.data.entry;
|
package io.gitlab.jfronny.respackopts.data.entry;
|
||||||
|
|
||||||
|
import io.gitlab.jfronny.respackopts.Respackopts;
|
||||||
import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
|
import me.shedaniel.clothconfig2.api.AbstractConfigListEntry;
|
||||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
@ -18,7 +19,7 @@ public abstract class ConfigEntry<T> {
|
||||||
|
|
||||||
public T getValue() {
|
public T getValue() {
|
||||||
if (value == null)
|
if (value == null)
|
||||||
value = defaultValue;
|
value = getDefault();
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +29,10 @@ public abstract class ConfigEntry<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getDefault() {
|
public T getDefault() {
|
||||||
if (defaultValue == null)
|
if (defaultValue == null) {
|
||||||
defaultValue = value;
|
defaultValue = getValue();
|
||||||
|
Respackopts.LOGGER.warn("No default value set for entry, using current");
|
||||||
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.gitlab.jfronny.respackopts.gson;
|
package io.gitlab.jfronny.respackopts.gson;
|
||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
|
import io.gitlab.jfronny.respackopts.Respackopts;
|
||||||
import io.gitlab.jfronny.respackopts.data.entry.ConfigEnumEntry;
|
import io.gitlab.jfronny.respackopts.data.entry.ConfigEnumEntry;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
@ -36,6 +37,10 @@ public class EnumEntrySerializer implements JsonSerializer<ConfigEnumEntry>, Jso
|
||||||
else
|
else
|
||||||
throw new JsonSyntaxException("Expected string entry in enum");
|
throw new JsonSyntaxException("Expected string entry in enum");
|
||||||
}
|
}
|
||||||
|
if (result.values.isEmpty())
|
||||||
|
Respackopts.LOGGER.warn("Enum entry empty");
|
||||||
|
else
|
||||||
|
result.setDefault(result.values.get(0));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user