Unicopia/src/main/java/com/minelittlepony/unicopia/Config.java

74 lines
2.2 KiB
Java
Raw Normal View History

package com.minelittlepony.unicopia;
2020-04-25 13:32:33 +02:00
import java.util.HashSet;
import java.util.Set;
import com.google.gson.annotations.Expose;
2020-04-25 13:32:33 +02:00
import com.minelittlepony.common.util.GamePaths;
import com.minelittlepony.common.util.settings.JsonConfig;
2020-04-25 13:32:33 +02:00
public class Config extends JsonConfig {
2020-04-25 13:32:33 +02:00
@Deprecated
2020-04-15 18:12:00 +02:00
public static Config getInstance() {
2020-04-25 13:32:33 +02:00
return Unicopia.getConfig();
}
2020-04-25 13:32:33 +02:00
public Config() {
super(GamePaths.getConfigDirectory().resolve("unicopia.json"));
}
@Expose(deserialize = false)
private final String speciesWhiteListComment =
"A whitelist of races permitted on the server. " +
"Races added to this list can be used by anyone, whilst any ones left off are not permitted. " +
"An empty list disables whitelisting entirely.";
@Expose
2020-04-25 13:32:33 +02:00
private final Set<Race> speciesWhiteList = new HashSet<>();
@Expose(deserialize = false)
private final String preferredRaceComment =
"The default preferred race. " +
"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.";
@Expose
private Race preferredRace = Race.EARTH;
@Expose(deserialize = false)
private final String ignoreMineLPComment =
"If true Mine Little Pony will not be considered when determining the race to use. " +
"The result will always be what is set by this config file.";
@Expose
private boolean ignoreMineLP = false;
2020-04-25 13:32:33 +02:00
public Set<Race> getSpeciesWhiteList() {
return speciesWhiteList;
}
public boolean ignoresMineLittlePony() {
return ignoreMineLP;
}
public void setIgnoreMineLittlePony(boolean value) {
if (value != ignoreMineLP) {
ignoreMineLP = value;
save();
}
}
public void setPreferredRace(Race race) {
if (preferredRace != race) {
preferredRace = race;
save();
}
}
public Race getPrefferedRace() {
if (preferredRace == null) {
setPreferredRace(Race.EARTH);
}
return preferredRace;
}
}