package dev.crucifixbeta.mod.commands.impl;

import dev.crucifixbeta.mod.commands.Command;
import java.util.List;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.GameMode;

@Environment(EnvType.CLIENT)
public class GamemodeCommand extends Command {

   public GamemodeCommand() {
      super("gamemode", "[gamemode]");
   }

   @Override
   public void runCommand(String[] parameters) {
      if (parameters.length == 0) {
         this.sendUsage();
      } else {
         String var2 = parameters[0];
         if (var2.equalsIgnoreCase("survival")) {
            mc.interactionManager.setGameMode(GameMode.SURVIVAL);
         } else if (var2.equalsIgnoreCase("creative")) {
            mc.interactionManager.setGameMode(GameMode.CREATIVE);
         } else if (var2.equalsIgnoreCase("adventure")) {
            mc.interactionManager.setGameMode(GameMode.ADVENTURE);
         } else if (var2.equalsIgnoreCase("spectator")) {
            mc.interactionManager.setGameMode(GameMode.SPECTATOR);
         }
      }
   }

   @Override
   public String[] getAutocorrect(int count, List<String> seperated) {
      return count == 1
         ? new String[]{"survival", "creative", "adventure", "spectator"}
         : null;
   }
}
