package dev.crucifixbeta.mod.modules.impl.misc;

import dev.crucifixbeta.CrucifixBeta;
import dev.crucifixbeta.api.events.eventbus.EventListener;
import dev.crucifixbeta.api.events.impl.DeathEvent;
import dev.crucifixbeta.mod.modules.Module;
import dev.crucifixbeta.mod.modules.settings.impl.EnumSetting;
import dev.crucifixbeta.mod.modules.settings.impl.SliderSetting;
import dev.crucifixbeta.mod.modules.settings.impl.StringSetting;
import java.util.List;
import java.util.Random;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.player.PlayerEntity;

@Environment(EnvType.CLIENT)
public class AutoEZ extends Module {
   private static final String CHARACTERS;
   public final List<String> bot = List.of(
      "\u9f20\u6807\u660e\u5929\u5230\uff0c\u89e6\u6478\u677f\u6253\u7684",
      "\u8f6c\u4eba\u5de5",
      "\u6536\u5f92",
      "\u4e0d\u6536\u5f92",
      "\u6709\u771f\u4eba\u5417",
      "\u58a8\u955c\u4e0a\u8f66",
      "\u7d20\u6750\u5c40",
      "\u4e0d\u63a5\u5355",
      "\u63a5\u5355",
      "\u5f81\u5a5a",
      "4399?",
      "\u6682\u65f6\u4e0d\u8003\u8651\u6253\u804c\u4e1a",
      "bot?",
      "\u53eb\u4f60\u5bb6\u957f\u5927\u4eba\u6765\u6253",
      "\u5047\u80a2\u4e0a\u95e8\u5b89\u88c5",
      "\u6d6a\u8d39\u6211\u7684\u7f51\u8d39",
      "\u4e0d\u6536\u6b8b\u75be\u4eba",
      "\u4e0b\u8bfe",
      "\u81ea\u5df1\u627e\u5dee\u8ddd",
      "\u4e0d\u63a5\u4ee3",
      "\u4ee3+",
      "\u8fd9\u6837\u7684\u6cbb\u597d\u4e86\u4e5f\u6d41\u53e3\u6c34",
      "\u4eba\u673a",
      "\u4eba\u673a\u600e\u4e48\u8c03\u96be\u5ea6\u554a",
      "\u53ea\u6536\u4e0d\u88ab0\u5c01\u7684",
      "Bot\u5417\u8fd9\u662f",
      "\u9886\u517b",
      "\u7eb3\u4eb2",
      "\u6b63\u89c6\u5dee\u8ddd",
      "\u8fd1\u4eb2\u7e41\u6b96?",
      "\u6211\u73a9\u7684\u662f\u65b0\u624b\u6559\u7a0b?",
      "\u6765\u8c03\u7075\u654f\u5ea6\u7684",
      "\u6765\u8c03\u53c2\u6570\u7684",
      "\u5c0f\u53f7",
      "\u4e0d\u662f\u672c\u4eba\u522b\u52a0",
      "\u4e0b\u6b21\u8bb0\u5f97\u665a\u70b9\u73a9",
      "\u968f\u4fbf\u73a9\u73a9,\u4e0d\u5e26\u59b9",
      "\u62531\u4e0a\u8f66"
   );
   public final List<String> legit = List.of(
      "good game",
      "good fight",
      "well played",
      "good luck",
      "have fun",
      "nice shot",
      "nice try",
      "respect",
      "you fought well",
      "thanks for the fight",
      "that was fun",
      "well fought",
      "nice fight",
      "good fight mate",
      "honorable fight",
      "fair fight",
      "respectable",
      "you are skilled",
      "nice moves",
      "impressive",
      "well done",
      "great fight",
      "awesome fight",
      "enjoyed that",
      "until next time",
      "you played well",
      "good duel",
      "nice duel",
      "respected opponent",
      "worthy opponent"
   );
   private final EnumSetting<AutoEZ.Type> type = this.add(new EnumSetting<>("Type", AutoEZ.Type.Bot));
   final StringSetting message = this.add(
      new StringSetting("Message", "EZ %player%", () -> this.type.getValue() == AutoEZ.Type.Custom)
   );
   final Random random = new Random();
   private final SliderSetting range = this.add(new SliderSetting("Range", 10.0, 0.0, 20.0, 0.1));
   private final SliderSetting randoms = this.add(new SliderSetting("Random", 3.0, 0.0, 20.0, 1.0));

   public AutoEZ() {
      super("AutoEZ", Module.Category.Misc);
      this.setChinese("\u81ea\u52a8\u5632\u8bbd");
   }

   @EventListener
   public void onDeath(DeathEvent event) {
      if (mc.player != null && mc.getNetworkHandler() != null) {
         PlayerEntity var2 = event.getPlayer();
         if (var2 != null) {
            if (var2 != mc.player && !CrucifixBeta.FRIEND.isFriend(var2)) {
               if (!(this.range.getValue() > 0.0) || !((double)mc.player.distanceTo(var2) > this.range.getValue())) {
                  String var3 = "";
                  if (this.type.getValue() != AutoEZ.Type.Legit) {
                     int var4 = this.randoms.getValueInt();
                     if (var4 > 0) {
                        var3 = " " + this.generateRandomString(var4);
                     }
                  }

                  switch ((AutoEZ.Type)this.type.getValue()) {
                     case Bot:
                        String var6 = this.bot.get(this.random.nextInt(this.bot.size())) + " " + var2.getName().getString() + var3;
                        mc.getNetworkHandler().sendChatMessage(var6);
                        break;
                     case Custom:
                        String var5 = this.message.getValue().replace("%player%", var2.getName().getString()) + var3;
                        mc.getNetworkHandler().sendChatMessage(var5);
                        break;
                     case Legit:
                        if (!this.legit.isEmpty()) {
                           mc.getNetworkHandler().sendChatMessage(this.legit.get(this.random.nextInt(this.legit.size())));
                        }
                  }
               }
            }
         }
      }
   }

   private String generateRandomString(int length) {
      StringBuilder var2 = new StringBuilder(length);

      for (int var3 = 0; var3 < length; var3++) {
         int var4 = this.random.nextInt(("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").length());
         var2.append(("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").charAt(var4));
      }

      return var2.toString();
   }

   static {

      CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   }
@Environment(EnvType.CLIENT)
   public static enum Type {
      Bot,
      Custom,
      Legit;

}
}
