From a7ffeab57a3ee5714dde0fba3e4bc152deecc18e Mon Sep 17 00:00:00 2001 From: VulpineFriend87 Date: Sat, 23 May 2026 00:28:12 +0200 Subject: [PATCH 1/4] feat: implementation --- build.gradle.kts | 4 + gradle/libs.versions.toml | 3 + .../top/vulpine/simpleLobby/SimpleLobby.java | 24 +- .../command/SimpleLobbyCommand.java | 9 +- .../simpleLobby/command/SpawnCommand.java | 33 +- .../command/subCommands/ReloadSubCommand.java | 11 +- .../subCommands/SetSpawnSubCommand.java | 42 +-- .../vulpine/simpleLobby/config/Config.java | 305 ++++++++++++++++++ .../simpleLobby/listener/PlayerListener.java | 28 +- .../simpleLobby/listener/WorldListener.java | 42 +-- .../simpleLobby/utils/PlayerUtils.java | 25 +- 11 files changed, 412 insertions(+), 114 deletions(-) create mode 100644 src/main/java/top/vulpine/simpleLobby/config/Config.java diff --git a/build.gradle.kts b/build.gradle.kts index 44ec280..d7e4d0f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,11 +12,14 @@ repositories { maven("https://oss.sonatype.org/content/groups/public/") maven("https://oss.sonatype.org/content/repositories/snapshots/") maven("https://repo.extendedclip.com/releases/") + maven("https://repo.okaeri.cloud/releases") } dependencies { implementation(libs.minimessage) implementation(libs.minimessage.legacy) + implementation(libs.okaeri) + implementation(libs.okaeri.serdes) implementation(libs.bstats) compileOnly(libs.spigot) @@ -48,6 +51,7 @@ tasks { } shade("net.kyori.adventure", "adventure") + shade("eu.okaeri", "okaeri") shade("org.bstats", "bstats") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ea9d297..fbbad77 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,6 +5,7 @@ papi = "2.11.6" minimessage = "4.25.0" minimessage-legacy = "4.25.0" +okaeri = "5.0.13" bstats = "3.2.1" shadow = "9.3.0" @@ -17,6 +18,8 @@ papi = { module = "me.clip:placeholderapi", version.ref = "papi" } minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "minimessage" } minimessage-legacy = { module = "net.kyori:adventure-text-serializer-legacy", version.ref = "minimessage-legacy" } +okaeri = { module = "eu.okaeri:okaeri-configs-yaml-bukkit", version.ref = "okaeri" } +okaeri-serdes = { module = "eu.okaeri:okaeri-configs-serdes-bukkit", version.ref = "okaeri" } bstats = { module = "org.bstats:bstats-bukkit", version.ref = "bstats" } [plugins ] diff --git a/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java b/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java index 4f6b09c..aa9f554 100644 --- a/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java +++ b/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java @@ -1,10 +1,14 @@ package top.vulpine.simpleLobby; +import eu.okaeri.configs.ConfigManager; +import eu.okaeri.configs.yaml.bukkit.YamlBukkitConfigurer; +import eu.okaeri.configs.yaml.bukkit.serdes.SerdesBukkit; import lombok.Getter; import org.bstats.bukkit.Metrics; import org.bukkit.plugin.java.JavaPlugin; import top.vulpine.simpleLobby.command.SimpleLobbyCommand; import top.vulpine.simpleLobby.command.SpawnCommand; +import top.vulpine.simpleLobby.config.Config; import top.vulpine.simpleLobby.listener.PlayerListener; import top.vulpine.simpleLobby.listener.WorldListener; import top.vulpine.simpleLobby.scheduler.BukkitSchedulerAdapter; @@ -14,6 +18,8 @@ import top.vulpine.simpleLobby.utils.logger.LogLevel; import top.vulpine.simpleLobby.utils.logger.Logger; +import java.io.File; + /** * Main class for the SimpleLobby plugin. * This class initializes the plugin, sets up logging, and registers commands and event listeners. @@ -22,6 +28,8 @@ @Getter public final class SimpleLobby extends JavaPlugin { + private Config configuration; + private ActionParser actionParser; private SchedulerAdapter scheduler; @@ -30,11 +38,23 @@ public final class SimpleLobby extends JavaPlugin { @Override public void onEnable() { - saveDefaultConfig(); + try { + configuration = ConfigManager.create(Config.class, (it) -> { + it.withConfigurer(new YamlBukkitConfigurer(), new SerdesBukkit()); + it.withBindFile(new File(this.getDataFolder(), "config.yml")); + it.saveDefaults(); + it.load(true); + }); + } catch (Exception e) { + Logger.error("Failed to load configuration: " + e.getMessage()); + e.printStackTrace(); + getServer().getPluginManager().disablePlugin(this); + return; + } LogLevel logLevel; try { - logLevel = LogLevel.valueOf(getConfig().getString("log_level")); + logLevel = configuration.logLevel; } catch (IllegalArgumentException e) { Logger.warn("Invalid log level in config, defaulting to INFO"); logLevel = LogLevel.INFO; diff --git a/src/main/java/top/vulpine/simpleLobby/command/SimpleLobbyCommand.java b/src/main/java/top/vulpine/simpleLobby/command/SimpleLobbyCommand.java index 998d3a9..6ac1b12 100644 --- a/src/main/java/top/vulpine/simpleLobby/command/SimpleLobbyCommand.java +++ b/src/main/java/top/vulpine/simpleLobby/command/SimpleLobbyCommand.java @@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; +import org.jetbrains.annotations.NotNull; import top.vulpine.simpleLobby.SimpleLobby; import top.vulpine.simpleLobby.command.subCommands.ReloadSubCommand; import top.vulpine.simpleLobby.command.subCommands.SetSpawnSubCommand; @@ -30,7 +31,7 @@ public SimpleLobbyCommand(SimpleLobby plugin) { } @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { executeSubCommand(sender, args); return false; @@ -53,7 +54,7 @@ private void executeSubCommand(CommandSender sender, String[] args) { if (!PermissionChecker.hasPermission(sender, "command." + args[0].toLowerCase())) { sender.sendMessage(Colorize.color( - plugin.getConfig().getString("messages.no_permission") + plugin.getConfiguration().messages.noPermission )); return; @@ -69,7 +70,7 @@ private void executeSubCommand(CommandSender sender, String[] args) { } else { sender.sendMessage(Colorize.color( - plugin.getConfig().getString("messages.unknown_command") + plugin.getConfiguration().messages.unknownCommand )); } @@ -77,7 +78,7 @@ private void executeSubCommand(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (args.length == 0) { return Collections.emptyList(); } diff --git a/src/main/java/top/vulpine/simpleLobby/command/SpawnCommand.java b/src/main/java/top/vulpine/simpleLobby/command/SpawnCommand.java index 7a4f3df..d7da01f 100644 --- a/src/main/java/top/vulpine/simpleLobby/command/SpawnCommand.java +++ b/src/main/java/top/vulpine/simpleLobby/command/SpawnCommand.java @@ -6,11 +6,11 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; -import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; +import org.jetbrains.annotations.NotNull; import top.vulpine.simpleLobby.SimpleLobby; import top.vulpine.simpleLobby.scheduler.Cancellable; import top.vulpine.simpleLobby.utils.ActionParser; @@ -39,36 +39,33 @@ public SpawnCommand(SimpleLobby plugin) { } @Override - public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) { if (!PermissionChecker.hasPermission(sender, "command.spawn")) { - sender.sendMessage(Colorize.color(plugin.getConfig().getString("messages.no_permission"))); + sender.sendMessage(Colorize.color(plugin.getConfiguration().messages.noPermission)); return true; } if (!(sender instanceof Player player)) { - sender.sendMessage(Colorize.color(plugin.getConfig().getString("messages.only_players"))); + sender.sendMessage(Colorize.color(plugin.getConfiguration().messages.onlyPlayers)); return true; } - if (!plugin.getConfig().getBoolean("spawn.command.enabled")) { + if (!plugin.getConfiguration().spawn.command.enabled) { return true; } + if (plugin.getConfiguration().spawn.command.delay.enabled) { - FileConfiguration config = plugin.getConfig(); - boolean delayEnabled = config.getBoolean("spawn.command.delay.enabled"); - if (delayEnabled) { - - int seconds = config.getInt("spawn.command.delay.time"); - boolean requireStill = config.getBoolean("spawn.command.delay.require_player_still"); + int seconds = plugin.getConfiguration().spawn.command.delay.time; + boolean requireStill = plugin.getConfiguration().spawn.command.delay.requirePlayerStill; Map placeholders = new HashMap<>(); placeholders.put("time", String.valueOf(seconds)); List actions = requireStill ? - config.getStringList("spawn.actions.delay_started_still") : - config.getStringList("spawn.actions.delay_started"); + plugin.getConfiguration().spawn.actions.delayStartedStill : + plugin.getConfiguration().spawn.actions.delayStarted; actionParser.executeActions(actions, player, 0, placeholders); @@ -82,7 +79,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String tasks.remove(uuid); locations.remove(uuid); - List teleportActions = plugin.getConfig().getStringList("spawn.actions.teleported"); + List teleportActions = plugin.getConfiguration().spawn.actions.teleported; actionParser.executeActions(teleportActions, player, 0, new HashMap<>()); }, seconds * 20L); @@ -100,7 +97,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String PlayerUtils.teleportPlayer(plugin, player); - List teleportActions = config.getStringList("spawn.actions.teleported"); + List teleportActions = plugin.getConfiguration().spawn.actions.teleported; actionParser.executeActions(teleportActions, player, 0, new HashMap<>()); } @@ -109,14 +106,14 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String } @Override - public List onTabComplete(CommandSender sender, Command cmd, String label, String[] args) { + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) { return List.of(); } @EventHandler public void onPlayerMove(PlayerMoveEvent event) { - if (!plugin.getConfig().getBoolean("spawn.command.delay.require_player_still")) return; + if (!plugin.getConfiguration().spawn.command.delay.requirePlayerStill) return; Player player = event.getPlayer(); UUID uuid = player.getUniqueId(); @@ -131,7 +128,7 @@ public void onPlayerMove(PlayerMoveEvent event) { if (task != null) task.cancel(); locations.remove(uuid); - List cancelActions = plugin.getConfig().getStringList("spawn.actions.teleport_canceled"); + List cancelActions = plugin.getConfiguration().spawn.actions.teleportCanceled; actionParser.executeActions(cancelActions, player, 0, new HashMap<>()); Logger.debug("Player " + player.getName() + " moved while waiting for spawn teleport, teleport canceled."); diff --git a/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java b/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java index b1b4dd1..ae21d7c 100644 --- a/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java +++ b/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java @@ -3,6 +3,7 @@ import lombok.Getter; import org.bukkit.command.CommandSender; import top.vulpine.simpleLobby.command.SimpleLobbyCommand; +import top.vulpine.simpleLobby.config.Config; import top.vulpine.simpleLobby.instance.SubCommand; import top.vulpine.simpleLobby.utils.Colorize; @@ -20,14 +21,14 @@ public ReloadSubCommand(SimpleLobbyCommand command) { @Override public void execute(CommandSender sender, String[] args) { + Config config = command.getPlugin().getConfiguration(); + long startTime = System.currentTimeMillis(); - command.getPlugin().reloadConfig(); - long endTime = System.currentTimeMillis(); - long duration = endTime - startTime; + config.load(); + long duration = System.currentTimeMillis() - startTime; sender.sendMessage(Colorize.color( - command.getPlugin().getConfig().getString("messages.reloaded") - .replace("%time%", String.valueOf(duration)) + config.messages.reloaded.replace("%time%", String.valueOf(duration)) )); } diff --git a/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java b/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java index fa48de6..5ebca0e 100644 --- a/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java +++ b/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java @@ -3,9 +3,10 @@ import lombok.Getter; import org.bukkit.Location; import org.bukkit.command.CommandSender; -import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; +import top.vulpine.simpleLobby.SimpleLobby; import top.vulpine.simpleLobby.command.SimpleLobbyCommand; +import top.vulpine.simpleLobby.config.Config; import top.vulpine.simpleLobby.instance.SubCommand; import top.vulpine.simpleLobby.utils.Colorize; @@ -23,40 +24,27 @@ public SetSpawnSubCommand(SimpleLobbyCommand command) { @Override public void execute(CommandSender sender, String[] args) { + SimpleLobby plugin = command.getPlugin(); + Config config = plugin.getConfiguration(); + if (!(sender instanceof Player player)) { - sender.sendMessage(Colorize.color( - "&7[&f&lS&a&lL&7] &cThis command can only be executed by a player." - )); + sender.sendMessage(Colorize.color(config.messages.onlyPlayers)); return; } Location location = player.getLocation(); - FileConfiguration config = command.getPlugin().getConfig(); - - String world = location.getWorld().getName(); - double x = location.getX(); - double y = location.getY(); - double z = location.getZ(); - float yaw = location.getYaw(); - float pitch = location.getPitch(); - - config.set("spawn.location.world", world); - config.set("spawn.location.x", x); - config.set("spawn.location.y", y); - config.set("spawn.location.z", z); - config.set("spawn.location.yaw", yaw); - config.set("spawn.location.pitch", pitch); - command.getPlugin().saveConfig(); + config.spawn.location = location; + config.save(); player.sendMessage(Colorize.color( - command.getPlugin().getConfig().getString("messages.spawn_set") - .replace("%world%", world) - .replace("%x%", String.valueOf(x)) - .replace("%y%", String.valueOf(y)) - .replace("%z%", String.valueOf(z)) - .replace("%yaw%", String.valueOf(yaw)) - .replace("%pitch%", String.valueOf(pitch)) + config.messages.spawnSet + .replace("%world%", location.getWorld().getName()) + .replace("%x%", String.valueOf(location.getX())) + .replace("%y%", String.valueOf(location.getY())) + .replace("%z%", String.valueOf(location.getZ())) + .replace("%yaw%", String.valueOf(location.getYaw())) + .replace("%pitch%", String.valueOf(location.getPitch())) )); } diff --git a/src/main/java/top/vulpine/simpleLobby/config/Config.java b/src/main/java/top/vulpine/simpleLobby/config/Config.java new file mode 100644 index 0000000..8497e47 --- /dev/null +++ b/src/main/java/top/vulpine/simpleLobby/config/Config.java @@ -0,0 +1,305 @@ +package top.vulpine.simpleLobby.config; + +import eu.okaeri.configs.OkaeriConfig; +import eu.okaeri.configs.annotation.Comment; +import eu.okaeri.configs.annotation.Header; +import eu.okaeri.configs.annotation.NameModifier; +import eu.okaeri.configs.annotation.NameStrategy; +import eu.okaeri.configs.annotation.Names; +import org.bukkit.Location; +import top.vulpine.simpleLobby.utils.logger.LogLevel; + +import java.util.ArrayList; +import java.util.List; + +@Header("SimpleLobby Configuration - By Vulpine (https://vulpine.top)") +@Header("") +@Header("Wherever you see the [actions] tag, you can put in a list all the actions you want to perform in order.") +@Header("These are the actions you can use:") +@Header("") +@Header(" [optional]") +@Header("") +@Header("- \"[COMMAND] ; \"") +@Header("- \"[GAMEMODE] ; \"") +@Header("- \"[TITLE] ; ; [subtitle]; [fadeIn]; [stay]; [fadeOut]\"") +@Header("- \"[ACTIONBAR] <global/player>; <message>\"") +@Header("- \"[MESSAGE] <global/player>; <message>\"") +@Header("- \"[SOUND] <global/player>; <sound>; [volume]; [pitch]\"") +@Header("- \"[DELAY] <milliseconds>\"") +@Header("") +@Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) +public class Config extends OkaeriConfig { + + public Spawn spawn = new Spawn(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Spawn extends OkaeriConfig { + + public Command command = new Command(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Command extends OkaeriConfig { + + @Comment("If enabled, players can use the '/spawn' command to teleport to spawn") + public boolean enabled = true; + + @Comment("If enabled, players will have to wait a certain amount of time before being teleported to spawn") + public Delay delay = new Delay(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Delay extends OkaeriConfig { + + public boolean enabled = false; + + @Comment("Time in seconds") + public int time = 3; + + @Comment("If true, the player must not move during the delay time, or else the teleport will be canceled") + public boolean requirePlayerStill = true; + + } + + } + + @Comment("If true, players will be teleported to spawn when they join the server") + public boolean tpOnJoin = false; + + @Comment("Can be set using the '/sl setspawn' command in-game") + public Location location = new Location(null, 0, 64, 0, 0, 0); + + @Comment("Placeholders: any PlaceholderAPI placeholder (if installed)") + public Actions actions = new Actions(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Actions extends OkaeriConfig { + + @Comment("[actions] Placeholders: %time%; requires spawn command delay to be enabled") + public List<String> delayStarted = new ArrayList<>(List.of( + "[MESSAGE] player; &7[&f&lS&a&lL&7] &aYou will be teleported to spawn in %time% second(s)" + )); + + @Comment("[actions] Placeholders: %time%; requires spawn command delay to be enabled and require_player_still to be true") + public List<String> delayStartedStill = new ArrayList<>(List.of( + "[MESSAGE] player; &7[&f&lS&a&lL&7] &aYou will be teleported to spawn in %time% second(s). Do not move." + )); + + @Comment("[actions] Requires spawn command delay to be enabled and require_player_still to be true") + public List<String> teleportCanceled = new ArrayList<>(List.of( + "[MESSAGE] player; &7[&f&lS&a&lL&7] &cTeleport to spawn canceled, you moved." + )); + + @Comment("[actions]") + public List<String> teleported = new ArrayList<>(List.of( + "[MESSAGE] player; &7[&f&lS&a&lL&7] &aYou have been teleported to spawn." + )); + + } + + } + + public Actions actions = new Actions(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Actions extends OkaeriConfig { + + public Join join = new Join(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Join extends OkaeriConfig { + + @Comment("If true, the default join message will not be shown") + public boolean suppressDefaultMessage = true; + + public boolean enabled = true; + + @Comment("[actions] Placeholders: %player%, any PlaceholderAPI placeholder (if installed)") + public List<String> actions = new ArrayList<>(List.of( + "[TITLE] player; &bWelcome to the server!; &7Enjoy your stay!; 20; 60; 20", + "[MESSAGE] global; &b%player% &7has joined the server.", + "[GAMEMODE] player; adventure" + )); + + } + + public Quit quit = new Quit(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Quit extends OkaeriConfig { + + @Comment("If true, the default quit message will not be shown") + public boolean suppressDefaultMessage = true; + + public boolean enabled = true; + + @Comment("[actions] Placeholders: %player%, any PlaceholderAPI placeholder (if installed)") + public List<String> actions = new ArrayList<>(List.of( + "[MESSAGE] global; &b%player% &7has left the server." + )); + + } + + } + + @Comment("General world options") + public Options options = new Options(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Options extends OkaeriConfig { + + public DisableHungerLoss disableHungerLoss = new DisableHungerLoss(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class DisableHungerLoss extends OkaeriConfig { + + public boolean enabled = true; + + public Whitelist whitelist = new Whitelist(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Whitelist extends OkaeriConfig { + public boolean enabled = false; + @Comment("List of worlds where hunger loss is disabled") + public List<String> worlds = new ArrayList<>(); + } + + } + + public DisableMobSpawning disableMobSpawning = new DisableMobSpawning(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class DisableMobSpawning extends OkaeriConfig { + + public boolean enabled = true; + + public Whitelist whitelist = new Whitelist(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Whitelist extends OkaeriConfig { + public boolean enabled = false; + @Comment("List of worlds where mob spawning is disabled") + public List<String> worlds = new ArrayList<>(); + } + + } + + public DisableDamage disableDamage = new DisableDamage(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class DisableDamage extends OkaeriConfig { + + public boolean enabled = true; + + public Whitelist whitelist = new Whitelist(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Whitelist extends OkaeriConfig { + public boolean enabled = false; + @Comment("List of worlds where damage is disabled") + public List<String> worlds = new ArrayList<>(); + } + + } + + public ClearInventoryOnJoin clearInventoryOnJoin = new ClearInventoryOnJoin(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class ClearInventoryOnJoin extends OkaeriConfig { + public boolean enabled = true; + } + + public ClearEffectsOnJoin clearEffectsOnJoin = new ClearEffectsOnJoin(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class ClearEffectsOnJoin extends OkaeriConfig { + public boolean enabled = false; + } + + public DisableBlockPlacing disableBlockPlacing = new DisableBlockPlacing(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class DisableBlockPlacing extends OkaeriConfig { + + public boolean enabled = true; + + @Comment("If true, players in creative mode can place blocks") + public boolean creativeBypass = true; + + public Whitelist whitelist = new Whitelist(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Whitelist extends OkaeriConfig { + public boolean enabled = false; + @Comment("List of worlds where block placing is disabled") + public List<String> worlds = new ArrayList<>(); + } + + } + + public DisableBlockBreaking disableBlockBreaking = new DisableBlockBreaking(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class DisableBlockBreaking extends OkaeriConfig { + + public boolean enabled = true; + + @Comment("If true, players in creative mode can break blocks") + public boolean creativeBypass = true; + + public Whitelist whitelist = new Whitelist(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Whitelist extends OkaeriConfig { + public boolean enabled = false; + @Comment("List of worlds where block breaking is disabled") + public List<String> worlds = new ArrayList<>(); + } + + } + + public DisableBlockInteraction disableBlockInteraction = new DisableBlockInteraction(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class DisableBlockInteraction extends OkaeriConfig { + + public boolean enabled = true; + + @Comment("If true, players in creative mode can interact with blocks") + public boolean creativeBypass = true; + + public Whitelist whitelist = new Whitelist(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Whitelist extends OkaeriConfig { + public boolean enabled = false; + @Comment("List of worlds where block interaction is disabled") + public List<String> worlds = new ArrayList<>(); + } + + } + + } + + public Messages messages = new Messages(); + + @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) + public static class Messages extends OkaeriConfig { + + public String noPermission = "&7[&f&lS&a&lL&7] &cMissing permission!"; + + public String onlyPlayers = "&7[&f&lS&a&lL&7] &cThis command can only be executed by players."; + + @Comment("Placeholders: %time%") + public String reloaded = "&7[&f&lS&a&lL&7] &aConfiguration reloaded in &f%time%ms&a."; + + @Comment("Placeholders: %world%, %x%, %y%, %z%, %yaw%, %pitch%") + public String spawnSet = "&7[&f&lS&a&lL&7] &aSuccessfully set the spawn in &f%world%&a at &f%x%&a, &f%y%&a, &f%z%&a, &fyaw:%yaw%&a, &fpitch:%pitch%&a."; + + public String unknownCommand = "&7[&f&lS&a&lL&7] &cUnknown command!"; + + } + + @Comment("Log level for the plugin. Can be: DEBUG, INFO, WARN, ERROR.") + @Comment("Leave as it is if you don't know what to choose.") + public LogLevel logLevel = LogLevel.INFO; + +} diff --git a/src/main/java/top/vulpine/simpleLobby/listener/PlayerListener.java b/src/main/java/top/vulpine/simpleLobby/listener/PlayerListener.java index 4d2d20c..95c3066 100644 --- a/src/main/java/top/vulpine/simpleLobby/listener/PlayerListener.java +++ b/src/main/java/top/vulpine/simpleLobby/listener/PlayerListener.java @@ -1,6 +1,5 @@ package top.vulpine.simpleLobby.listener; -import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -29,29 +28,29 @@ public PlayerListener(SimpleLobby plugin) { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { - if (plugin.getConfig().getBoolean("actions.join.suppress_default_message")) { + if (plugin.getConfiguration().actions.join.suppressDefaultMessage) { event.setJoinMessage(null); Logger.debug("Join message suppressed for player: " + event.getPlayer().getName()); } - if (plugin.getConfig().getBoolean("options.clear_inventory_on_join.enabled")) { + if (plugin.getConfiguration().options.clearInventoryOnJoin.enabled) { event.getPlayer().getInventory().clear(); Logger.debug("Inventory cleared for player: " + event.getPlayer().getName()); } - if (plugin.getConfig().getBoolean("options.clear_effects_on_join.enabled")) { + if (plugin.getConfiguration().options.clearEffectsOnJoin.enabled) { event.getPlayer().getActivePotionEffects().forEach(effect -> event.getPlayer().removePotionEffect(effect.getType()) ); Logger.debug("Potion effects cleared for player: " + event.getPlayer().getName()); } - if (plugin.getConfig().getBoolean("actions.join.enabled")) { + if (plugin.getConfiguration().actions.join.enabled) { Map<String, String> placeholders = new HashMap<>(); placeholders.put("%player%", event.getPlayer().getName()); - plugin.getActionParser().executeActions(plugin.getConfig().getStringList("actions.join.actions"), + plugin.getActionParser().executeActions(plugin.getConfiguration().actions.join.actions, event.getPlayer(), 0, placeholders @@ -59,15 +58,10 @@ public void onPlayerJoin(PlayerJoinEvent event) { } - if (plugin.getConfig().getBoolean("spawn.tp_on_join")) { + if (plugin.getConfiguration().spawn.tpOnJoin) { - String world = plugin.getConfig().getString("spawn.location.world"); - World worldObj = Bukkit.getWorld(world); - if (worldObj == null) { - Logger.warn("World '" + world + "' not found. Cannot teleport player to spawn."); - } else { - PlayerUtils.teleportPlayer(plugin, event.getPlayer()); - } + World world = plugin.getConfiguration().spawn.location.getWorld(); + PlayerUtils.teleportPlayer(plugin, event.getPlayer()); } @@ -76,17 +70,17 @@ public void onPlayerJoin(PlayerJoinEvent event) { @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - if (plugin.getConfig().getBoolean("actions.quit.suppress_default_message")) { + if (plugin.getConfiguration().actions.quit.suppressDefaultMessage) { event.setQuitMessage(null); Logger.debug("Quit message suppressed for player: " + event.getPlayer().getName()); } - if (plugin.getConfig().getBoolean("actions.quit.enabled")) { + if (plugin.getConfiguration().actions.quit.enabled) { Map<String, String> placeholders = new HashMap<>(); placeholders.put("%player%", event.getPlayer().getName()); - plugin.getActionParser().executeActions(plugin.getConfig().getStringList("actions.quit.actions"), + plugin.getActionParser().executeActions(plugin.getConfiguration().actions.quit.actions, event.getPlayer(), 0, placeholders diff --git a/src/main/java/top/vulpine/simpleLobby/listener/WorldListener.java b/src/main/java/top/vulpine/simpleLobby/listener/WorldListener.java index 4572353..c99017f 100644 --- a/src/main/java/top/vulpine/simpleLobby/listener/WorldListener.java +++ b/src/main/java/top/vulpine/simpleLobby/listener/WorldListener.java @@ -38,9 +38,9 @@ public void onLungerLoss(FoodLevelChangeEvent event) { return; } - boolean enabled = plugin.getConfig().getBoolean("options.disable_hunger_loss.enabled"); - boolean whitelistEnabled = plugin.getConfig().getBoolean("options.disable_hunger_loss.whitelist.enabled"); - List<String> whitelistedWorlds = plugin.getConfig().getStringList("options.disable_hunger_loss.whitelist.worlds"); + boolean enabled = plugin.getConfiguration().options.disableHungerLoss.enabled; + boolean whitelistEnabled = plugin.getConfiguration().options.disableHungerLoss.whitelist.enabled; + List<String> whitelistedWorlds = plugin.getConfiguration().options.disableHungerLoss.whitelist.worlds; String world = player.getWorld().getName(); if (enabled && (!whitelistEnabled || whitelistedWorlds.contains(world))) { event.setCancelled(true); @@ -52,9 +52,9 @@ public void onLungerLoss(FoodLevelChangeEvent event) { @EventHandler public void onMobSpawn(CreatureSpawnEvent event) { - boolean enabled = plugin.getConfig().getBoolean("options.disable_mob_spawning.enabled"); - boolean whitelistEnabled = plugin.getConfig().getBoolean("options.disable_mob_spawning.whitelist.enabled"); - List<String> whitelistedWorlds = plugin.getConfig().getStringList("options.disable_mob_spawning.whitelist.worlds"); + boolean enabled = plugin.getConfiguration().options.disableMobSpawning.enabled; + boolean whitelistEnabled = plugin.getConfiguration().options.disableMobSpawning.whitelist.enabled; + List<String> whitelistedWorlds = plugin.getConfiguration().options.disableMobSpawning.whitelist.worlds; String world = event.getLocation().getWorld().getName(); if (enabled && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.NATURAL && (!whitelistEnabled || whitelistedWorlds.contains(world))) { @@ -71,9 +71,9 @@ public void onDamage(EntityDamageEvent event) { return; } - boolean enabled = plugin.getConfig().getBoolean("options.disable_damage.enabled"); - boolean whitelistEnabled = plugin.getConfig().getBoolean("options.disable_damage.whitelist.enabled"); - List<String> whitelistedWorlds = plugin.getConfig().getStringList("options.disable_damage.whitelist.worlds"); + boolean enabled = plugin.getConfiguration().options.disableDamage.enabled; + boolean whitelistEnabled = plugin.getConfiguration().options.disableDamage.whitelist.enabled; + List<String> whitelistedWorlds = plugin.getConfiguration().options.disableDamage.whitelist.worlds; String world = player.getWorld().getName(); if (enabled && (!whitelistEnabled || whitelistedWorlds.contains(world))) { event.setCancelled(true); @@ -85,12 +85,12 @@ public void onDamage(EntityDamageEvent event) { @EventHandler public void onBlockPlace(BlockPlaceEvent event) { - boolean enabled = plugin.getConfig().getBoolean("options.disable_block_placing.enabled"); + boolean enabled = plugin.getConfiguration().options.disableBlockPlacing.enabled; if (enabled) { - boolean creativeBypass = plugin.getConfig().getBoolean("options.disable_block_placing.creative_bypass"); + boolean creativeBypass = plugin.getConfiguration().options.disableBlockPlacing.creativeBypass; if (!(event.getPlayer().getGameMode() == GameMode.CREATIVE && creativeBypass)) { - boolean whitelistEnabled = plugin.getConfig().getBoolean("options.disable_block_placing.whitelist.enabled"); - List<String> whitelistedWorlds = plugin.getConfig().getStringList("options.disable_block_placing.whitelist.worlds"); + boolean whitelistEnabled = plugin.getConfiguration().options.disableBlockPlacing.whitelist.enabled; + List<String> whitelistedWorlds = plugin.getConfiguration().options.disableBlockPlacing.whitelist.worlds; String world = event.getPlayer().getWorld().getName(); if (!whitelistEnabled || whitelistedWorlds.contains(world)) { event.setCancelled(true); @@ -104,12 +104,12 @@ public void onBlockPlace(BlockPlaceEvent event) { @EventHandler public void onBlockBreak(BlockBreakEvent event) { - boolean enabled = plugin.getConfig().getBoolean("options.disable_block_breaking.enabled"); + boolean enabled = plugin.getConfiguration().options.disableBlockBreaking.enabled; if (enabled) { - boolean creativeBypass = plugin.getConfig().getBoolean("options.disable_block_breaking.creative_bypass"); + boolean creativeBypass = plugin.getConfiguration().options.disableBlockBreaking.creativeBypass; if (!(event.getPlayer().getGameMode() == GameMode.CREATIVE && creativeBypass)) { - boolean whitelistEnabled = plugin.getConfig().getBoolean("options.disable_block_breaking.whitelist.enabled"); - List<String> whitelistedWorlds = plugin.getConfig().getStringList("options.disable_block_breaking.whitelist.worlds"); + boolean whitelistEnabled = plugin.getConfiguration().options.disableBlockBreaking.whitelist.enabled; + List<String> whitelistedWorlds = plugin.getConfiguration().options.disableBlockBreaking.whitelist.worlds; String world = event.getPlayer().getWorld().getName(); if (!whitelistEnabled || whitelistedWorlds.contains(world)) { event.setCancelled(true); @@ -123,12 +123,12 @@ public void onBlockBreak(BlockBreakEvent event) { @EventHandler(priority = EventPriority.LOWEST) public void onBlockInteraction(PlayerInteractEvent event) { - boolean enabled = plugin.getConfig().getBoolean("options.disable_block_interaction.enabled"); + boolean enabled = plugin.getConfiguration().options.disableBlockInteraction.enabled; if (enabled) { - boolean creativeBypass = plugin.getConfig().getBoolean("options.disable_block_interaction.creative_bypass"); + boolean creativeBypass = plugin.getConfiguration().options.disableBlockInteraction.creativeBypass; if (!(event.getPlayer().getGameMode() == GameMode.CREATIVE && creativeBypass)) { - boolean whitelistEnabled = plugin.getConfig().getBoolean("options.disable_block_interaction.whitelist.enabled"); - List<String> whitelistedWorlds = plugin.getConfig().getStringList("options.disable_block_interaction.whitelist.worlds"); + boolean whitelistEnabled = plugin.getConfiguration().options.disableBlockInteraction.whitelist.enabled; + List<String> whitelistedWorlds = plugin.getConfiguration().options.disableBlockInteraction.whitelist.worlds; String world = event.getPlayer().getWorld().getName(); if (!whitelistEnabled || whitelistedWorlds.contains(world)) { diff --git a/src/main/java/top/vulpine/simpleLobby/utils/PlayerUtils.java b/src/main/java/top/vulpine/simpleLobby/utils/PlayerUtils.java index df76bd1..732541d 100644 --- a/src/main/java/top/vulpine/simpleLobby/utils/PlayerUtils.java +++ b/src/main/java/top/vulpine/simpleLobby/utils/PlayerUtils.java @@ -1,9 +1,5 @@ package top.vulpine.simpleLobby.utils; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import top.vulpine.simpleLobby.SimpleLobby; import top.vulpine.simpleLobby.utils.logger.Logger; @@ -21,23 +17,12 @@ public class PlayerUtils { */ public static void teleportPlayer(SimpleLobby plugin, Player player) { - FileConfiguration config = plugin.getConfig(); + plugin.getScheduler().teleport(player, plugin.getConfiguration().spawn.location); - World world = Bukkit.getWorld(config.getString("spawn.location.world")); - if (world == null) { - Logger.warn("World does not exist"); - return; - } - - double x = config.getDouble("spawn.location.x"); - double y = config.getDouble("spawn.location.y"); - double z = config.getDouble("spawn.location.z"); - float yaw = (float) config.getDouble("spawn.location.yaw"); - float pitch = (float) config.getDouble("spawn.location.pitch"); - - plugin.getScheduler().teleport(player, new Location(world, x, y, z, yaw, pitch)); - - Logger.debug("Teleported player " + player.getName() + " to spawn at " + world + " (" + x + ", " + y + ", " + z + ")"); + Logger.debug("Teleported player " + player.getName() + " to spawn at " + plugin.getConfiguration().spawn.location.getWorld() + " (" + + plugin.getConfiguration().spawn.location.getX() + ", " + + plugin.getConfiguration().spawn.location.getY() + ", " + + plugin.getConfiguration().spawn.location.getZ() + ")"); } From 21722d70ded99c8e433f74f6a787ecb45e148df2 Mon Sep 17 00:00:00 2001 From: VulpineFriend87 <vulpinefriend87@gmail.com> Date: Tue, 26 May 2026 14:40:48 +0200 Subject: [PATCH 2/4] refactor(config): rely on enclosing-class @Names inheritance --- .../top/vulpine/simpleLobby/SimpleLobby.java | 2 +- .../command/subCommands/ReloadSubCommand.java | 2 +- .../subCommands/SetSpawnSubCommand.java | 2 +- .../simpleLobby/config/BaseConfig.java | 10 +++ .../simpleLobby/config/{ => impl}/Config.java | 80 +++++++------------ 5 files changed, 40 insertions(+), 56 deletions(-) create mode 100644 src/main/java/top/vulpine/simpleLobby/config/BaseConfig.java rename src/main/java/top/vulpine/simpleLobby/config/{ => impl}/Config.java (68%) diff --git a/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java b/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java index aa9f554..b4bfe7e 100644 --- a/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java +++ b/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java @@ -8,7 +8,7 @@ import org.bukkit.plugin.java.JavaPlugin; import top.vulpine.simpleLobby.command.SimpleLobbyCommand; import top.vulpine.simpleLobby.command.SpawnCommand; -import top.vulpine.simpleLobby.config.Config; +import top.vulpine.simpleLobby.config.impl.Config; import top.vulpine.simpleLobby.listener.PlayerListener; import top.vulpine.simpleLobby.listener.WorldListener; import top.vulpine.simpleLobby.scheduler.BukkitSchedulerAdapter; diff --git a/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java b/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java index ae21d7c..1359573 100644 --- a/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java +++ b/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java @@ -3,7 +3,7 @@ import lombok.Getter; import org.bukkit.command.CommandSender; import top.vulpine.simpleLobby.command.SimpleLobbyCommand; -import top.vulpine.simpleLobby.config.Config; +import top.vulpine.simpleLobby.config.impl.Config; import top.vulpine.simpleLobby.instance.SubCommand; import top.vulpine.simpleLobby.utils.Colorize; diff --git a/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java b/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java index 5ebca0e..fe1989f 100644 --- a/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java +++ b/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import top.vulpine.simpleLobby.SimpleLobby; import top.vulpine.simpleLobby.command.SimpleLobbyCommand; -import top.vulpine.simpleLobby.config.Config; +import top.vulpine.simpleLobby.config.impl.Config; import top.vulpine.simpleLobby.instance.SubCommand; import top.vulpine.simpleLobby.utils.Colorize; diff --git a/src/main/java/top/vulpine/simpleLobby/config/BaseConfig.java b/src/main/java/top/vulpine/simpleLobby/config/BaseConfig.java new file mode 100644 index 0000000..f0263b3 --- /dev/null +++ b/src/main/java/top/vulpine/simpleLobby/config/BaseConfig.java @@ -0,0 +1,10 @@ +package top.vulpine.simpleLobby.config; + +import eu.okaeri.configs.OkaeriConfig; +import eu.okaeri.configs.annotation.NameModifier; +import eu.okaeri.configs.annotation.NameStrategy; +import eu.okaeri.configs.annotation.Names; + +@SuppressWarnings("deprecation") +@Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) +public abstract class BaseConfig extends OkaeriConfig {} \ No newline at end of file diff --git a/src/main/java/top/vulpine/simpleLobby/config/Config.java b/src/main/java/top/vulpine/simpleLobby/config/impl/Config.java similarity index 68% rename from src/main/java/top/vulpine/simpleLobby/config/Config.java rename to src/main/java/top/vulpine/simpleLobby/config/impl/Config.java index 8497e47..6d8aaf5 100644 --- a/src/main/java/top/vulpine/simpleLobby/config/Config.java +++ b/src/main/java/top/vulpine/simpleLobby/config/impl/Config.java @@ -1,12 +1,9 @@ -package top.vulpine.simpleLobby.config; +package top.vulpine.simpleLobby.config.impl; -import eu.okaeri.configs.OkaeriConfig; import eu.okaeri.configs.annotation.Comment; import eu.okaeri.configs.annotation.Header; -import eu.okaeri.configs.annotation.NameModifier; -import eu.okaeri.configs.annotation.NameStrategy; -import eu.okaeri.configs.annotation.Names; import org.bukkit.Location; +import top.vulpine.simpleLobby.config.BaseConfig; import top.vulpine.simpleLobby.utils.logger.LogLevel; import java.util.ArrayList; @@ -27,18 +24,15 @@ @Header("- \"[SOUND] <global/player>; <sound>; [volume]; [pitch]\"") @Header("- \"[DELAY] <milliseconds>\"") @Header("") -@Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) -public class Config extends OkaeriConfig { +public class Config extends BaseConfig { public Spawn spawn = new Spawn(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Spawn extends OkaeriConfig { + public static class Spawn extends BaseConfig { public Command command = new Command(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Command extends OkaeriConfig { + public static class Command extends BaseConfig { @Comment("If enabled, players can use the '/spawn' command to teleport to spawn") public boolean enabled = true; @@ -46,8 +40,7 @@ public static class Command extends OkaeriConfig { @Comment("If enabled, players will have to wait a certain amount of time before being teleported to spawn") public Delay delay = new Delay(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Delay extends OkaeriConfig { + public static class Delay extends BaseConfig { public boolean enabled = false; @@ -70,8 +63,7 @@ public static class Delay extends OkaeriConfig { @Comment("Placeholders: any PlaceholderAPI placeholder (if installed)") public Actions actions = new Actions(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Actions extends OkaeriConfig { + public static class Actions extends BaseConfig { @Comment("[actions] Placeholders: %time%; requires spawn command delay to be enabled") public List<String> delayStarted = new ArrayList<>(List.of( @@ -99,13 +91,11 @@ public static class Actions extends OkaeriConfig { public Actions actions = new Actions(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Actions extends OkaeriConfig { + public static class Actions extends BaseConfig { public Join join = new Join(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Join extends OkaeriConfig { + public static class Join extends BaseConfig { @Comment("If true, the default join message will not be shown") public boolean suppressDefaultMessage = true; @@ -123,8 +113,7 @@ public static class Join extends OkaeriConfig { public Quit quit = new Quit(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Quit extends OkaeriConfig { + public static class Quit extends BaseConfig { @Comment("If true, the default quit message will not be shown") public boolean suppressDefaultMessage = true; @@ -143,20 +132,18 @@ public static class Quit extends OkaeriConfig { @Comment("General world options") public Options options = new Options(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Options extends OkaeriConfig { + public static class Options extends BaseConfig { public DisableHungerLoss disableHungerLoss = new DisableHungerLoss(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class DisableHungerLoss extends OkaeriConfig { + public static class DisableHungerLoss extends BaseConfig { public boolean enabled = true; public Whitelist whitelist = new Whitelist(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Whitelist extends OkaeriConfig { + + public static class Whitelist extends BaseConfig { public boolean enabled = false; @Comment("List of worlds where hunger loss is disabled") public List<String> worlds = new ArrayList<>(); @@ -166,15 +153,13 @@ public static class Whitelist extends OkaeriConfig { public DisableMobSpawning disableMobSpawning = new DisableMobSpawning(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class DisableMobSpawning extends OkaeriConfig { + public static class DisableMobSpawning extends BaseConfig { public boolean enabled = true; public Whitelist whitelist = new Whitelist(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Whitelist extends OkaeriConfig { + public static class Whitelist extends BaseConfig { public boolean enabled = false; @Comment("List of worlds where mob spawning is disabled") public List<String> worlds = new ArrayList<>(); @@ -184,15 +169,13 @@ public static class Whitelist extends OkaeriConfig { public DisableDamage disableDamage = new DisableDamage(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class DisableDamage extends OkaeriConfig { + public static class DisableDamage extends BaseConfig { public boolean enabled = true; public Whitelist whitelist = new Whitelist(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Whitelist extends OkaeriConfig { + public static class Whitelist extends BaseConfig { public boolean enabled = false; @Comment("List of worlds where damage is disabled") public List<String> worlds = new ArrayList<>(); @@ -202,22 +185,19 @@ public static class Whitelist extends OkaeriConfig { public ClearInventoryOnJoin clearInventoryOnJoin = new ClearInventoryOnJoin(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class ClearInventoryOnJoin extends OkaeriConfig { + public static class ClearInventoryOnJoin extends BaseConfig { public boolean enabled = true; } public ClearEffectsOnJoin clearEffectsOnJoin = new ClearEffectsOnJoin(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class ClearEffectsOnJoin extends OkaeriConfig { + public static class ClearEffectsOnJoin extends BaseConfig { public boolean enabled = false; } public DisableBlockPlacing disableBlockPlacing = new DisableBlockPlacing(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class DisableBlockPlacing extends OkaeriConfig { + public static class DisableBlockPlacing extends BaseConfig { public boolean enabled = true; @@ -226,8 +206,7 @@ public static class DisableBlockPlacing extends OkaeriConfig { public Whitelist whitelist = new Whitelist(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Whitelist extends OkaeriConfig { + public static class Whitelist extends BaseConfig { public boolean enabled = false; @Comment("List of worlds where block placing is disabled") public List<String> worlds = new ArrayList<>(); @@ -237,8 +216,7 @@ public static class Whitelist extends OkaeriConfig { public DisableBlockBreaking disableBlockBreaking = new DisableBlockBreaking(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class DisableBlockBreaking extends OkaeriConfig { + public static class DisableBlockBreaking extends BaseConfig { public boolean enabled = true; @@ -247,8 +225,7 @@ public static class DisableBlockBreaking extends OkaeriConfig { public Whitelist whitelist = new Whitelist(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Whitelist extends OkaeriConfig { + public static class Whitelist extends BaseConfig { public boolean enabled = false; @Comment("List of worlds where block breaking is disabled") public List<String> worlds = new ArrayList<>(); @@ -258,8 +235,7 @@ public static class Whitelist extends OkaeriConfig { public DisableBlockInteraction disableBlockInteraction = new DisableBlockInteraction(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class DisableBlockInteraction extends OkaeriConfig { + public static class DisableBlockInteraction extends BaseConfig { public boolean enabled = true; @@ -268,8 +244,7 @@ public static class DisableBlockInteraction extends OkaeriConfig { public Whitelist whitelist = new Whitelist(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Whitelist extends OkaeriConfig { + public static class Whitelist extends BaseConfig { public boolean enabled = false; @Comment("List of worlds where block interaction is disabled") public List<String> worlds = new ArrayList<>(); @@ -281,8 +256,7 @@ public static class Whitelist extends OkaeriConfig { public Messages messages = new Messages(); - @Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) - public static class Messages extends OkaeriConfig { + public static class Messages extends BaseConfig { public String noPermission = "&7[&f&lS&a&lL&7] &cMissing permission!"; From 9cdc70602c519cb4471615a614faf500d4ab04cb Mon Sep 17 00:00:00 2001 From: VulpineFriend87 <vulpinefriend87@gmail.com> Date: Tue, 26 May 2026 16:28:24 +0200 Subject: [PATCH 3/4] feat(config): implement custom keys and add no spawn set state --- .../top/vulpine/simpleLobby/SimpleLobby.java | 2 +- .../simpleLobby/command/SpawnCommand.java | 6 + .../command/subCommands/ReloadSubCommand.java | 2 +- .../subCommands/SetSpawnSubCommand.java | 2 +- .../simpleLobby/config/BaseConfig.java | 10 -- .../simpleLobby/config/{impl => }/Config.java | 145 ++++++++++++++---- .../simpleLobby/listener/PlayerListener.java | 10 +- 7 files changed, 133 insertions(+), 44 deletions(-) delete mode 100644 src/main/java/top/vulpine/simpleLobby/config/BaseConfig.java rename src/main/java/top/vulpine/simpleLobby/config/{impl => }/Config.java (66%) diff --git a/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java b/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java index b4bfe7e..aa9f554 100644 --- a/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java +++ b/src/main/java/top/vulpine/simpleLobby/SimpleLobby.java @@ -8,7 +8,7 @@ import org.bukkit.plugin.java.JavaPlugin; import top.vulpine.simpleLobby.command.SimpleLobbyCommand; import top.vulpine.simpleLobby.command.SpawnCommand; -import top.vulpine.simpleLobby.config.impl.Config; +import top.vulpine.simpleLobby.config.Config; import top.vulpine.simpleLobby.listener.PlayerListener; import top.vulpine.simpleLobby.listener.WorldListener; import top.vulpine.simpleLobby.scheduler.BukkitSchedulerAdapter; diff --git a/src/main/java/top/vulpine/simpleLobby/command/SpawnCommand.java b/src/main/java/top/vulpine/simpleLobby/command/SpawnCommand.java index d7da01f..37aaa6a 100644 --- a/src/main/java/top/vulpine/simpleLobby/command/SpawnCommand.java +++ b/src/main/java/top/vulpine/simpleLobby/command/SpawnCommand.java @@ -55,6 +55,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N return true; } + Location spawn = plugin.getConfiguration().spawn.location; + if (spawn == null || spawn.getWorld() == null) { + player.sendMessage(Colorize.color(plugin.getConfiguration().messages.spawnNotSet)); + return true; + } + if (plugin.getConfiguration().spawn.command.delay.enabled) { int seconds = plugin.getConfiguration().spawn.command.delay.time; diff --git a/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java b/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java index 1359573..ae21d7c 100644 --- a/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java +++ b/src/main/java/top/vulpine/simpleLobby/command/subCommands/ReloadSubCommand.java @@ -3,7 +3,7 @@ import lombok.Getter; import org.bukkit.command.CommandSender; import top.vulpine.simpleLobby.command.SimpleLobbyCommand; -import top.vulpine.simpleLobby.config.impl.Config; +import top.vulpine.simpleLobby.config.Config; import top.vulpine.simpleLobby.instance.SubCommand; import top.vulpine.simpleLobby.utils.Colorize; diff --git a/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java b/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java index fe1989f..5ebca0e 100644 --- a/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java +++ b/src/main/java/top/vulpine/simpleLobby/command/subCommands/SetSpawnSubCommand.java @@ -6,7 +6,7 @@ import org.bukkit.entity.Player; import top.vulpine.simpleLobby.SimpleLobby; import top.vulpine.simpleLobby.command.SimpleLobbyCommand; -import top.vulpine.simpleLobby.config.impl.Config; +import top.vulpine.simpleLobby.config.Config; import top.vulpine.simpleLobby.instance.SubCommand; import top.vulpine.simpleLobby.utils.Colorize; diff --git a/src/main/java/top/vulpine/simpleLobby/config/BaseConfig.java b/src/main/java/top/vulpine/simpleLobby/config/BaseConfig.java deleted file mode 100644 index f0263b3..0000000 --- a/src/main/java/top/vulpine/simpleLobby/config/BaseConfig.java +++ /dev/null @@ -1,10 +0,0 @@ -package top.vulpine.simpleLobby.config; - -import eu.okaeri.configs.OkaeriConfig; -import eu.okaeri.configs.annotation.NameModifier; -import eu.okaeri.configs.annotation.NameStrategy; -import eu.okaeri.configs.annotation.Names; - -@SuppressWarnings("deprecation") -@Names(strategy = NameStrategy.SNAKE_CASE, modifier = NameModifier.TO_LOWER_CASE) -public abstract class BaseConfig extends OkaeriConfig {} \ No newline at end of file diff --git a/src/main/java/top/vulpine/simpleLobby/config/impl/Config.java b/src/main/java/top/vulpine/simpleLobby/config/Config.java similarity index 66% rename from src/main/java/top/vulpine/simpleLobby/config/impl/Config.java rename to src/main/java/top/vulpine/simpleLobby/config/Config.java index 6d8aaf5..723c9c9 100644 --- a/src/main/java/top/vulpine/simpleLobby/config/impl/Config.java +++ b/src/main/java/top/vulpine/simpleLobby/config/Config.java @@ -1,9 +1,10 @@ -package top.vulpine.simpleLobby.config.impl; +package top.vulpine.simpleLobby.config; +import eu.okaeri.configs.OkaeriConfig; import eu.okaeri.configs.annotation.Comment; +import eu.okaeri.configs.annotation.CustomKey; import eu.okaeri.configs.annotation.Header; import org.bukkit.Location; -import top.vulpine.simpleLobby.config.BaseConfig; import top.vulpine.simpleLobby.utils.logger.LogLevel; import java.util.ArrayList; @@ -24,30 +25,37 @@ @Header("- \"[SOUND] <global/player>; <sound>; [volume]; [pitch]\"") @Header("- \"[DELAY] <milliseconds>\"") @Header("") -public class Config extends BaseConfig { +public class Config extends OkaeriConfig { + @CustomKey("spawn") public Spawn spawn = new Spawn(); - public static class Spawn extends BaseConfig { + public static class Spawn extends OkaeriConfig { + @CustomKey("command") public Command command = new Command(); - public static class Command extends BaseConfig { + public static class Command extends OkaeriConfig { @Comment("If enabled, players can use the '/spawn' command to teleport to spawn") + @CustomKey("enabled") public boolean enabled = true; @Comment("If enabled, players will have to wait a certain amount of time before being teleported to spawn") + @CustomKey("delay") public Delay delay = new Delay(); - public static class Delay extends BaseConfig { + public static class Delay extends OkaeriConfig { + @CustomKey("enabled") public boolean enabled = false; @Comment("Time in seconds") + @CustomKey("time") public int time = 3; @Comment("If true, the player must not move during the delay time, or else the teleport will be canceled") + @CustomKey("require_player_still") public boolean requirePlayerStill = true; } @@ -55,32 +63,39 @@ public static class Delay extends BaseConfig { } @Comment("If true, players will be teleported to spawn when they join the server") + @CustomKey("tp_on_join") public boolean tpOnJoin = false; @Comment("Can be set using the '/sl setspawn' command in-game") - public Location location = new Location(null, 0, 64, 0, 0, 0); + @CustomKey("location") + public Location location = null; @Comment("Placeholders: any PlaceholderAPI placeholder (if installed)") + @CustomKey("actions") public Actions actions = new Actions(); - public static class Actions extends BaseConfig { + public static class Actions extends OkaeriConfig { @Comment("[actions] Placeholders: %time%; requires spawn command delay to be enabled") + @CustomKey("delay_started") public List<String> delayStarted = new ArrayList<>(List.of( "[MESSAGE] player; &7[&f&lS&a&lL&7] &aYou will be teleported to spawn in %time% second(s)" )); @Comment("[actions] Placeholders: %time%; requires spawn command delay to be enabled and require_player_still to be true") + @CustomKey("delay_started_still") public List<String> delayStartedStill = new ArrayList<>(List.of( "[MESSAGE] player; &7[&f&lS&a&lL&7] &aYou will be teleported to spawn in %time% second(s). Do not move." )); @Comment("[actions] Requires spawn command delay to be enabled and require_player_still to be true") + @CustomKey("teleport_canceled") public List<String> teleportCanceled = new ArrayList<>(List.of( "[MESSAGE] player; &7[&f&lS&a&lL&7] &cTeleport to spawn canceled, you moved." )); @Comment("[actions]") + @CustomKey("teleported") public List<String> teleported = new ArrayList<>(List.of( "[MESSAGE] player; &7[&f&lS&a&lL&7] &aYou have been teleported to spawn." )); @@ -89,20 +104,25 @@ public static class Actions extends BaseConfig { } + @CustomKey("actions") public Actions actions = new Actions(); - public static class Actions extends BaseConfig { + public static class Actions extends OkaeriConfig { + @CustomKey("join") public Join join = new Join(); - public static class Join extends BaseConfig { + public static class Join extends OkaeriConfig { @Comment("If true, the default join message will not be shown") + @CustomKey("suppress_default_message") public boolean suppressDefaultMessage = true; + @CustomKey("enabled") public boolean enabled = true; @Comment("[actions] Placeholders: %player%, any PlaceholderAPI placeholder (if installed)") + @CustomKey("actions") public List<String> actions = new ArrayList<>(List.of( "[TITLE] player; &bWelcome to the server!; &7Enjoy your stay!; 20; 60; 20", "[MESSAGE] global; &b%player% &7has joined the server.", @@ -111,16 +131,20 @@ public static class Join extends BaseConfig { } + @CustomKey("quit") public Quit quit = new Quit(); - public static class Quit extends BaseConfig { + public static class Quit extends OkaeriConfig { @Comment("If true, the default quit message will not be shown") + @CustomKey("suppress_default_message") public boolean suppressDefaultMessage = true; + @CustomKey("enabled") public boolean enabled = true; @Comment("[actions] Placeholders: %player%, any PlaceholderAPI placeholder (if installed)") + @CustomKey("actions") public List<String> actions = new ArrayList<>(List.of( "[MESSAGE] global; &b%player% &7has left the server." )); @@ -130,150 +154,215 @@ public static class Quit extends BaseConfig { } @Comment("General world options") + @CustomKey("options") public Options options = new Options(); - public static class Options extends BaseConfig { + public static class Options extends OkaeriConfig { + @CustomKey("disable_hunger_loss") public DisableHungerLoss disableHungerLoss = new DisableHungerLoss(); - public static class DisableHungerLoss extends BaseConfig { + public static class DisableHungerLoss extends OkaeriConfig { + @CustomKey("enabled") public boolean enabled = true; + @CustomKey("whitelist") public Whitelist whitelist = new Whitelist(); - - public static class Whitelist extends BaseConfig { + public static class Whitelist extends OkaeriConfig { + + @CustomKey("enabled") public boolean enabled = false; + @Comment("List of worlds where hunger loss is disabled") + @CustomKey("worlds") public List<String> worlds = new ArrayList<>(); + } } + @CustomKey("disable_mob_spawning") public DisableMobSpawning disableMobSpawning = new DisableMobSpawning(); - public static class DisableMobSpawning extends BaseConfig { + public static class DisableMobSpawning extends OkaeriConfig { + @CustomKey("enabled") public boolean enabled = true; + @CustomKey("whitelist") public Whitelist whitelist = new Whitelist(); - public static class Whitelist extends BaseConfig { + public static class Whitelist extends OkaeriConfig { + + @CustomKey("enabled") public boolean enabled = false; + @Comment("List of worlds where mob spawning is disabled") + @CustomKey("worlds") public List<String> worlds = new ArrayList<>(); + } } + @CustomKey("disable_damage") public DisableDamage disableDamage = new DisableDamage(); - public static class DisableDamage extends BaseConfig { + public static class DisableDamage extends OkaeriConfig { + @CustomKey("enabled") public boolean enabled = true; + @CustomKey("whitelist") public Whitelist whitelist = new Whitelist(); - public static class Whitelist extends BaseConfig { + public static class Whitelist extends OkaeriConfig { + + @CustomKey("enabled") public boolean enabled = false; @Comment("List of worlds where damage is disabled") + + @CustomKey("worlds") public List<String> worlds = new ArrayList<>(); + } } + @CustomKey("clear_inventory_on_join") public ClearInventoryOnJoin clearInventoryOnJoin = new ClearInventoryOnJoin(); - public static class ClearInventoryOnJoin extends BaseConfig { + public static class ClearInventoryOnJoin extends OkaeriConfig { + @CustomKey("enabled") public boolean enabled = true; } + @CustomKey("clear_effects_on_join") public ClearEffectsOnJoin clearEffectsOnJoin = new ClearEffectsOnJoin(); - public static class ClearEffectsOnJoin extends BaseConfig { + public static class ClearEffectsOnJoin extends OkaeriConfig { + @CustomKey("enabled") public boolean enabled = false; } + @CustomKey("disable_block_placing") public DisableBlockPlacing disableBlockPlacing = new DisableBlockPlacing(); - public static class DisableBlockPlacing extends BaseConfig { + public static class DisableBlockPlacing extends OkaeriConfig { + @CustomKey("enabled") public boolean enabled = true; @Comment("If true, players in creative mode can place blocks") + @CustomKey("creative_bypass") public boolean creativeBypass = true; + @CustomKey("whitelist") public Whitelist whitelist = new Whitelist(); - public static class Whitelist extends BaseConfig { + public static class Whitelist extends OkaeriConfig { + + @CustomKey("enabled") public boolean enabled = false; + @Comment("List of worlds where block placing is disabled") + @CustomKey("worlds") public List<String> worlds = new ArrayList<>(); + } } + @CustomKey("disable_block_breaking") public DisableBlockBreaking disableBlockBreaking = new DisableBlockBreaking(); - public static class DisableBlockBreaking extends BaseConfig { + public static class DisableBlockBreaking extends OkaeriConfig { + @CustomKey("enabled") public boolean enabled = true; @Comment("If true, players in creative mode can break blocks") + @CustomKey("creative_bypass") public boolean creativeBypass = true; + @CustomKey("whitelist") public Whitelist whitelist = new Whitelist(); - public static class Whitelist extends BaseConfig { + public static class Whitelist extends OkaeriConfig { + + @CustomKey("enabled") public boolean enabled = false; + @Comment("List of worlds where block breaking is disabled") + @CustomKey("worlds") public List<String> worlds = new ArrayList<>(); + } } + @CustomKey("disable_block_interaction") public DisableBlockInteraction disableBlockInteraction = new DisableBlockInteraction(); - public static class DisableBlockInteraction extends BaseConfig { + public static class DisableBlockInteraction extends OkaeriConfig { + @CustomKey("enabled") public boolean enabled = true; @Comment("If true, players in creative mode can interact with blocks") + @CustomKey("creative_bypass") public boolean creativeBypass = true; + @CustomKey("whitelist") public Whitelist whitelist = new Whitelist(); - public static class Whitelist extends BaseConfig { + public static class Whitelist extends OkaeriConfig { + + @CustomKey("enabled") public boolean enabled = false; + @Comment("List of worlds where block interaction is disabled") + @CustomKey("worlds") public List<String> worlds = new ArrayList<>(); + } } } + @CustomKey("messages") public Messages messages = new Messages(); - public static class Messages extends BaseConfig { + public static class Messages extends OkaeriConfig { + @CustomKey("no_permission") public String noPermission = "&7[&f&lS&a&lL&7] &cMissing permission!"; + @CustomKey("only_players") public String onlyPlayers = "&7[&f&lS&a&lL&7] &cThis command can only be executed by players."; @Comment("Placeholders: %time%") + @CustomKey("reloaded") public String reloaded = "&7[&f&lS&a&lL&7] &aConfiguration reloaded in &f%time%ms&a."; @Comment("Placeholders: %world%, %x%, %y%, %z%, %yaw%, %pitch%") + @CustomKey("spawn_set") public String spawnSet = "&7[&f&lS&a&lL&7] &aSuccessfully set the spawn in &f%world%&a at &f%x%&a, &f%y%&a, &f%z%&a, &fyaw:%yaw%&a, &fpitch:%pitch%&a."; + @CustomKey("spawn_not_set") + public String spawnNotSet = "&7[&f&lS&a&lL&7] &cThe spawn has not been set yet. Contact an administrator."; + + @CustomKey("unknown_command") public String unknownCommand = "&7[&f&lS&a&lL&7] &cUnknown command!"; } @Comment("Log level for the plugin. Can be: DEBUG, INFO, WARN, ERROR.") @Comment("Leave as it is if you don't know what to choose.") + @CustomKey("log_level") public LogLevel logLevel = LogLevel.INFO; } diff --git a/src/main/java/top/vulpine/simpleLobby/listener/PlayerListener.java b/src/main/java/top/vulpine/simpleLobby/listener/PlayerListener.java index 95c3066..cf2c9d8 100644 --- a/src/main/java/top/vulpine/simpleLobby/listener/PlayerListener.java +++ b/src/main/java/top/vulpine/simpleLobby/listener/PlayerListener.java @@ -1,6 +1,5 @@ package top.vulpine.simpleLobby.listener; -import org.bukkit.World; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; @@ -60,8 +59,13 @@ public void onPlayerJoin(PlayerJoinEvent event) { if (plugin.getConfiguration().spawn.tpOnJoin) { - World world = plugin.getConfiguration().spawn.location.getWorld(); - PlayerUtils.teleportPlayer(plugin, event.getPlayer()); + org.bukkit.Location spawn = plugin.getConfiguration().spawn.location; + if (spawn == null || spawn.getWorld() == null) { + Logger.warn("tp_on_join is enabled but the spawn location is not set. Skipping teleport for " + + event.getPlayer().getName() + "."); + } else { + PlayerUtils.teleportPlayer(plugin, event.getPlayer()); + } } From 55c7ee0e3dcab8f6049387e3725e47dd91c9d434 Mon Sep 17 00:00:00 2001 From: VulpineFriend87 <vulpinefriend87@gmail.com> Date: Tue, 26 May 2026 20:28:57 +0200 Subject: [PATCH 4/4] chore: remove old config file --- src/main/resources/config.yml | 103 ---------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 src/main/resources/config.yml diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml deleted file mode 100644 index f722ce0..0000000 --- a/src/main/resources/config.yml +++ /dev/null @@ -1,103 +0,0 @@ -# Simple Lobby Configuration - By Vulpine (https://vulpine.top) - -# Wherever you see the [actions] tag, you can put in a list all the actions you want to perform in order. -# These are the actions you can use: -# -# <required> [optional] -# -# - "[COMMAND] <console/player>; <command without slash>" -# - "[GAMEMODE] <global/player>; <gamemode>" -# - "[TITLE] <global/player>; <title>; [subtitle]; [fadeIn]; [stay]; [fadeOut]" -# - "[ACTIONBAR] <global/player>; <message>" -# - "[MESSAGE] <global/player>; <message>" -# - "[SOUND] <global/player>; <sound>; [volume]; [pitch]" -# - "[DELAY] <milliseconds>" - -spawn: - command: # If enabled, players can use the '/spawn' command to teleport to spawn - enabled: true - delay: # If enabled, players will have to wait a certain amount of time before being teleported to spawn - enabled: false - time: 3 # Time in seconds - require_player_still: true # If true, the player must not move during the delay time, or else the teleport will be canceled - tp_on_join: false # If true, players will be teleported to spawn when they join the server - location: # Can be set using the '/sl setspawn' command in-game - world: world - x: 0 - y: 0 - z: 0 - yaw: 0 - pitch: 0 - actions: # Placeholders: any PlaceholderAPI placeholder (if installed) - delay_started: # [actions] Placeholders: %time%; requires spawn command delay to be enabled - - "[MESSAGE] player; &7[&f&lS&a&lL&7] &aYou will be teleported to spawn in %time% second(s)" - delay_started_still: # [actions] Placeholders: %time%; requires spawn command delay to be enabled and require_player_still to be true - - "[MESSAGE] player; &7[&f&lS&a&lL&7] &aYou will be teleported to spawn in %time% second(s). Do not move." - teleport_canceled: # [actions] Requires spawn command delay to be enabled and require_player_still to be true - - "[MESSAGE] player; &7[&f&lS&a&lL&7] &cTeleport to spawn canceled, you moved." - teleported: # [actions] - - "[MESSAGE] player; &7[&f&lS&a&lL&7] &aYou have been teleported to spawn." - -actions: - join: - suppress_default_message: true # If true, the default join message will not be shown - enabled: true - actions: # [actions] Placeholders: %player%, any PlaceholderAPI placeholder (if installed) - - "[TITLE] player; &bWelcome to the server!; &7Enjoy your stay!; 20; 60; 20" - - "[MESSAGE] global; &b%player% &7has joined the server." - - "[GAMEMODE] player; adventure" - quit: - suppress_default_message: true # If true, the default quit message will not be shown - enabled: true - actions: # [actions] Placeholders: %player%, any PlaceholderAPI placeholder (if installed) - - "[MESSAGE] global; &b%player% &7has left the server." - -options: # General world options - disable_hunger_loss: - enabled: true - whitelist: - enabled: false - worlds: [] # List of worlds where hunger loss is disabled - disable_mob_spawning: - enabled: true - whitelist: - enabled: false - worlds: [] # List of worlds where mob spawning is disabled - disable_damage: - enabled: true - whitelist: - enabled: false - worlds: [] # List of worlds where damage is disabled - clear_inventory_on_join: - enabled: true - clear_effects_on_join: - enabled: false - disable_block_placing: - enabled: true - creative_bypass: true # If true, players in creative mode can place blocks - whitelist: - enabled: false - worlds: [] # List of worlds where block placing is disabled - disable_block_breaking: - enabled: true - creative_bypass: true # If true, players in creative mode can break blocks - whitelist: - enabled: false - worlds: [] # List of worlds where block breaking is disabled - disable_block_interaction: - enabled: true - creative_bypass: true # If true, players in creative mode can interact with blocks - whitelist: - enabled: false - worlds: [] # List of worlds where block interaction is disabled - -messages: - no_permission: "&7[&f&lS&a&lL&7] &cMissing permission!" - only_players: "&7[&f&lS&a&lL&7] &cThis command can only be executed by players." - reloaded: "&7[&f&lS&a&lL&7] &aConfiguration reloaded in &f%time%ms&a." # Placeholders: %time% - spawn_set: "&7[&f&lS&a&lL&7] &aSuccessfully set the spawn in &f%world%&a at &f%x%&a, &f%y%&a, &f%z%&a, &fyaw:%yaw%&a, &fpitch:%pitch%&a." # Placeholders: %world%, %x%, %y%, %z%, %yaw%, %pitch% - unknown_command: "&7[&f&lS&a&lL&7] &cUnknown command!" - -# Log level for the plugin. Can be: DEBUG, INFO, WARN, ERROR. -# Leave as it is if you don't know what to choose. -log_level: INFO \ No newline at end of file