All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.hendrixshen.magiclib.malilib.api.config.IMagicConfigBase Maven / Gradle / Ivy

package top.hendrixshen.magiclib.malilib.api.config;

import fi.dy.masa.malilib.config.IConfigBase;
import fi.dy.masa.malilib.config.options.ConfigBase;
import fi.dy.masa.malilib.util.StringUtils;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.jetbrains.annotations.Nullable;
import top.hendrixshen.magiclib.language.api.I18n;

import java.util.function.Consumer;

@Environment(EnvType.CLIENT)
public interface IMagicConfigBase extends IConfigBase {
    @Nullable
    Consumer> getValueChangedFromJsonCallback();

    void setValueChangedFromJsonCallback(@Nullable Consumer> valueChangedFromJsonCallback);

    String getPrefix();

    @Override
    default String getComment() {
        String key = String.format("%s.%s.comment", this.getPrefix(), this.getName());
        return I18n.exists(key) ? I18n.get(key) : this.getName();
    }

    @Override
    default String getPrettyName() {
        String key = String.format("%s.%s.pretty_name", this.getPrefix(), this.getName());
        return I18n.exists(key) ? I18n.get(key) : StringUtils.splitCamelCase(this.getConfigGuiDisplayName());
    }

    @Override
    default String getConfigGuiDisplayName() {
        String key = String.format("%s.%s.name", this.getPrefix(), this.getName());
        return I18n.exists(key) ? I18n.get(key) : this.getName();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy