package dev.crucifixbeta.mod.commands.impl;

import dev.crucifixbeta.CrucifixBeta;
import dev.crucifixbeta.mod.commands.Command;
import dev.crucifixbeta.mod.modules.Module;
import java.util.ArrayList;
import java.util.List;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

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

   public TCommand() {
      super("t", "[module]");
   }

   @Override
   public void runCommand(String[] parameters) {
      if (parameters.length == 0) {
         this.sendUsage();
      } else {
         String var2 = parameters[0];
         Module var3 = CrucifixBeta.MODULE.getModuleByName(var2);
         if (var3 == null) {
            this.sendChatMessage("\u00a7fUnknown module!");
         } else {
            var3.toggle();
         }
      }
   }

   @Override
   public String[] getAutocorrect(int count, List<String> seperated) {
      if (count != 1) {
         return null;
      } else {
         String var3 = ((String)seperated.getLast()).toLowerCase();
         ArrayList<String> var4 = new ArrayList<>();

         for (Module var6 : CrucifixBeta.MODULE.getModules()) {
            if (var3.equalsIgnoreCase(CrucifixBeta.getPrefix() + "t") || var6.getName().toLowerCase().startsWith(var3)) {
               var4.add(var6.getName());
            }
         }

         int var10 = var4.size();
         String[] var11 = new String[var10];
         int var7 = 0;

         for (String var9 : var4) {
            var11[var7++] = var9;
         }

         return var11;
      }
   }
}
