diff options
Diffstat (limited to 'src/main/java/cat/freya/khs/command/Send.java')
-rw-r--r-- | src/main/java/cat/freya/khs/command/Send.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/java/cat/freya/khs/command/Send.java b/src/main/java/cat/freya/khs/command/Send.java new file mode 100644 index 0000000..1f110b8 --- /dev/null +++ b/src/main/java/cat/freya/khs/command/Send.java @@ -0,0 +1,68 @@ +package cat.freya.khs.command; + +import cat.freya.khs.Main; +import cat.freya.khs.command.util.ICommand; +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.List; +import java.util.stream.Collectors; + +public class Send implements ICommand { + + public void execute(Player sender, String[] args) { + + if (Main.getInstance().getGame().getStatus() != Status.STANDBY) { + sender.sendMessage(Config.errorPrefix + Localization.message("GAME_INPROGRESS")); + return; + } + + Map map = Maps.getMap(args[0]); + if(map == null) { + sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP")); + return; + } + + if(map.isNotSetup()){ + sender.sendMessage(Config.errorPrefix + Localization.message("MAP_NOT_SETUP")); + return; + } + + if (!Main.getInstance().getBoard().contains(sender)) { + sender.sendMessage(Config.errorPrefix + Localization.message("GAME_NOT_INGAME")); + return; + } + + Main.getInstance().getGame().setCurrentMap(map); + Main.getInstance().getBoard().reloadLobbyBoards(); + for(Player player : Main.getInstance().getBoard().getPlayers()) { + map.getLobby().teleport(player); + } + + } + + public String getLabel() { + return "send"; + } + + public String getUsage() { + return "<map>"; + } + + public String getDescription() { + return "Set the current lobby to another map"; + } + + public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) { + if(parameter.equals("map")) { + return Maps.getAllMaps().stream().filter(map -> !map.isNotSetup()).map(Map::getName).collect(Collectors.toList()); + } + return null; + } + +}
\ No newline at end of file |