diff options
Diffstat (limited to 'src/main/java/cat/freya/khs/command/map/Status.java')
-rw-r--r-- | src/main/java/cat/freya/khs/command/map/Status.java | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/main/java/cat/freya/khs/command/map/Status.java b/src/main/java/cat/freya/khs/command/map/Status.java new file mode 100644 index 0000000..e62e10d --- /dev/null +++ b/src/main/java/cat/freya/khs/command/map/Status.java @@ -0,0 +1,79 @@ +package cat.freya.khs.command.map; + +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 org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.stream.Collectors; + +public class Status implements ICommand { + + public void execute(Player sender, String[] args) { + + String msg = Localization.message("SETUP").toString(); + int count = 0; + Map map = Maps.getMap(args[0]); + if(map == null) { + sender.sendMessage(Config.errorPrefix + Localization.message("INVALID_MAP")); + return; + } + if (map.getSpawn().getBlockX() == 0 && map.getSpawn().getBlockY() == 0 && map.getSpawn().getBlockZ() == 0 || !map.getSpawn().exists()) { + msg = msg + "\n" + Localization.message("SETUP_GAME"); + count++; + } + if (map.getLobby().getBlockX() == 0 && map.getLobby().getBlockY() == 0 && map.getLobby().getBlockZ() == 0 || !map.getLobby().exists()) { + msg = msg + "\n" + Localization.message("SETUP_LOBBY"); + count++; + } + if (map.getSeekerLobby().getBlockX() == 0 && map.getSeekerLobby().getBlockY() == 0 && map.getSeekerLobby().getBlockZ() == 0 || !map.getSeekerLobby().exists()) { + msg = msg + "\n" + Localization.message("SETUP_SEEKER_LOBBY"); + count++; + } + if (Config.exitPosition.getBlockX() == 0 && Config.exitPosition.getBlockY() == 0 && Config.exitPosition.getBlockZ() == 0 || !Config.exitPosition.exists()) { + msg = msg + "\n" + Localization.message("SETUP_EXIT"); + count++; + } + if (map.isBoundsNotSetup()) { + msg = msg + "\n" + Localization.message("SETUP_BOUNDS"); + count++; + } + if (Config.mapSaveEnabled && !map.getGameSpawn().exists()) { + msg = msg + "\n" + Localization.message("SETUP_SAVEMAP"); + count++; + } + if (map.isBlockHuntEnabled() && map.getBlockHunt().isEmpty()) { + msg = msg + "\n" + Localization.message("SETUP_BLOCKHUNT"); + count++; + } + if (count < 1) { + sender.sendMessage(Config.messagePrefix + Localization.message("SETUP_COMPLETE")); + } else { + sender.sendMessage(msg); + } + } + + public String getLabel() { + return "status"; + } + + public String getUsage() { + return "<map>"; + } + + public String getDescription() { + return "Shows what needs to be setup on a map"; + } + + public List<String> autoComplete(@NotNull String parameter, @NotNull String typed) { + if(parameter.equals("map")) { + return Maps.getAllMaps().stream().map(Map::getName).collect(Collectors.toList()); + } + return null; + } + +} |