package dev.crucifixbeta.mod.commands.impl;

import dev.crucifixbeta.CrucifixBeta;
import dev.crucifixbeta.core.impl.PlayerManager;
import dev.crucifixbeta.mod.commands.Command;
import dev.crucifixbeta.mod.gui.windows.WindowsScreen;
import dev.crucifixbeta.mod.gui.windows.impl.ItemSelectWindow;
import java.util.ArrayList;
import java.util.List;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.Blocks;

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

   public XrayCommand() {
      super("xray", "[\"\"/name/reset/clear/list] | [add/remove] [name]");
   }

   @Override
   public void runCommand(String[] parameters) {
      if (parameters.length == 0) {
         PlayerManager.screenToOpen = new WindowsScreen(new ItemSelectWindow(CrucifixBeta.XRAY));
      } else {
         String var2 = parameters[0];
         switch (var2) {
            case "reset":
               CrucifixBeta.XRAY.clear();
               CrucifixBeta.XRAY.add(Blocks.DIAMOND_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.DEEPSLATE_DIAMOND_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.GOLD_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.NETHER_GOLD_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.IRON_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.DEEPSLATE_IRON_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.REDSTONE_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.EMERALD_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.DEEPSLATE_EMERALD_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.DEEPSLATE_REDSTONE_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.COAL_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.DEEPSLATE_COAL_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.ANCIENT_DEBRIS.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.NETHER_QUARTZ_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.LAPIS_ORE.getTranslationKey());
               CrucifixBeta.XRAY.add(Blocks.DEEPSLATE_LAPIS_ORE.getTranslationKey());
               this.sendChatMessage("\u00a7fBlocks list got reset");
               return;
            case "clear":
               CrucifixBeta.XRAY.clear();
               this.sendChatMessage("\u00a7fBlocks list got clear");
               return;
            case "list":
               if (CrucifixBeta.XRAY.getList().isEmpty()) {
                  this.sendChatMessage("\u00a7fBlocks list is empty");
                  return;
               }

               for (String var5 : CrucifixBeta.XRAY.getList()) {
                  this.sendChatMessage("§a" + var5);
               }

               return;
            case "add":
               if (parameters.length == 2) {
                  CrucifixBeta.XRAY.add(parameters[1]);
                  this.sendChatMessage(
                     "§f" + parameters[1] + (CrucifixBeta.XRAY.inWhitelist(parameters[1]) ? " \u00a7ahas been added" : " \u00a7chas been removed")
                  );
                  return;
               }

               this.sendUsage();
               return;
            case "remove":
               if (parameters.length == 2) {
                  CrucifixBeta.XRAY.remove(parameters[1]);
                  this.sendChatMessage(
                     "§f" + parameters[1] + (CrucifixBeta.XRAY.inWhitelist(parameters[1]) ? " \u00a7ahas been added" : " \u00a7chas been removed")
                  );
                  return;
               }

               this.sendUsage();
               return;
            default:
               if (parameters.length == 1) {
                  this.sendChatMessage(
                     "§f" + parameters[0] + (CrucifixBeta.XRAY.inWhitelist(parameters[0]) ? " \u00a7ais in whitelist" : " \u00a7cisn't in whitelist")
                  );
               } else {
                  this.sendUsage();
               }
         }
      }
   }

   @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 (String var7 : List.of(
            "add", "remove", "list", "reset", "clear"
         )) {
            if (var3.equalsIgnoreCase(CrucifixBeta.getPrefix() + "xray") || var7.toLowerCase().startsWith(var3)) {
               var4.add(var7);
            }
         }

         int var11 = var4.size();
         String[] var12 = new String[var11];
         int var8 = 0;

         for (String var10 : var4) {
            var12[var8++] = var10;
         }

         return var12;
      }
   }
}
