Use the new config format and fix serialization of races

This commit is contained in:
Sollace 2022-10-12 19:30:06 +02:00
parent 08c9b730ca
commit d9cb0528f1

View file

@ -1,37 +1,40 @@
package com.minelittlepony.unicopia; package com.minelittlepony.unicopia;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import com.google.gson.GsonBuilder;
import com.minelittlepony.common.util.GamePaths; import com.minelittlepony.common.util.GamePaths;
import com.minelittlepony.common.util.settings.JsonConfig; import com.minelittlepony.common.util.settings.*;
import com.minelittlepony.common.util.settings.Setting;
public class Config extends JsonConfig { public class Config extends com.minelittlepony.common.util.settings.Config {
/*private final String speciesWhiteListComment = private static final Adapter ADAPTER = new HeirarchicalJsonConfigAdapter(new GsonBuilder()
"A whitelist of races permitted on the server. " + .registerTypeAdapter(Race.class, RegistryTypeAdapter.of(Race.REGISTRY))
"Races added to this list can be used by anyone, whilst any ones left off are not permitted. " + );
"An empty list disables whitelisting entirely.";*/
public final Setting<Set<Race>> speciesWhiteList = value("server", "speciesWhiteList", new HashSet<>()); public final Setting<Set<Race>> speciesWhiteList = value("server", "speciesWhiteList", Set.<Race>of())
.addComment("A whitelist of races permitted on the server")
.addComment("Races added to this list can be used by anyone,")
.addComment("whilst any ones left off are not permitted")
.addComment("An empty list disables whitelisting entirely.");
public final Setting<Boolean> enableCheats = value("server", "enableCheats", false); public final Setting<Boolean> enableCheats = value("server", "enableCheats", false)
.addComment("Allows use of the /race, /disguise, and /gravity commands");
/*private final String preferredRaceComment = public final Setting<Race> preferredRace = value("client", "preferredRace", Race.EARTH)
"The default preferred race. " + .addComment("The default preferred race")
"This is the race a client requests when first joining a game. " + .addComment("This is the race a client requests when first joining a game")
"It is the default used both when Mine Little Pony is not installed and when they respond with a human race.";*/ .addComment("It is the default used both when Mine Little Pony is not installed")
.addComment("and when they respond with a human race.");
public final Setting<Race> preferredRace = value("client", "preferredRace", Race.EARTH); public final Setting<Boolean> ignoreMineLP = value("client", "ignoreMineLP", false)
.addComment("If true Mine Little Pony will not be considered when determining the race to use")
.addComment("The result will always be what is set by this config file.");
/*private final String ignoreMineLPComment = public final Setting<Boolean> disableWaterPlantsFix = value("compatibility", "disableWaterPlantsFix", false)
"If true Mine Little Pony will not be considered when determining the race to use. " + .addComment("Disables this mod's built in fix for making sea plants waterlogged")
"The result will always be what is set by this config file.";*/ .addComment("Turn this ON if you're using another mod that does something similar of if you encounter copatibility issues with other mods.");
public final Setting<Boolean> ignoreMineLP = value("client", "ignoreMineLP", false);
public final Setting<Boolean> disableWaterPlantsFix = value("compatibility", "disableWaterPlantsFix", false);
public Config() { public Config() {
super(GamePaths.getConfigDirectory().resolve("unicopia.json")); super(ADAPTER, GamePaths.getConfigDirectory().resolve("unicopia.json"));
} }
} }