Class SnapshotRepository

java.lang.Object
com.sk89q.worldedit.world.snapshot.SnapshotRepository

public class SnapshotRepository extends Object
A repository contains zero or more snapshots.
  • Field Details

  • Constructor Details

    • SnapshotRepository

      public SnapshotRepository(File dir)
      Create a new instance of a repository.
      Parameters:
      dir - the directory
    • SnapshotRepository

      public SnapshotRepository(String dir)
      Create a new instance of a repository.
      Parameters:
      dir - the directory
  • Method Details

    • getSnapshots

      public List<Snapshot> getSnapshots(boolean newestFirst, String worldName) throws MissingWorldException
      Get a list of snapshots in a directory. The newest snapshot is near the top of the array.
      Parameters:
      newestFirst - true to get the newest first
      Returns:
      a list of snapshots
      Throws:
      MissingWorldException
    • getSnapshotAfter

      @Nullable public Snapshot getSnapshotAfter(ZonedDateTime date, String world) throws MissingWorldException
      Get the first snapshot after a date.
      Parameters:
      date - a date
      Returns:
      a snapshot or null
      Throws:
      MissingWorldException
    • getSnapshotBefore

      @Nullable public Snapshot getSnapshotBefore(ZonedDateTime date, String world) throws MissingWorldException
      Get the first snapshot before a date.
      Parameters:
      date - a date
      Returns:
      a snapshot or null
      Throws:
      MissingWorldException
    • detectDate

      protected void detectDate(Snapshot snapshot)
      Attempt to detect a snapshot's date and assign it.
      Parameters:
      snapshot - the snapshot
    • getDefaultSnapshot

      @Nullable public Snapshot getDefaultSnapshot(String world) throws MissingWorldException
      Get the default snapshot.
      Parameters:
      world - the world name
      Returns:
      a snapshot or null
      Throws:
      MissingWorldException
    • isValidSnapshotName

      public boolean isValidSnapshotName(String snapshot)
      Check to see if a snapshot is valid.
      Parameters:
      snapshot - a snapshot name
      Returns:
      whether it is a valid snapshot
    • isValidSnapshot

      protected boolean isValidSnapshot(File file)
      Check to see if a snapshot is valid.
      Parameters:
      file - the file to the snapshot
      Returns:
      whether it is a valid snapshot
    • getSnapshot

      public Snapshot getSnapshot(String name) throws InvalidSnapshotException
      Get a snapshot.
      Parameters:
      name - the name of the snapshot
      Returns:
      a snapshot
      Throws:
      InvalidSnapshotException - if the snapshot is invalid
    • getDirectory

      public File getDirectory()
      Get the snapshot directory.
      Returns:
      a path