From 67aba9081bb73aeaa822b059e8ca6defc8352a2f Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sat, 6 Sep 2025 23:11:25 -0400 Subject: rename pacakges dev.tylerm -> cat.freya --- .../freya/khs/command/location/LocationUtils.java | 52 ++++++++++++++++++++++ .../cat/freya/khs/command/location/Locations.java | 17 +++++++ 2 files changed, 69 insertions(+) create mode 100644 src/main/java/cat/freya/khs/command/location/LocationUtils.java create mode 100644 src/main/java/cat/freya/khs/command/location/Locations.java (limited to 'src/main/java/cat/freya/khs/command/location') diff --git a/src/main/java/cat/freya/khs/command/location/LocationUtils.java b/src/main/java/cat/freya/khs/command/location/LocationUtils.java new file mode 100644 index 0000000..c914944 --- /dev/null +++ b/src/main/java/cat/freya/khs/command/location/LocationUtils.java @@ -0,0 +1,52 @@ +package cat.freya.khs.command.location; + +import cat.freya.khs.Main; +import cat.freya.khs.configuration.Config; +import cat.freya.khs.configuration.Localization; +import cat.freya.khs.configuration.Map; +import cat.freya.khs.configuration.Maps; +import cat.freya.khs.game.util.Status; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.function.Consumer; + +/** + * @author bobby29831 + */ +public class LocationUtils { + + public static void setLocation(@NotNull Player player, @NotNull Locations place, String mapName, @NotNull Consumer consumer) { + + if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { + player.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS")); + return; + } + + if (player.getLocation().getBlockX() == 0 || player.getLocation().getBlockZ() == 0 || player.getLocation().getBlockY() == 0){ + player.sendMessage(Config.errorPrefix + Localization.message("NOT_AT_ZERO")); + return; + } + + Map map = null; + if(mapName != null) { + map = Maps.getMap(mapName); + if (map == null) { + player.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP")); + return; + } + } + + try { + consumer.accept(map); + } catch (Exception e) { + player.sendMessage(Config.errorPrefix + e.getMessage()); + return; + } + + if(map != null) + Maps.setMap(mapName, map); + player.sendMessage(Config.messagePrefix + Localization.message(place.message())); + } + +} \ No newline at end of file diff --git a/src/main/java/cat/freya/khs/command/location/Locations.java b/src/main/java/cat/freya/khs/command/location/Locations.java new file mode 100644 index 0000000..f40419f --- /dev/null +++ b/src/main/java/cat/freya/khs/command/location/Locations.java @@ -0,0 +1,17 @@ +package cat.freya.khs.command.location; + +/** + * @author bobby29831 + */ +public enum Locations { + + GAME, + LOBBY, + EXIT, + SEEKER; + + public String message() { + return this + "_SPAWN"; + } + +} \ No newline at end of file -- cgit v1.2.3-freya