diff options
author | tylermurphy534 <tylerm@tylerm.dev> | 2023-07-30 22:13:49 +0000 |
---|---|---|
committer | tylermurphy534 <tylerm@tylerm.dev> | 2023-07-30 22:13:49 +0000 |
commit | a2ea5a635e1b841f58c05ca07e4b547a38fe3433 (patch) | |
tree | 5217465c967796680cc03b11359490f638d6b78c /src/main/java/dev/tylerm/khs/command/location | |
parent | Update 'README.md' (diff) | |
parent | 1.7.5 rc4 (diff) | |
download | kenshinshideandseek-a2ea5a635e1b841f58c05ca07e4b547a38fe3433.tar.gz kenshinshideandseek-a2ea5a635e1b841f58c05ca07e4b547a38fe3433.tar.bz2 kenshinshideandseek-a2ea5a635e1b841f58c05ca07e4b547a38fe3433.zip |
Merge pull request '1.7.5' (#10) from dev into main
Reviewed-on: https://g.tylerm.dev/tylermurphy534/KenshinsHideAndSeek/pulls/10
Diffstat (limited to 'src/main/java/dev/tylerm/khs/command/location')
-rw-r--r-- | src/main/java/dev/tylerm/khs/command/location/LocationUtils.java | 52 | ||||
-rw-r--r-- | src/main/java/dev/tylerm/khs/command/location/Locations.java | 17 |
2 files changed, 69 insertions, 0 deletions
diff --git a/src/main/java/dev/tylerm/khs/command/location/LocationUtils.java b/src/main/java/dev/tylerm/khs/command/location/LocationUtils.java new file mode 100644 index 0000000..8c8e3f7 --- /dev/null +++ b/src/main/java/dev/tylerm/khs/command/location/LocationUtils.java @@ -0,0 +1,52 @@ +package dev.tylerm.khs.command.location; + +import dev.tylerm.khs.Main; +import dev.tylerm.khs.configuration.Config; +import dev.tylerm.khs.configuration.Localization; +import dev.tylerm.khs.configuration.Map; +import dev.tylerm.khs.configuration.Maps; +import dev.tylerm.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/dev/tylerm/khs/command/location/Locations.java b/src/main/java/dev/tylerm/khs/command/location/Locations.java new file mode 100644 index 0000000..c3d505c --- /dev/null +++ b/src/main/java/dev/tylerm/khs/command/location/Locations.java @@ -0,0 +1,17 @@ +package dev.tylerm.khs.command.location; + +/** + * @author bobby29831 + */ +public enum Locations { + + GAME, + LOBBY, + EXIT, + SEEKER; + + public String message() { + return this + "_SPAWN"; + } + +}
\ No newline at end of file |