142 lines
No EOL
5 KiB
Java
142 lines
No EOL
5 KiB
Java
/*
|
|
* Copyright (C) 2024 Minecon724
|
|
* Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file
|
|
* in the project root for the full license text.
|
|
*/
|
|
|
|
package eu.m724.tweaks;
|
|
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
public record TweaksConfig(
|
|
boolean metrics,
|
|
boolean debug,
|
|
String locale,
|
|
|
|
boolean worldborderExpand,
|
|
boolean worldborderHide,
|
|
|
|
boolean brandEnabled,
|
|
String brandText,
|
|
boolean brandShowPing,
|
|
boolean brandShowMspt,
|
|
|
|
boolean doorDoubleOpen,
|
|
boolean doorKnocking,
|
|
|
|
boolean motdEnabled,
|
|
String motdSet,
|
|
|
|
boolean chatEnabled,
|
|
boolean chatLocalEvents,
|
|
String chatDefaultName,
|
|
int chatRadius,
|
|
|
|
boolean compassEnabled,
|
|
int compassWidth,
|
|
int compassPrecision,
|
|
|
|
boolean pomodoroEnabled,
|
|
boolean pomodoroForce,
|
|
|
|
boolean updaterEnabled,
|
|
|
|
boolean hardcoreEnabled,
|
|
float hardcoreChance,
|
|
|
|
boolean sleepEnabled,
|
|
boolean sleepInstant,
|
|
|
|
boolean authEnabled,
|
|
boolean authForce,
|
|
String authDomain,
|
|
|
|
boolean redstoneEnabled,
|
|
String redstoneListen
|
|
) {
|
|
public static final int CONFIG_VERSION = 1;
|
|
private static TweaksConfig config;
|
|
|
|
public static TweaksConfig getConfig() {
|
|
return config;
|
|
}
|
|
|
|
public static TweaksConfig load(Plugin plugin) {
|
|
plugin.saveDefaultConfig();
|
|
FileConfiguration config = plugin.getConfig();
|
|
|
|
int configVersion = config.getInt("magic number don't modify this", 0);
|
|
RuntimeException exception = new RuntimeException("Config version is %d, expected %d".formatted(configVersion, CONFIG_VERSION));
|
|
if (configVersion == 0) {
|
|
throw exception;
|
|
} else if (configVersion > CONFIG_VERSION) {
|
|
throw new RuntimeException("Please follow update instructions", exception);
|
|
} else if (configVersion < CONFIG_VERSION) {
|
|
throw new RuntimeException("Did you downgrade the plugin? Remove config.yml and let the plugin re-create it", exception);
|
|
}
|
|
|
|
boolean metrics = config.getBoolean("metrics");
|
|
boolean debug = config.getBoolean("debug", false);
|
|
String locale = config.getString("locale", "US");
|
|
|
|
boolean worldborderExpand = config.getBoolean("worldborder.expand");
|
|
boolean worldborderHide = config.getBoolean("worldborder.hide");
|
|
|
|
boolean brandEnabled = config.getBoolean("brand.enabled");
|
|
String brandText = config.getString("brand.text");
|
|
boolean brandShowPing = config.getBoolean("brand.showPing");
|
|
boolean brandShowMspt = config.getBoolean("brand.showMspt");
|
|
|
|
boolean doorDoubleOpen = config.getBoolean("doors.doubleOpen");
|
|
boolean doorKnocking = config.getBoolean("doors.knocking");
|
|
|
|
String motdSet = config.getString("motd.set");
|
|
boolean motdEnabled = !(motdSet.equals("false") || motdSet.isBlank());
|
|
|
|
boolean chatEnabled = config.getBoolean("chat.enabled");
|
|
boolean chatLocalEvents = config.getBoolean("chat.localEvents");
|
|
String chatDefaultName = config.getString("chat.defaultName");
|
|
int chatRadius = config.getInt("chat.radius");
|
|
|
|
boolean compassEnabled = config.getBoolean("compass.enabled");
|
|
int compassWidth = config.getInt("compass.width");
|
|
int compassPrecision = config.getInt("compass.precision");
|
|
|
|
boolean pomodoroEnabled = config.getBoolean("pomodoro.enabled");
|
|
boolean pomodoroForce = config.getBoolean("pomodoro.force");
|
|
|
|
boolean updaterEnabled = config.getBoolean("updater.enabled");
|
|
|
|
boolean hardcoreEnabled = config.getBoolean("hardcore.enabled");
|
|
float hardcoreChance = (float) config.getDouble("hardcore.chance");
|
|
|
|
boolean sleepEnabled = config.getBoolean("sleep.enabled");
|
|
boolean sleepInstant = config.getBoolean("sleep.instant");
|
|
|
|
boolean authEnabled = config.getBoolean("auth.enabled");
|
|
boolean authForce = config.getBoolean("auth.force");
|
|
String authHostname = config.getString("auth.domain");
|
|
|
|
boolean redstoneEnabled = config.getBoolean("retstone.enabled");
|
|
String redstoneListen = config.getString("retstone.listen");
|
|
|
|
TweaksConfig.config = new TweaksConfig(
|
|
debug, metrics, locale,
|
|
worldborderExpand, worldborderHide,
|
|
brandEnabled, brandText, brandShowPing, brandShowMspt,
|
|
doorDoubleOpen, doorKnocking,
|
|
motdEnabled, motdSet,
|
|
chatEnabled, chatLocalEvents, chatDefaultName, chatRadius,
|
|
compassEnabled, compassWidth, compassPrecision,
|
|
pomodoroEnabled, pomodoroForce,
|
|
updaterEnabled,
|
|
hardcoreEnabled, hardcoreChance,
|
|
sleepEnabled, sleepInstant,
|
|
authEnabled, authForce, authHostname,
|
|
redstoneEnabled, redstoneListen
|
|
);
|
|
|
|
return TweaksConfig.config;
|
|
}
|
|
} |