package com.techcavern.wavetact.ircCommands.misc;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.techcavern.wavetact.objects.IRCCommand;
import com.techcavern.wavetact.utils.GeneralUtils;
import com.techcavern.wavetact.utils.IRCUtils;
import org.pircbotx.Channel;
import org.pircbotx.PircBotX;
import org.pircbotx.User;

//@IRCCMD
public class Test extends IRCCommand {

    public Test() {
        super(GeneralUtils.toArray("test dev"), 0, "test", "Test Command (This should not show up in a production environment. If it does, report it", false);
    }

    @Override
    public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception {
        JsonArray versions = GeneralUtils.getJsonArray("http://bot.notenoughmods.com/?json&count");
        MCModVersionSearch:
        for (int i = versions.size() - 1; i >= 0; i--) {
            int size = versions.get(i).getAsJsonObject().get("count").getAsInt();
            if (size > 10) {
                String version = versions.get(i).getAsJsonObject().get("name").getAsString();
                JsonArray mods = GeneralUtils.getJsonArray("http://bot.notenoughmods.com/" + version + ".json");
                JsonArray mods2 = GeneralUtils.getJsonArray("http://modlist.mcf.li/api/v3/" + version + ".json");
                mods2.forEach(mod2 -> {
                    JsonObject mod = mod2.getAsJsonObject();
                    String searchPhrase = mod.get("name").getAsString().replaceAll(" ", "").replaceAll("[^a-zA-Z0-9]", "");
                    boolean isTrue = false;
                    int j = 0;
                    while (j < mods.size() && !isTrue) {
                        JsonObject mod24 = mods.get(j).getAsJsonObject();
                        if (mod24.get("name").getAsString().replaceAll(" ", "").replaceAll("[^a-zA-Z0-9]", "").equalsIgnoreCase(searchPhrase)) {
                            isTrue = true;
                        }
                        j++;
                    }
                    if (!isTrue)
                        IRCUtils.sendMessage(user, network, channel, "[" + version + "] " + searchPhrase, prefix);
                });
            }

        }
    }
}

@@ -785,1506 +785,8 @@
     
- JsonArray versions = GeneralUtils.getJsonArray(%22http://bot.notenoughmods.com/?json&count%22);%0A        MCModVersionSearch:%0A        for (int i = versions.size() - 1; i %3E= 0; i--) %7B%0A            int size = versions.get(i).getAsJsonObject().get(%22count%22).getAsInt();%0A            if (size %3E 10) %7B%0A                String version = versions.get(i).getAsJsonObject().get(%22name%22).getAsString();%0A                JsonArray mods = GeneralUtils.getJsonArray(%22http://bot.notenoughmods.com/%22 + version + %22.json%22);%0A                JsonArray mods2 = GeneralUtils.getJsonArray(%22http://modlist.mcf.li/api/v3/%22 + version + %22.json%22);%0A                mods2.forEach(mod2 -%3E %7B%0A                    JsonObject mod = mod2.getAsJsonObject();%0A                    String searchPhrase = mod.get(%22name%22).getAsString().replaceAll(%22 %22, %22%22).replaceAll(%22%5B%5Ea-zA-Z0-9%5D%22, %22%22);%0A                    boolean isTrue = false;%0A                    int j = 0;%0A                    while (j %3C mods.size() && !isTrue) %7B%0A                        JsonObject mod24 = mods.get(j).getAsJsonObject();%0A                        if (mod24.get(%22name%22).getAsString().replaceAll(%22 %22, %22%22).replaceAll(%22%5B%5Ea-zA-Z0-9%5D%22, %22%22).equalsIgnoreCase(searchPhrase)) %7B%0A                            isTrue = true;%0A                        %7D%0A                        j++;%0A                    %7D%0A                    if (!isTrue)%0A                        IRCUtils.sendMessage(user, network, channel, %22%5B%22 + version + %22%5D %22 + searchPhrase, prefix);%0A                %7D);%0A            %7D%0A%0A        %7D
 %0A   

Clear test code