From ea02b866e1f958f68f32a0ebb081cdfc14ff23ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Thu, 11 Aug 2022 21:46:23 +0200 Subject: [PATCH] Add world capability check for setfirework --- .../commands/uhccommands/SetFireworkCommand.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetFireworkCommand.java b/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetFireworkCommand.java index 3b9dd82..9c97281 100644 --- a/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetFireworkCommand.java +++ b/src/main/java/wtf/beatrice/uhccore/commands/uhccommands/SetFireworkCommand.java @@ -1,6 +1,7 @@ package wtf.beatrice.uhccore.commands.uhccommands; import wtf.beatrice.uhccore.utils.Cache; +import wtf.beatrice.uhccore.utils.MessageUtils; import wtf.beatrice.uhccore.utils.configuration.ConfigEntry; import wtf.beatrice.uhccore.utils.Debugger; import wtf.beatrice.uhccore.utils.configuration.FileUtils; @@ -8,6 +9,7 @@ import org.bukkit.Location; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; +import wtf.beatrice.uhccore.utils.configuration.LocalizedMessage; import java.util.logging.Level; @@ -21,6 +23,14 @@ public class SetFireworkCommand Player player = (Player) sender; Location fireworkLoc = player.getLocation(); + String worldName = fireworkLoc.getWorld().getName(); + + if(!Cache.lobbyWorlds.contains(worldName)) + { + MessageUtils.sendLocalizedMessage(sender, LocalizedMessage.ERROR_NOT_IN_LOBBY_WORLD); + return; + } + YamlConfiguration config = FileUtils.FileType.CONFIG_YAML.yaml; int listPos = Cache.fireworksLocations.size() + 1; @@ -41,7 +51,7 @@ public class SetFireworkCommand config.set(currentPath + ".x", fireworkLoc.getX()); config.set(currentPath + ".y", fireworkLoc.getY()); config.set(currentPath + ".z", fireworkLoc.getZ()); - config.set(currentPath + ".world", fireworkLoc.getWorld().getName()); + config.set(currentPath + ".world", worldName); FileUtils.FileType.CONFIG_YAML.yaml = config; FileUtils.saveExistingYaml(FileUtils.FileType.CONFIG_YAML);