// Path: src/main/java/com/endercrest/voidspawn/CommandHandler.java
// public class CommandHandler implements CommandExecutor {
//     private final VoidSpawn plugin;
//     private final HashMap<String, SubCommand> commands = new HashMap<>();
// 
//     public CommandHandler(VoidSpawn plugin){
//         this.plugin = plugin;
//         loadCommands();
//     }
// 
//     /**
//      * Load the commands into the HashMap that makes it accessible to players.
//      */
//     private void loadCommands(){
//         commands.put("set", new SetCommand());
//         commands.put("remove", new RemoveCommand());
//         commands.put("reload", new ReloadCommand());
//         commands.put("modes", new ModesCommand());
//         commands.put("mode", new ModeCommand());
//         commands.put("help", new HelpCommand(commands));
//         commands.put("toggle", new ToggleCommand());
//         commands.put("detector", new DetectorCommand());
//         commands.put("info", new InfoCommand());
//         commands.put("option", new OptionCommand());
//     }
// 
//     public Set<Map.Entry<String, SubCommand>> getCommands() {
//         return commands.entrySet();
//     }
// 
//     public SubCommand getSubCommand(String cmd) {
//         return commands.get(cmd);
//     }
// 
//     @Override
//     public boolean onCommand(@NotNull CommandSender cs, @NotNull Command cmd, @NotNull String s, String[] args){
//         if(!(cs instanceof Player)){
//             if((args.length >= 1) && (args[0].equalsIgnoreCase("reload"))){
//                 ConfigManager.getInstance().reloadConfig();
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&6Plugin Reloaded"));
//                 return true;
//             }
// 
//             cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cOnly Players can use these commands"));
//             return false;
//         }
//         if(cmd.getName().equalsIgnoreCase("voidspawn")){
//             if((args == null) || (args.length < 1)){
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Version &6" + plugin.getDescription().getVersion() + "&f by &6EnderCrest"));
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
//                 return true;
//             }
//             String sub = args[0].toLowerCase();
//             if(!commands.containsKey(sub)){
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cThat command does not exist"));
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
//                 return true;
//             }
//             SubCommand command = commands.get(sub);
//             Player player = (Player)cs;
//             if(command.permission() != null && !player.hasPermission(command.permission())) {
//                 player.sendMessage(MessageUtil.colorize("&cYou do not have permission."));
//                 return true;
//             }
// 
// 
//             try {
//                 command.onCommand(player, args);
//             } catch (Exception e) {
//                 e.printStackTrace();
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cThere was an error"));
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
//             }
//         }
//         return false;
//     }
// }
// 
// Path: src/main/java/com/endercrest/voidspawn/utils/WorldUtil.java
// public class WorldUtil {
// 
//     public static String configSafe(String worldName){
//         return worldName.replace(" ", "_");
//     }
// 
//     /**
//      * Checks if the selected world is a valid world.
//      *
//      * @param worldName The world name that will be checked.
//      * @return True if the world does not return null.
//      */
//     public static boolean isValidWorld(String worldName){
//         return Bukkit.getWorld(worldName) != null;
//     }
// 
//     /**
//      * get a list of world names that begin with partial. If partial is
//      * empty, all worlds are returned.
//      * @param partial String to compare against.
//      * @return List of world names.
//      */
//     public static List<String> getMatchingWorlds(String partial) {
//         return Bukkit.getWorlds().stream()
//                 .map(World::getName)
//                 .filter(world -> world.toLowerCase().startsWith(partial.toLowerCase()))
//                 .collect(Collectors.toList());
//     }
// }


import com.endercrest.voidspawn.CommandHandler;
import com.endercrest.voidspawn.utils.WorldUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
                    continue;

                if(args.length == 0 || subCommand.getKey().startsWith(args[0])) {
                    output.add(subCommand.getKey());
                }
            }

            return output;
        }

        SubCommand subCommand = handler.getSubCommand(args[0]);
        return subCommand != null ? subCommand.getTabCompletion(player, Arrays.copyOfRange(args, 1, args.length)) : null;
    }

    /////////////////////////////////////////////
    ////        Common Auto Completes        ////
    /////////////////////////////////////////////


    static List<String> getBooleanWorldCompletion(String[] args) {
        switch(args.length) {
            case 1:
                return new ArrayList<String>() {{
                    add("true");
                    add("false");
                }}
                .stream()
                .filter(s -> s.startsWith(args[0].toLowerCase()))
                .collect(Collectors.toList());
            case 2:
// Path: src/main/java/com/endercrest/voidspawn/CommandHandler.java
// public class CommandHandler implements CommandExecutor {
//     private final VoidSpawn plugin;
//     private final HashMap<String, SubCommand> commands = new HashMap<>();
// 
//     public CommandHandler(VoidSpawn plugin){
//         this.plugin = plugin;
//         loadCommands();
//     }
// 
//     /**
//      * Load the commands into the HashMap that makes it accessible to players.
//      */
//     private void loadCommands(){
//         commands.put("set", new SetCommand());
//         commands.put("remove", new RemoveCommand());
//         commands.put("reload", new ReloadCommand());
//         commands.put("modes", new ModesCommand());
//         commands.put("mode", new ModeCommand());
//         commands.put("help", new HelpCommand(commands));
//         commands.put("toggle", new ToggleCommand());
//         commands.put("detector", new DetectorCommand());
//         commands.put("info", new InfoCommand());
//         commands.put("option", new OptionCommand());
//     }
// 
//     public Set<Map.Entry<String, SubCommand>> getCommands() {
//         return commands.entrySet();
//     }
// 
//     public SubCommand getSubCommand(String cmd) {
//         return commands.get(cmd);
//     }
// 
//     @Override
//     public boolean onCommand(@NotNull CommandSender cs, @NotNull Command cmd, @NotNull String s, String[] args){
//         if(!(cs instanceof Player)){
//             if((args.length >= 1) && (args[0].equalsIgnoreCase("reload"))){
//                 ConfigManager.getInstance().reloadConfig();
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&6Plugin Reloaded"));
//                 return true;
//             }
// 
//             cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cOnly Players can use these commands"));
//             return false;
//         }
//         if(cmd.getName().equalsIgnoreCase("voidspawn")){
//             if((args == null) || (args.length < 1)){
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Version &6" + plugin.getDescription().getVersion() + "&f by &6EnderCrest"));
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
//                 return true;
//             }
//             String sub = args[0].toLowerCase();
//             if(!commands.containsKey(sub)){
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cThat command does not exist"));
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
//                 return true;
//             }
//             SubCommand command = commands.get(sub);
//             Player player = (Player)cs;
//             if(command.permission() != null && !player.hasPermission(command.permission())) {
//                 player.sendMessage(MessageUtil.colorize("&cYou do not have permission."));
//                 return true;
//             }
// 
// 
//             try {
//                 command.onCommand(player, args);
//             } catch (Exception e) {
//                 e.printStackTrace();
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "&cThere was an error"));
//                 cs.sendMessage(MessageUtil.colorize(VoidSpawn.prefix + "Type &6/vs help &ffor command information"));
//             }
//         }
//         return false;
//     }
// }
// 
// Path: src/main/java/com/endercrest/voidspawn/utils/WorldUtil.java
// public class WorldUtil {
// 
//     public static String configSafe(String worldName){
//         return worldName.replace(" ", "_");
//     }
// 
//     /**
//      * Checks if the selected world is a valid world.
//      *
//      * @param worldName The world name that will be checked.
//      * @return True if the world does not return null.
//      */
//     public static boolean isValidWorld(String worldName){
//         return Bukkit.getWorld(worldName) != null;
//     }
// 
//     /**
//      * get a list of world names that begin with partial. If partial is
//      * empty, all worlds are returned.
//      * @param partial String to compare against.
//      * @return List of world names.
//      */
//     public static List<String> getMatchingWorlds(String partial) {
//         return Bukkit.getWorlds().stream()
//                 .map(World::getName)
//                 .filter(world -> world.toLowerCase().startsWith(partial.toLowerCase()))
//                 .collect(Collectors.toList());
//     }
// }


// Path: src/main/java/com/endercrest/voidspawn/commands/VoidSpawnTabCompleter.java
import com.endercrest.voidspawn.CommandHandler;
import com.endercrest.voidspawn.utils.WorldUtil;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

                    continue;

                if(args.length == 0 || subCommand.getKey().startsWith(args[0])) {
                    output.add(subCommand.getKey());
                }
            }

            return output;
        }

        SubCommand subCommand = handler.getSubCommand(args[0]);
        return subCommand != null ? subCommand.getTabCompletion(player, Arrays.copyOfRange(args, 1, args.length)) : null;
    }

    /////////////////////////////////////////////
    ////        Common Auto Completes        ////
    /////////////////////////////////////////////


    static List<String> getBooleanWorldCompletion(String[] args) {
        switch(args.length) {
            case 1:
                return new ArrayList<String>() {{
                    add("true");
                    add("false");
                }}
                .stream()
                .filter(s -> s.startsWith(args[0].toLowerCase()))
                .collect(Collectors.toList());
            case 2:
                return WorldUtil.getMatchingWorlds(args[1]);