CompleteConfig

CompleteConfig

487k Downloads

NoSuchFieldError: checkbox on dedicated server

anar4732 opened this issue ยท 8 comments

commented
commented

This should be fixed by using the latest version of CompleteConfig.

commented

This should be fixed by using the latest version of CompleteConfig.

it needs the fix for older minecraft versions too

commented

Would it be fixed on 1.20.1 or is it resolved only on 1.20.4?

commented

@Lortseam any word on fixing 1.19.2?

commented

I will probably not fix this anymore for such old versions of Minecraft.

commented

This happens for 1.20.1 servers too, it would be amazing if it could be fixed ๐Ÿ™

commented

@Lortseam I would greatly appreciate a fix for 1.19.2. This is blocking me from using the progressive bosses mod on my fabric server. Or if you could show me the commit that fixed this issue I could create a PR. Thank you.

commented

@Lortseam Currently mods using complete config for minecraft 1.19.2 are broken. I think I have a fix. However I was couldn't push my branch to create a PR. I'm trying to make this change for version 2.0.1 for minecraft 1.19.2, so I checked out commit with hash "7f82a5ccb7333633472932ca1041d2fa75854a51". Do you think the below change will fix the issue? If so do you mind releasing a version 2.0.2 with this fix?

image

package me.lortseam.completeconfig.data;

import me.lortseam.completeconfig.api.ConfigEntry;
import me.lortseam.completeconfig.text.TranslationKey;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.api.Environment;
import net.minecraft.screen.ScreenTexts;
import net.fabricmc.api.Environment; 
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;

public class BooleanEntry extends Entry<Boolean> {

    @Environment(EnvType.CLIENT)
    private Map<Boolean, TranslationKey> valueTranslations;
    @Environment(EnvType.CLIENT)
    private Boolean checkbox;

    public BooleanEntry(EntryOrigin origin) {
        super(origin);
    }

    @Environment(EnvType.CLIENT)
    private Map<Boolean, TranslationKey> getValueTranslations() {
        if (valueTranslations == null) {
            valueTranslations = new HashMap<>();
            Optional<ConfigEntry.Boolean> annotation = origin.getOptionalAnnotation(ConfigEntry.Boolean.class);
            if (annotation.isPresent()) {
                if (!annotation.get().trueKey().isBlank()) {
                    valueTranslations.put(true, origin.getRoot().getBaseTranslation().append(annotation.get().trueKey()));
                }
                if (!annotation.get().falseKey().isBlank()) {
                    valueTranslations.put(false, origin.getRoot().getBaseTranslation().append(annotation.get().falseKey()));
                }
            }
            TranslationKey defaultTrueTranslation = getNameTranslation().append("true");
            if (defaultTrueTranslation.exists()) {
                valueTranslations.putIfAbsent(true, defaultTrueTranslation);
            }
            TranslationKey defaultFalseTranslation = getNameTranslation().append("false");
            if (defaultFalseTranslation.exists()) {
                valueTranslations.putIfAbsent(false, defaultFalseTranslation);
            }
        }
        return valueTranslations;
    }

    @Override
    public Function<Boolean, Text> getValueTextSupplier() {
        if (getValueTranslations().isEmpty()) {
            return ScreenTexts::onOrOff;
        }
        return value -> getValueTranslations().get(value).toText();
    }

    public boolean isCheckbox() {
        if (checkbox == null) {
            checkbox = origin.isAnnotationPresent(ConfigEntry.Checkbox.class);
        }
        return checkbox;
    }

}