top.hendrixshen.magiclib.malilib.impl.config.MagicConfigString Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of magiclib-1_14_4 Show documentation
Show all versions of magiclib-1_14_4 Show documentation
To beat magic with magic :(
package top.hendrixshen.magiclib.malilib.impl.config;
import com.google.gson.JsonElement;
import fi.dy.masa.malilib.config.options.ConfigBase;
import fi.dy.masa.malilib.config.options.ConfigString;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.jetbrains.annotations.Nullable;
import top.hendrixshen.magiclib.malilib.api.config.IMagicConfigBase;
import java.util.function.Consumer;
@Environment(EnvType.CLIENT)
public class MagicConfigString extends ConfigString implements IMagicConfigBase {
private final String prefix;
@Nullable
private Consumer> valueChangedFromJsonCallback;
public MagicConfigString(String prefix, String name, String defaultValue) {
super(name, defaultValue, String.format("%s.%s.comment", prefix, name));
this.prefix = prefix;
}
@Override
public void setValueFromJsonElement(JsonElement jsonElement) {
super.setValueFromJsonElement(jsonElement);
if (this.valueChangedFromJsonCallback != null) {
this.valueChangedFromJsonCallback.accept(this);
}
}
@Override
@Nullable
public Consumer> getValueChangedFromJsonCallback() {
return this.valueChangedFromJsonCallback;
}
@Override
public void setValueChangedFromJsonCallback(@Nullable Consumer> valueChangedFromJsonCallback) {
this.valueChangedFromJsonCallback = valueChangedFromJsonCallback;
}
@Override
public String getPrefix() {
return this.prefix;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy