tweaks724/src/main/java/eu/m724/tweaks/TweaksConfig.java
Minecon724 a3e3cc4b57
All checks were successful
/ deploy (push) Successful in 1m20s
Proximity chat
Also:
Removed login "Chat room:" notice
Removed "Joined chat room:" on command
The room in "has left the chat room" is now correct
Removed prefix from global
Fixed double kill message
2024-12-13 16:00:19 +01:00

133 lines
No EOL
4.7 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 worldborderExpand,
boolean worldborderHide,
boolean brandEnabled,
String brandText,
boolean brandShowPing,
boolean brandShowMspt,
boolean doorEnabled,
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
) {
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 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");
boolean doorEnabled = doorDoubleOpen || doorKnocking;
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");
TweaksConfig.config = new TweaksConfig(
metrics,
worldborderExpand, worldborderHide,
brandEnabled, brandText, brandShowPing, brandShowMspt,
doorEnabled, doorDoubleOpen, doorKnocking,
motdEnabled, motdSet,
chatEnabled, chatLocalEvents, chatDefaultName, chatRadius,
compassEnabled, compassWidth, compassPrecision,
pomodoroEnabled, pomodoroForce,
updaterEnabled,
hardcoreEnabled, hardcoreChance,
sleepEnabled, sleepInstant,
authEnabled, authForce, authHostname
);
return TweaksConfig.config;
}
}