package los.numeros.command;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;

import los.numeros.HidersAndDiggers.Main;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;

public class HidersAndDiggersCommand {
  public static void
  register(CommandDispatcher<ServerCommandSource> dispatcher, boolean dedicated)
  {
    dispatcher.register(CommandManager.literal("hiders")
      .then(CommandManager.literal("start").executes(HidersAndDiggersCommand::run)));
  }

  public static int
  run(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException
  {
    /* get the minecraft server object */
    MinecraftServer server = ctx.getSource().getMinecraftServer();

    /* pass in the minecraft server object and start it */
    new Main(server, 1);

    return 0;
  }
}