Class SnapshotRepository
java.lang.Object
com.sk89q.worldedit.world.snapshot.SnapshotRepository
A repository contains zero or more snapshots.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSnapshotRepository
(File dir) Create a new instance of a repository.SnapshotRepository
(String dir) Create a new instance of a repository. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
detectDate
(Snapshot snapshot) Attempt to detect a snapshot's date and assign it.getDefaultSnapshot
(String world) Get the default snapshot.Get the snapshot directory.getSnapshot
(String name) Get a snapshot.getSnapshotAfter
(ZonedDateTime date, String world) Get the first snapshot after a date.getSnapshotBefore
(ZonedDateTime date, String world) Get the first snapshot before a date.getSnapshots
(boolean newestFirst, String worldName) Get a list of snapshots in a directory.protected boolean
isValidSnapshot
(File file) Check to see if a snapshot is valid.boolean
isValidSnapshotName
(String snapshot) Check to see if a snapshot is valid.
-
Field Details
-
dir
-
dateParsers
-
-
Constructor Details
-
SnapshotRepository
Create a new instance of a repository.- Parameters:
dir
- the directory
-
SnapshotRepository
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
Attempt to detect a snapshot's date and assign it.- Parameters:
snapshot
- the snapshot
-
getDefaultSnapshot
Get the default snapshot.- Parameters:
world
- the world name- Returns:
- a snapshot or null
- Throws:
MissingWorldException
-
isValidSnapshotName
Check to see if a snapshot is valid.- Parameters:
snapshot
- a snapshot name- Returns:
- whether it is a valid snapshot
-
isValidSnapshot
Check to see if a snapshot is valid.- Parameters:
file
- the file to the snapshot- Returns:
- whether it is a valid snapshot
-
getSnapshot
Get a snapshot.- Parameters:
name
- the name of the snapshot- Returns:
- a snapshot
- Throws:
InvalidSnapshotException
- if the snapshot is invalid
-
getDirectory
Get the snapshot directory.- Returns:
- a path
-