package dev.crucifixbeta.mod.modules.settings;

import dev.crucifixbeta.api.utils.i18n.LangUtil;
import java.util.function.BooleanSupplier;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

@Environment(EnvType.CLIENT)
public abstract class Setting {
   private final BooleanSupplier visibility;
   private final String name;
   private String chineseName;

   public Setting(String name) {
      this.name = name;
      this.visibility = null;
   }

   public Setting(String name, BooleanSupplier visibilityIn) {
      this.name = name;
      this.visibility = visibilityIn;
   }

   public boolean isVisible() {
      return this.visibility == null || this.visibility.getAsBoolean();
   }

   public String getName() {
      return this.name;
   }

   public String getDisplayName() {
      if (!LangUtil.isChinese()) {
         return this.name;
      } else {
         return this.chineseName != null && !this.chineseName.isEmpty() ? this.chineseName : LangUtil.setting(this.name);
      }
   }

   public Setting setChinese(String chineseName) {
      this.chineseName = chineseName;
      return this;
   }
}
