From 6cc6ec4a25966aa88b4afac3d1834c0d6d9c776c Mon Sep 17 00:00:00 2001 From: stranzjakob Date: Wed, 13 May 2026 22:28:54 +0000 Subject: [PATCH] Dateien nach "src/main/java/com/alttd/playerutils/config" hochladen --- .../com/alttd/playerutils/config/Config.java | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 src/main/java/com/alttd/playerutils/config/Config.java diff --git a/src/main/java/com/alttd/playerutils/config/Config.java b/src/main/java/com/alttd/playerutils/config/Config.java new file mode 100644 index 0000000..523e251 --- /dev/null +++ b/src/main/java/com/alttd/playerutils/config/Config.java @@ -0,0 +1,178 @@ +package com.alttd.playerutils.config; + +import lombok.extern.slf4j.Slf4j; +import org.bukkit.configuration.ConfigurationSection; + +import java.io.File; +import java.util.HashMap; +import java.util.List; +import java.util.Set; + +@Slf4j public class Config extends AbstractConfig{ + + static Config config; + + Config() { + super( + new File(File.separator + + "mnt" + File.separator + + "configs" + File.separator + + "PlayerUtils"), + "config.yml"); + } + + public static void reload() { + log.info("Reloading config"); + config = new Config(); + config.readConfig(Config.class, null); + } + + public static class SETTINGS { + private static final String prefix = "settings."; + public static boolean DEBUG = false; + public static boolean WARNINGS = true; + + @SuppressWarnings("unused") + private static void load() { + DEBUG = config.getBoolean(prefix, "debug", DEBUG); + WARNINGS = config.getBoolean(prefix, "warnings", WARNINGS); + } + } + + public static class KEY { + private static final String prefix = "key."; + public static HashMap CRATES = new HashMap<>(); + + @SuppressWarnings("unused") + private static void load() { + CRATES.clear(); + ConfigurationSection configurationSection = config.getConfigurationSection(prefix.substring(0, prefix.length() - 1)); + if (configurationSection == null) { + log.warn("No keys configured, adding default"); + config.set(prefix, "dailyvotecrate", 0); + config.set(prefix, "weeklyvotecrate", 0); + config.set(prefix, "questcrate", 0); + return; + } + Set keys = configurationSection.getKeys(false); + for (String key : keys) { + CRATES.put(key, config.getInt(prefix, key, 0)); + } + } + } + + public static class ARMOR_STAND_LIMIT { + private static final String prefix = "armor_stand_limit."; + + public static HashMap LIMIT = new HashMap<>(); + + @SuppressWarnings("unused") + private static void load() { + LIMIT.clear(); + ConfigurationSection configurationSection = config.getConfigurationSection(prefix.substring(0, prefix.length() - 1)); + if (configurationSection == null) { + log.warn("No limits configured, adding default"); + config.set(prefix, "default", 10); + } + Set limits = configurationSection.getKeys(false); + for (String key : limits) { + LIMIT.put(key, config.getInt(prefix, key, 10)); + } + } + } + + public static class LOCATOR_BAR { + private static final String prefix = "locator_bar."; + + public static double WAYPOINT_RECEIVE_RANGE = 200; + public static double WAYPOINT_TRANSMIT_RANGE = 200; + + @SuppressWarnings("unused") + private static void load() { + WAYPOINT_RECEIVE_RANGE = config.getDouble(prefix, "waypoint_receive_range", WAYPOINT_RECEIVE_RANGE); + WAYPOINT_TRANSMIT_RANGE = config.getDouble(prefix, "waypoint_transmit_range", WAYPOINT_TRANSMIT_RANGE); + } + } + + public static class VILLAGER_WORKSTATION { + private static final String prefix = "villager-workstation."; + + public static int RANGE = 8; + public static int CHECK_INTERVAL_TICKS = 5; + public static int PARTICLE_RING_COUNT = 8; + + @SuppressWarnings("unused") + private static void load() { + RANGE = config.getInt(prefix, "range", RANGE); + CHECK_INTERVAL_TICKS = config.getInt(prefix, "check-interval-ticks", CHECK_INTERVAL_TICKS); + PARTICLE_RING_COUNT = config.getInt(prefix, "particle-ring-count", PARTICLE_RING_COUNT); + } + } + + public static class RANDOM_PLOT { + private static final String prefix = "random-plot."; + + // Command + public static String PORT_COMMAND = "rpp"; + public static List ALLOWED_WORLDS = List.of("plotworld"); + + // Permissions + public static boolean USE_LUCKPERMS = true; + public static String LUCKPERMS_GROUP = "default"; + public static boolean USE_VAULT = false; + public static String VAULT_GROUP = "member"; + public static String FALLBACK_PERM = "randomplot.use"; + + // Countdown + public static int COUNTDOWN_SECONDS = 3; + public static HashMap COUNTDOWN_TITLES = new HashMap<>(); + public static String COUNTDOWN_SUBTITLE = "Preparing teleportation"; + + // Messages + public static String MSG_TELEPORT_START = "Starting teleport countdown..."; + public static String MSG_TELEPORT_SUCCESS = "You have arrived at a random plot!"; + public static String MSG_TELEPORT_CANCELLED = "Teleport cancelled! You moved."; + public static String MSG_NO_PLOTS_FOUND = "No plots found in this world."; + + @SuppressWarnings("unused") + private static void load() { + PORT_COMMAND = config.getString(prefix, "port-command", PORT_COMMAND); + ALLOWED_WORLDS = config.getStringList(prefix, "allowed-worlds", ALLOWED_WORLDS); + + USE_LUCKPERMS = config.getBoolean(prefix + "permissions.", "use-luckperms", USE_LUCKPERMS); + LUCKPERMS_GROUP = config.getString(prefix + "permissions.", "luckperms-group", LUCKPERMS_GROUP); + USE_VAULT = config.getBoolean(prefix + "permissions.", "use-vault", USE_VAULT); + VAULT_GROUP = config.getString(prefix + "permissions.", "vault-group", VAULT_GROUP); + FALLBACK_PERM = config.getString(prefix + "permissions.", "fallback-perm", FALLBACK_PERM); + + COUNTDOWN_SECONDS = config.getInt(prefix + "countdown.", "seconds", COUNTDOWN_SECONDS); + COUNTDOWN_SUBTITLE = config.getString(prefix + "countdown.", "subtitle", COUNTDOWN_SUBTITLE); + + // Countdown titles — integer keys map to display strings + COUNTDOWN_TITLES.clear(); + ConfigurationSection titlesSection = + config.getConfigurationSection("random-plot.countdown.titles"); + if (titlesSection != null) { + for (String key : titlesSection.getKeys(false)) { + try { + COUNTDOWN_TITLES.put(Integer.parseInt(key), + titlesSection.getString(key, key)); + } catch (NumberFormatException ignored) {} + } + } else { + // Write defaults on first run + config.yaml.addDefault("random-plot.countdown.titles.3", "<#08FBFF>3"); + config.yaml.addDefault("random-plot.countdown.titles.2", "<#08FBFF>2"); + config.yaml.addDefault("random-plot.countdown.titles.1", "<#08FBFF>1"); + COUNTDOWN_TITLES.put(3, "<#08FBFF>3"); + COUNTDOWN_TITLES.put(2, "<#08FBFF>2"); + COUNTDOWN_TITLES.put(1, "<#08FBFF>1"); + } + + MSG_TELEPORT_START = config.getString(prefix + "messages.", "teleport-start", MSG_TELEPORT_START); + MSG_TELEPORT_SUCCESS = config.getString(prefix + "messages.", "teleport-success", MSG_TELEPORT_SUCCESS); + MSG_TELEPORT_CANCELLED = config.getString(prefix + "messages.", "teleport-cancelled", MSG_TELEPORT_CANCELLED); + MSG_NO_PLOTS_FOUND = config.getString(prefix + "messages.", "no-plots-found", MSG_NO_PLOTS_FOUND); + } + } +}