Skip to content

Commit c017259

Browse files
committed
Implement Translatable Schematic Commands
1 parent c8c6484 commit c017259

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,8 @@ public void save(
553553
AsyncCommandBuilder.wrap(task, actor)
554554
.registerWithSupervisor(worldEdit.getSupervisor(), "Saving schematic " + filename)
555555
.setDelayMessage(Caption.of("worldedit.schematic.save.saving"))
556-
.onSuccess(filename + " saved" + (overwrite ? " (overwriting previous file)." : "."), null)
556+
.onSuccess(Caption.of("fawe.worldedit.schematic.schematic.saved", filename, (overwrite ?
557+
" (overwriting previous file)." : ".")), null)
557558
.onFailure(
558559
Caption.of("worldedit.schematic.failed-to-save"),
559560
worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter()
@@ -975,13 +976,9 @@ public Void call() throws Exception {
975976
int limit = actor.getLimit().SCHEM_FILE_NUM_LIMIT;
976977

977978
if (numFiles >= limit) {
978-
TextComponent noSlotsErr = TextComponent.of( //TODO - to be moved into captions/translatablecomponents
979-
String.format(
980-
"You have " + numFiles + "/" + limit + " saved schematics. Delete some to save this one!",
981-
TextColor.RED
982-
));
983979
LOGGER.info(actor.getName() + " failed to save " + file.getCanonicalPath() + " - too many schematics!");
984-
throw new WorldEditException(noSlotsErr) {
980+
actor.print(Caption.of("fawe.error.schematic.over.count.limit", numFiles, limit).color(TextColor.RED));
981+
throw new WorldEditException(Caption.of("fawe.error.schematic.over.limit", numFiles, limit)) {
985982
};
986983
}
987984
}
@@ -1008,9 +1005,7 @@ public Void call() throws Exception {
10081005
closer.close(); // release the new .schem file so that its size can be measured
10091006
double filesizeKb = Files.size(Paths.get(file.getAbsolutePath())) / 1000.0;
10101007

1011-
TextComponent filesizeNotif = TextComponent.of( //TODO - to be moved into captions/translatablecomponents
1012-
SCHEMATIC_NAME + " size: " + String.format("%.1f", filesizeKb) + "kb", TextColor.GRAY);
1013-
actor.print(filesizeNotif);
1008+
actor.print(Caption.of("fawe.worldedit.schematic.schematic.size", SCHEMATIC_NAME, String.format("%.1f", filesizeKb)));
10141009

10151010
if (checkFilesize) {
10161011

@@ -1023,17 +1018,11 @@ public Void call() throws Exception {
10231018

10241019
if ((curKb) > allocatedKb) {
10251020
file.delete();
1026-
TextComponent notEnoughKbErr = TextComponent.of(
1027-
//TODO - to be moved into captions/translatablecomponents
1028-
"You're about to be at " + String.format("%.1f", curKb) + "kb of schematics. ("
1029-
+ String.format(
1030-
"%dkb",
1031-
allocatedKb
1032-
) + " available) Delete some first to save this one!",
1033-
TextColor.RED
1034-
);
1021+
actor.print(Caption.of("fawe.error.schematic.over.disk.limit", String.format("%.1f", curKb)
1022+
, String.format("%dkb", allocatedKb)).color(TextColor.RED));
10351023
LOGGER.info(actor.getName() + " failed to save " + SCHEMATIC_NAME + " - not enough space!");
1036-
throw new WorldEditException(notEnoughKbErr) {
1024+
throw new WorldEditException(Caption.of("fawe.error.schematic.over.disk.limit", String.format("%.1f", curKb)
1025+
, String.format("%dkb", allocatedKb))) {
10371026
};
10381027
}
10391028
if (overwrite) {
@@ -1042,23 +1031,13 @@ public Void call() throws Exception {
10421031
} else {
10431032
numFiles++;
10441033
}
1045-
TextComponent kbRemainingNotif = TextComponent.of(
1046-
//TODO - to be moved into captions/translatablecomponents
1047-
"You have " + String.format("%.1f", (allocatedKb - curKb)) + "kb left for schematics.",
1048-
TextColor.GRAY
1049-
);
1050-
actor.print(kbRemainingNotif);
1034+
1035+
actor.print(Caption.of("fawe.worldedit.schematic.schematic.disk.space", String.format("%.1f", (allocatedKb - curKb))));
10511036
}
10521037

10531038
if (Settings.settings().PATHS.PER_PLAYER_SCHEMATICS && actor.getLimit().SCHEM_FILE_NUM_LIMIT > -1) {
10541039

1055-
TextComponent slotsRemainingNotif = TextComponent.of(
1056-
//TODO - to be moved into captions/translatablecomponents
1057-
"You have " + (actor.getLimit().SCHEM_FILE_NUM_LIMIT - numFiles)
1058-
+ " schematic file slots left.",
1059-
TextColor.GRAY
1060-
);
1061-
actor.print(slotsRemainingNotif);
1040+
actor.print(Caption.of("fawe.worldedit.schematic.schematic.slots.free", (actor.getLimit().SCHEM_FILE_NUM_LIMIT - numFiles)));
10621041
}
10631042
LOGGER.info(actor.getName() + " saved " + file.getCanonicalPath());
10641043
} else {

worldedit-core/src/main/resources/lang/strings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@
6767
"fawe.worldedit.schematic.schematic.move.success": "{0} -> {1}",
6868
"fawe.worldedit.schematic.schematic.move.failed": "{0} no moved: {1}",
6969
"fawe.worldedit.schematic.schematic.loaded": "{0} loaded. Paste it with //paste",
70-
"fawe.worldedit.schematic.schematic.saved": "{0} saved.",
70+
"fawe.worldedit.schematic.schematic.saved": "{0} saved{1}",
7171
"fawe.worldedit.schematic.schematic.none": "No files found.",
7272
"fawe.worldedit.schematic.schematic.load-failure": "File could not be read or it does not exist: {0}. If you are specifying a format, you may not be specifying the correct one. Sponge schematic v2 and v3 both use the .schem file extension. To allow FAWE to select the format, do not specify one. If you are using a litematica schematic, it is not supported!",
73+
"fawe.worldedit.schematic.schematic.size": "{0} size {1} kb",
74+
"fawe.worldedit.schematic.schematic.disk.space": "You have {0} kb left for schematics",
75+
"fawe.worldedit.schematic.schematic.slots.free": "You have {0} schematic file slots left.",
7376
"fawe.worldedit.clipboard.clipboard.uri.not.found": "You do not have {0} loaded",
7477
"fawe.worldedit.clipboard.clipboard.cleared": "Clipboard cleared",
7578
"fawe.worldedit.clipboard.clipboard.invalid.format": "Unknown clipboard format: {0}",
@@ -125,6 +128,8 @@
125128
"fawe.error.input-parser-exception": "Invalid empty string instead of boolean.",
126129
"fawe.error.invalid-boolean": "Invalid boolean {0}",
127130
"fawe.error.schematic.not.found": "Schematic {0} not found.",
131+
"fawe.error.schematic.over.count.limit": "You have {0}/{1} saved schematics. Delete some to save this one!",
132+
"fawe.error.schematic.over.disk.limit": "You're about to be at {0} kb of schematics {1} available) Delete some first to save this one!",
128133
"fawe.error.parse.invalid-dangling-character": "Invalid dangling character {0}.",
129134
"fawe.error.parse.unknown-mask": "Unknown mask: {0}, See: {1}",
130135
"fawe.error.parse.unknown-pattern": "Unknown pattern: {0}, See: {1}",

0 commit comments

Comments
 (0)