diff options
author | Freya Murphy <freya@freyacat.org> | 2025-09-06 23:11:25 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-09-06 23:11:25 -0400 |
commit | 67aba9081bb73aeaa822b059e8ca6defc8352a2f (patch) | |
tree | cba7c5c8c9a0286b491b0b0784a27730ce58696e /src/main/java/cat/freya/khs/command/location | |
parent | add wiki for cgit (diff) | |
download | kenshinshideandseek-67aba9081bb73aeaa822b059e8ca6defc8352a2f.tar.gz kenshinshideandseek-67aba9081bb73aeaa822b059e8ca6defc8352a2f.tar.bz2 kenshinshideandseek-67aba9081bb73aeaa822b059e8ca6defc8352a2f.zip |
rename pacakges dev.tylerm -> cat.freya
Diffstat (limited to 'src/main/java/cat/freya/khs/command/location')
-rw-r--r-- | src/main/java/cat/freya/khs/command/location/LocationUtils.java | 52 | ||||
-rw-r--r-- | src/main/java/cat/freya/khs/command/location/Locations.java | 17 |
2 files changed, 69 insertions, 0 deletions
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<Map> 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 |