int count1 = 0;
int count2 = 0;
for (int i = 0; i < installer.getJsonMods().size(); ) {
boolean skip = false;
final Mod mod = installer.getJsonMods().get(i);
if (installer.isServer() && !mod.installOnServer()) {
continue;
}
ModsJCheckBox checkBox = null;
if ((installer.isServer() ? mod.isServerOptional() : mod.isOptional())) {
if (!skip) {
checkBox = new ModsJCheckBox(mod);
checkBox.setEnabled(true);
if (!mod.hasLinked()) {
checkBox.setBounds(0, (count1 * 20), checkBox.getPreferredSize().width, 20);
} else {
Mod linkedMod = installer.getJsonModByName(mod.getLinked());
if (linkedMod == null) {
LogManager.error("The mod " + mod.getName() + " tried to reference a linked mod " + mod
.getLinked() + " which doesn't exist!");
installer.cancel(true);
return;
}
if ((installer.isServer() ? linkedMod.isServerOptional() : linkedMod.isOptional())) {
checkBox.setEnabled(false);
checkBox.setBounds(20, (count1 * 20), checkBox.getPreferredSize().width, 20);
} else {
checkBox.setBounds(0, (count1 * 20), checkBox.getPreferredSize().width, 20);
}
if (mod.isSelected()) {
checkBox.setEnabled(true);
checkBox.setSelected(true);
if (!linkedMod.isSelected()) {
boolean needToEnableChildren = false;
for (ModsJCheckBox checkbox : modCheckboxes) {
if (checkbox.getJsonMod().getName().equalsIgnoreCase(mod.getLinked())) {
checkbox.setSelected(true); // Select the checkbox
needToEnableChildren = true;
break;
}
}
if (needToEnableChildren) {
for (ModsJCheckBox checkbox : modCheckboxes) {
if (checkbox.getJsonMod().getLinked().equalsIgnoreCase(mod.getLinked())) {
checkbox.setEnabled(true);
}
}
}
}
} else {
if (linkedMod.isSelected()) {
checkBox.setEnabled(true);
}
}
}
if (mod.isHidden() || mod.isLibrary()) {