Merge remote-tracking branch 'upstream/feature/translatable-text' into i18n-merge

This commit is contained in:
Jesse Boyd
2019-11-21 13:50:05 +00:00
102 changed files with 1606 additions and 584 deletions

View File

@ -28,11 +28,11 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
@ -76,7 +76,7 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured.");
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return;
}
@ -86,7 +86,7 @@ public class SnapshotCommands {
if (!snapshots.isEmpty()) {
actor.print(new SnapshotListBox(world.getName(), snapshots).create(page));
} else {
actor.printError("No snapshots are available. See console for details.");
actor.printError(TranslatableComponent.of("worldedit.restore.none-found-console"));
// Okay, let's toss some debugging information!
File dir = config.snapshotRepo.getDirectory();
@ -101,7 +101,7 @@ public class SnapshotCommands {
}
}
} catch (MissingWorldException ex) {
actor.printError("No snapshots were found for this world.");
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
}
}
@ -117,7 +117,7 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured.");
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return;
}
@ -128,19 +128,19 @@ public class SnapshotCommands {
if (snapshot != null) {
session.setSnapshot(null);
actor.print("Now using newest snapshot.");
actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use.newest"));
} else {
actor.printError("No snapshots were found.");
actor.printError(TranslatableComponent.of("worldedit.restore.none-found"));
}
} catch (MissingWorldException ex) {
actor.printError("No snapshots were found for this world.");
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
}
} else {
try {
session.setSnapshot(config.snapshotRepo.getSnapshot(name));
actor.print("Snapshot set to: " + name);
actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(name)));
} catch (InvalidSnapshotException e) {
actor.printError("That snapshot does not exist or is not available.");
actor.printError(TranslatableComponent.of("worldedit.restore.not-available"));
}
}
}
@ -156,30 +156,30 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured.");
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return;
}
if (index < 1) {
actor.printError("Invalid index, must be equal or higher then 1.");
actor.printError(TranslatableComponent.of("worldedit.snapshot.index-above-0"));
return;
}
try {
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, world.getName());
if (snapshots.size() < index) {
actor.printError("Invalid index, must be between 1 and " + snapshots.size() + ".");
actor.printError(TranslatableComponent.of("worldedit.snapshot.index-oob", TextComponent.of(snapshots.size())));
return;
}
Snapshot snapshot = snapshots.get(index - 1);
if (snapshot == null) {
actor.printError("That snapshot does not exist or is not available.");
actor.printError(TranslatableComponent.of("worldedit.restore.not-available"));
return;
}
session.setSnapshot(snapshot);
actor.print("Snapshot set to: " + snapshot.getName());
actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
} catch (MissingWorldException e) {
actor.printError("No snapshots were found for this world.");
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
}
}
@ -195,7 +195,7 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured.");
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return;
}
@ -203,14 +203,16 @@ public class SnapshotCommands {
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, world.getName());
if (snapshot == null) {
actor.printError("Couldn't find a snapshot before "
+ dateFormat.withZone(session.getTimeZone()).format(date) + ".");
actor.printError(TranslatableComponent.of(
"worldedit.snapshot.none-before",
TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date)))
);
} else {
session.setSnapshot(snapshot);
actor.print("Snapshot set to: " + snapshot.getName());
actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
}
} catch (MissingWorldException ex) {
actor.printError("No snapshots were found for this world.");
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
}
}
@ -226,21 +228,23 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
actor.printError("Snapshot/backup restore is not configured.");
actor.printError(TranslatableComponent.of("worldedit.restore.not-configured"));
return;
}
try {
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, world.getName());
if (snapshot == null) {
actor.printError("Couldn't find a snapshot after "
+ dateFormat.withZone(session.getTimeZone()).format(date) + ".");
actor.printError(TranslatableComponent.of(
"worldedit.snapshot.none-after",
TextComponent.of(dateFormat.withZone(session.getTimeZone()).format(date)))
);
} else {
session.setSnapshot(snapshot);
actor.print("Snapshot set to: " + snapshot.getName());
actor.printInfo(TranslatableComponent.of("worldedit.snapshot.use", TextComponent.of(snapshot.getName())));
}
} catch (MissingWorldException ex) {
actor.printError("No snapshots were found for this world.");
actor.printError(TranslatableComponent.of("worldedit.restore.none-for-world"));
}
}