Class SettingsModule

java.lang.Object
com.minecolonies.api.colony.buildings.modules.AbstractBuildingModule
com.minecolonies.core.colony.buildings.modules.SettingsModule
All Implemented Interfaces:
IBuildingModule, ICommonSettingsModule, IPersistentModule, ISettingsModule, IHasDirty

public class SettingsModule extends AbstractBuildingModule implements IPersistentModule, ISettingsModule
Module containing all settings.
  • Constructor Details

    • SettingsModule

      public SettingsModule()
  • Method Details

    • getSetting

      public <T extends ISetting<?>> T getSetting(ISettingKey<T> key)
      Description copied from interface: ICommonSettingsModule
      Get a specific setting.
      Specified by:
      getSetting in interface ICommonSettingsModule
      Type Parameters:
      T - the type of setting.
      Parameters:
      key - the key of the setting.
      Returns:
      the setting.
    • getOptionalSetting

      @NotNull public <T extends ISetting<?>> @NotNull Optional<T> getOptionalSetting(ISettingKey<T> key)
      Description copied from interface: ISettingsModule
      Get a specific setting.
      Specified by:
      getOptionalSetting in interface ISettingsModule
      Type Parameters:
      T - the type of setting.
      Parameters:
      key - the key of the setting.
      Returns:
      the setting, if it exists and is active.
    • with

      public ISettingsModule with(ISettingKey<?> key, ISetting<?> setting)
      Description copied from interface: ISettingsModule
      Register a new setting.
      Specified by:
      with in interface ISettingsModule
      Parameters:
      key - the key of the setting.
      setting - the setting.
      Returns:
      the instance of the module.
    • deserializeNBT

      public void deserializeNBT(net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IPersistentModule
      Deserialize the module.
      Specified by:
      deserializeNBT in interface IPersistentModule
      Parameters:
      compound - the nbt compound.
    • serializeNBT

      public void serializeNBT(net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IPersistentModule
      Serialize the module from a compound.
      Specified by:
      serializeNBT in interface IPersistentModule
      Parameters:
      compound - the compound.
    • serializeToView

      public void serializeToView(net.minecraft.network.FriendlyByteBuf buf)
      Description copied from interface: IBuildingModule
      Serialization method to send the module data to the client side.
      Specified by:
      serializeToView in interface IBuildingModule
      Parameters:
      buf - the buffer to write it to.
    • updateSetting

      public void updateSetting(ISettingKey<?> settingKey, ISetting<?> value, net.minecraft.server.level.ServerPlayer sender)
      Description copied from interface: ICommonSettingsModule
      Update a given settings value.
      Specified by:
      updateSetting in interface ICommonSettingsModule
      Parameters:
      settingKey - the given key.
      value - the value.
      sender - the player that updated the setting.
    • getSettingValueOrDefault

      public <S, T extends ISetting<S>> S getSettingValueOrDefault(ISettingKey<T> key, S def)
      Description copied from interface: ISettingsModule
      Get setting value or default.
      Specified by:
      getSettingValueOrDefault in interface ISettingsModule
      Type Parameters:
      S - the setting value type.
      T - the type of setting.
      Parameters:
      key - the key of the setting.
      def - the default.
      Returns:
      the setting value or the default.