Class AutoSaveData<T>

java.lang.Object
dev.scsupercraft.mc.libraries.corelib.api.data.SaveData<T>
dev.scsupercraft.mc.libraries.corelib.api.data.AutoSaveData<T>
Type Parameters:
T - The type of the data being saved.
All Implemented Interfaces:
Data<T>
Direct Known Subclasses:
SyncedAutoSaveData

@AvailableSince("1.0.0") public sealed class AutoSaveData<T> extends SaveData<T> permits SyncedAutoSaveData<T>
A helper class for save data. Automatically saves and loads data.
  • Constructor Details

    • AutoSaveData

      @AvailableSince("1.0.0") public AutoSaveData(Supplier<@NotNull T> defaultValue, CodecHolder<T> codecHolder, Supplier<File> fileGetter, SaveData.Type type)
      Creates new auto save data.
      Parameters:
      defaultValue - A supplier that returns the default value for this savable. Used if there isn't any existing data during loading.
      codecHolder - A codec holder for serializing the save data.
      fileGetter - A supplier that returns the file that the data will be saved to.
      type - What should the data be saved as.
  • Method Details

    • markDirty

      public void markDirty()
      Description copied from class: SaveData
      Tell the savable that it was updated. Failing to call this method after an update will result in the data not getting saved.
      Overrides:
      markDirty in class SaveData<T>