Updated a class, minor command tweaks, and formatting

This commit is contained in:
MattBDev
2019-07-25 14:58:59 -04:00
parent ff5860113d
commit 3a3efb8117
14 changed files with 1508 additions and 1233 deletions

View File

@ -22,8 +22,6 @@
package com.sk89q.worldedit.world.snapshot;
import com.sk89q.worldedit.world.storage.MissingWorldException;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FilenameFilter;
import java.time.ZoneOffset;
@ -33,6 +31,7 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import javax.annotation.Nullable;
/**
* A repository contains zero or more snapshots.
@ -67,13 +66,13 @@ public class SnapshotRepository {
}
/**
* Get a list of snapshots in a directory. The newest snapshot is
* near the top of the array.
* Get a list of snapshots in a directory. The newest snapshot is near the top of the array.
*
* @param newestFirst true to get the newest first
* @return a list of snapshots
*/
public List<Snapshot> getSnapshots(boolean newestFirst, String worldName) throws MissingWorldException {
public List<Snapshot> getSnapshots(boolean newestFirst, String worldName)
throws MissingWorldException {
FilenameFilter filter = (dir, name) -> {
File f = new File(dir, name);
return isValidSnapshot(f);
@ -117,7 +116,8 @@ public class SnapshotRepository {
* @return a snapshot or null
*/
@Nullable
public Snapshot getSnapshotAfter(ZonedDateTime date, String world) throws MissingWorldException {
public Snapshot getSnapshotAfter(ZonedDateTime date, String world)
throws MissingWorldException {
List<Snapshot> snapshots = getSnapshots(true, world);
Snapshot last = null;
@ -139,7 +139,8 @@ public class SnapshotRepository {
* @return a snapshot or null
*/
@Nullable
public Snapshot getSnapshotBefore(ZonedDateTime date, String world) throws MissingWorldException {
public Snapshot getSnapshotBefore(ZonedDateTime date, String world)
throws MissingWorldException {
List<Snapshot> snapshots = getSnapshots(false, world);
Snapshot last = null;
@ -205,7 +206,8 @@ public class SnapshotRepository {
* @return whether it is a valid snapshot
*/
protected boolean isValidSnapshot(File file) {
if (!file.getName().matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) {
if (!file.getName()
.matches("^[A-Za-z0-9_\\- \\./\\\\'\\$@~!%\\^\\*\\(\\)\\[\\]\\+\\{\\},\\?]+$")) {
return false;
}