Class BackUpHelper

java.lang.Object
com.minecolonies.core.util.BackUpHelper

public final class BackUpHelper extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Export colony filename scheme
    static long
    Last backup timer before the next is allowed
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Backup the colony
    static String
    Exports a certain colony and its part of the world and colony data data to a zip
    static @NotNull File
    Get save location for Minecolonies data, from the world/save directory.
    static void
    Loads all colonies from the backup files, skips deleted colonies.
    static void
    loadColonyBackup(int colonyId, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension, boolean loadDeleted, boolean claimChunks)
    Load the colony backup by colony, also works for backups of deleted colonies.
    static void
    Loads the colony managers backup file
    static void
    Loads all colonies from backup files which the world cap is missing.
    static net.minecraft.nbt.CompoundTag
    loadNBTFromPath(@Nullable File file)
    Load a file and return the data as an CompoundTag.
    static void
    markColonyDeleted(int colonyID, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimensionID)
    Marks a colony's backup file as deleted.
    static void
    Reclaims chunks for a colony
    static void
    Save all the Colonies.
    static void
    saveNBTToPath(@Nullable File file, @NotNull net.minecraft.nbt.CompoundTag compound)
    Save an CompoundTag to a file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FILENAME_EXPORT

      public static final String FILENAME_EXPORT
      Export colony filename scheme
      See Also:
    • lastBackupTime

      public static long lastBackupTime
      Last backup timer before the next is allowed
  • Method Details

    • backupColonyData

      public static boolean backupColonyData()
      Backup the colony
      Returns:
      true if succesful.
    • loadManagerBackup

      public static void loadManagerBackup()
      Loads the colony managers backup file
    • loadMissingColonies

      public static void loadMissingColonies()
      Loads all colonies from backup files which the world cap is missing.
    • getSaveLocation

      @NotNull public static @NotNull File getSaveLocation()
      Get save location for Minecolonies data, from the world/save directory.
      Returns:
      Save file for minecolonies.
    • saveNBTToPath

      public static void saveNBTToPath(@Nullable @Nullable File file, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Save an CompoundTag to a file. Does so in a safe manner using an intermediate tmp file.
      Parameters:
      file - The destination file to write the data to.
      compound - The CompoundTag to write to the file.
    • loadNBTFromPath

      public static net.minecraft.nbt.CompoundTag loadNBTFromPath(@Nullable @Nullable File file)
      Load a file and return the data as an CompoundTag.
      Parameters:
      file - The path to the file.
      Returns:
      the data from the file as an CompoundTag, or null.
    • saveColonies

      public static void saveColonies()
      Save all the Colonies.
    • markColonyDeleted

      public static void markColonyDeleted(int colonyID, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimensionID)
      Marks a colony's backup file as deleted.
      Parameters:
      colonyID - id of the colony to delete
      dimensionID - dimension of the colony to delete
    • loadAllBackups

      public static void loadAllBackups()
      Loads all colonies from the backup files, skips deleted colonies.
    • loadColonyBackup

      public static void loadColonyBackup(int colonyId, net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension, boolean loadDeleted, boolean claimChunks)
      Load the colony backup by colony, also works for backups of deleted colonies.
      Parameters:
      colonyId - of the colony.
      dimension - the colony dimension.
      loadDeleted - whether to load deleted colonies aswell.
      claimChunks - if chunks shall be claimed on loading.
    • reclaimChunks

      public static void reclaimChunks(IColony colony)
      Reclaims chunks for a colony
      Parameters:
      colony -
    • exportColony

      public static String exportColony(IColony colony)
      Exports a certain colony and its part of the world and colony data data to a zip
      Parameters:
      colony - colony to export
      Returns:
      file Path and name