From 01dff32597b8726004f8fd3e470777063f9be7e2 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Tue, 6 Apr 2021 14:01:04 +0200 Subject: [PATCH] Fine tuning captions Fix listchunks throwing component error --- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 2 +- .../java/com/sk89q/worldedit/WorldEdit.java | 5 +- .../worldedit/command/ApplyBrushCommands.java | 2 +- .../worldedit/command/BrushCommands.java | 2 +- .../worldedit/command/ChunkCommands.java | 5 +- .../worldedit/command/ExpandCommands.java | 2 +- .../worldedit/command/GeneralCommands.java | 14 ++-- .../worldedit/command/PaintBrushCommands.java | 2 +- .../worldedit/command/RegionCommands.java | 4 +- .../worldedit/command/SchematicCommands.java | 67 +++++++------------ .../worldedit/command/SelectionCommands.java | 20 +++--- .../command/util/AsyncCommandBuilder.java | 8 ++- .../com/sk89q/worldedit/entity/Player.java | 8 +-- .../platform/AbstractPlayerActor.java | 4 +- .../internal/command/CommandUtil.java | 10 ++- .../src/main/resources/lang/strings.json | 28 +++++++- 16 files changed, 97 insertions(+), 86 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 44b04b620..40843a677 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -329,7 +329,7 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public void sendAnnouncements() { if (WorldEditPlugin.getInstance().getBukkitImplAdapter() == null) { - printError(TranslatableComponent.of("worldedit.version.bukkit.unsupported-adapter", + print(Caption.of("worldedit.version.bukkit.unsupported-adapter", TextComponent.of("https://intellectualsites.github.io/download/fawe.html", TextColor.AQUA) .clickEvent(ClickEvent.openUrl("https://intellectualsites.github.io/download/fawe.html")))); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java index 0aaba5dee..a18ada3f6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/WorldEdit.java @@ -772,14 +772,13 @@ public final class WorldEdit { } catch (ScriptException e) { // non-exceptional return check if (!(Throwables.getRootCause(e) instanceof ReturnException)) { - player.print(Caption.of("worldedit.script.failed", TextComponent.of(e.getMessage(), TextColor.WHITE))); + player.print(Caption.of("worldedit.script.failed", TextComponent.of(e.getMessage()))); logger.warn("Failed to execute script", e); } } catch (NumberFormatException | WorldEditException e) { throw e; } catch (Throwable e) { - player.print(Caption.of("worldedit.script.failed-console", TextComponent.of(e.getClass().getCanonicalName(), - TextColor.WHITE))); + player.print(Caption.of("worldedit.script.failed-console", TextComponent.of(e.getClass().getCanonicalName()))); logger.warn("Failed to execute script", e); } finally { for (EditSession editSession : scriptContext.getEditSessions()) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java index 6828e457a..23adaf710 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ApplyBrushCommands.java @@ -125,7 +125,7 @@ public class ApplyBrushCommands { @Arg(desc = "The direction in which the item will be applied", def = "up") @Direction(includeDiagonals = true) com.sk89q.worldedit.util.Direction direction) throws WorldEditException { - player.print(TextComponent.builder().append("WARNING: ", TextColor.RED, TextDecoration.BOLD) + player.print(TextComponent.builder().append("WARNING: ") .append(Caption.of("worldedit.brush.apply.item.warning")).build()); setApplyBrush(parameters, player, localSession, new ItemUseFactory(item, direction)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 8599f9c92..614833f5d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -145,7 +145,7 @@ public class BrushCommands { private final WorldEdit worldEdit; - private static final Component UNBIND_COMMAND_COMPONENT = TextComponent.builder("/brush unbind", TextColor.AQUA) + private static final Component UNBIND_COMMAND_COMPONENT = TextComponent.builder("/brush unbind") .clickEvent(ClickEvent.suggestCommand("/brush unbind")) .build(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java index f1662f439..b9bad4442 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ChunkCommands.java @@ -102,8 +102,8 @@ public class ChunkCommands { @ArgFlag(name = 'p', desc = "Page number.", def = "1") int page) throws WorldEditException { final Region region = session.getSelection(world); - actor.print(Caption.of("worldedit.listchunks.listfor", TextComponent.of(actor.getName()))); actor.print(new ChunkListPaginationBox(region).create(page)); + actor.print(Caption.of("worldedit.listchunks.listfor", TextComponent.of(actor.getName()))); } @Command( @@ -177,10 +177,11 @@ public class ChunkCommands { private static class ChunkListPaginationBox extends PaginationBox { //private final Region region; - private final List chunks = null; + private final List chunks; ChunkListPaginationBox(Region region) { super("Selected Chunks", "/listchunks -p %page%"); + this.chunks = new ArrayList<>(region.getChunks()); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java index 976372191..77eba2ffd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ExpandCommands.java @@ -111,7 +111,7 @@ public class ExpandCommands { long newSize = region.getVolume(); session.getRegionSelector(world).explainRegionAdjust(actor, session); long changeSize = newSize - oldSize; - actor.printInfo( + actor.print( Caption.of("worldedit.expand.expanded.vert", TextComponent.of(changeSize)) ); } catch (RegionOperationException e) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index 9724de8f8..e58190fe4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -178,11 +178,11 @@ public class GeneralCommands { } session.setBlockChangeLimit(limit); - Component component = TextComponent.empty().append(TranslatableComponent.of("worldedit.limit.set", TextComponent.of(limit))); + Component component = TextComponent.empty().append(Caption.of("worldedit.limit.set", TextComponent.of(limit))); if (limit != config.defaultChangeLimit) { - component.append(TextComponent.space()).append(TranslatableComponent.of("worldedit.limit.return-to-default", TextColor.GRAY)); + component.append(TextComponent.space()).append(Caption.of("worldedit.limit.return-to-default")); } - actor.printInfo(component); + actor.print(component); } @Command( @@ -205,11 +205,11 @@ public class GeneralCommands { } session.setTimeout(limit); - Component component = TextComponent.empty().append(TranslatableComponent.of("worldedit.timeout.set", TextComponent.of(limit))); + Component component = TextComponent.empty().append(Caption.of("worldedit.timeout.set", TextComponent.of(limit))); if (limit != config.calculationTimeout) { - component.append(TranslatableComponent.of("worldedit.timeout.return-to-default", TextColor.GRAY)); + component.append(TranslatableComponent.of("worldedit.timeout.return-to-default")); } - actor.printInfo(component); + actor.print(component); } @Command( @@ -439,7 +439,7 @@ public class GeneralCommands { } WorldEditAsyncCommandBuilder.createAndSendMessage(actor, new ItemSearcher(search, blocksOnly, itemsOnly, page), - TranslatableComponent.of("worldedit.searchitem.searching")); + Caption.of("worldedit.searchitem.searching")); } private static class ItemSearcher implements Callable { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java index a84cbfddb..e64457f66 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/PaintBrushCommands.java @@ -130,7 +130,7 @@ public class PaintBrushCommands { @Arg(desc = "The direction in which the item will be applied", def = "up") @Direction(includeDiagonals = true) com.sk89q.worldedit.util.Direction direction) throws WorldEditException { - player.print(TextComponent.builder().append("WARNING: ", TextColor.RED, TextDecoration.BOLD) + player.print(TextComponent.builder().append("WARNING: ") .append(TranslatableComponent.of("worldedit.brush.paint.item.warning")).build()); setPaintBrush(parameters, player, localSession, new ItemUseFactory(item, direction)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 5c5aed9d4..79f28acf8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -212,7 +212,7 @@ public class RegionCommands { ) @CommandPermissions("worldedit.light.set") public void setlighting(Player player, EditSession editSession, @Selection Region region) { - player.print(TextComponent.of("Temporarily not working")); + player.print(Caption.of("fawe.info.temporarily-not-working")); } @Command( @@ -221,7 +221,7 @@ public class RegionCommands { ) @CommandPermissions("worldedit.light.set") public void setskylighting(Player player, @Selection Region region) { - player.printInfo(TextComponent.of("Temporarily not working")); + player.print(Caption.of("fawe.info.temporarily-not-working")); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index 5202e7830..b934b3f8e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -53,6 +53,7 @@ import com.sk89q.worldedit.util.formatting.component.PaginationBox; import com.sk89q.worldedit.util.formatting.component.TextComponentProducer; 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; @@ -94,7 +95,6 @@ import static com.boydti.fawe.util.ReflectionUtils.as; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; - /** * Commands that work with schematic files. */ @@ -300,9 +300,9 @@ public class SchematicCommands { format.hold(actor, uri, in); actor.print(Caption.of("fawe.worldedit.schematic.schematic.loaded", filename)); } catch (IllegalArgumentException e) { - actor.printError("Unknown filename: " + filename); + actor.print(Caption.of("worldedit.schematic.unknown-filename", TextComponent.of(filename))); } catch (URISyntaxException | IOException e) { - actor.printError("File could not be read or it does not exist: " + e.getMessage()); + actor.print(TranslatableComponent.of("worldedit.schematic.file-not-exist", TextComponent.of(e.getMessage()))); LOGGER.warn("Failed to load a saved clipboard", e); } finally { if (in != null) { @@ -316,7 +316,7 @@ public class SchematicCommands { @Command( name = "save", - desc = "Save a schematic into your clipboard" + desc = "Save your clipboard into a schematic file" ) @CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"}) public void save(Actor actor, LocalSession session, @@ -326,7 +326,7 @@ public class SchematicCommands { String formatName, @Switch(name = 'f', desc = "Overwrite an existing file.") boolean allowOverwrite, - @Switch(name = 'g', desc = "//TODO") + @Switch(name = 'g', desc = "Bypasses per-player-schematic folders") boolean global) throws WorldEditException { LocalConfiguration config = worldEdit.getConfiguration(); @@ -360,7 +360,7 @@ public class SchematicCommands { boolean overwrite = f.exists(); if (overwrite) { if (!actor.hasPermission("worldedit.schematic.delete")) { - throw new StopExecutionException(TextComponent.of("That schematic already exists!")); + throw new StopExecutionException(TranslatableComponent.of("worldedit.schematic.already-exists")); } if (other) { if (!actor.hasPermission("worldedit.schematic.delete.other")) { @@ -390,7 +390,7 @@ public class SchematicCommands { .registerWithSupervisor(worldEdit.getSupervisor(), "Saving schematic " + filename) .sendMessageAfterDelay(Caption.of("worldedit.schematic.save.saving")) .onSuccess(filename + " saved" + (overwrite ? " (overwriting previous file)." : "."), null) - .onFailure("Failed to save schematic", worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter()) + .onFailure(TranslatableComponent.of("worldedit.schematic.failed-to-save"), worldEdit.getPlatformManager().getPlatformCommandManager().getExceptionConverter()) .buildAndExec(worldEdit.getExecutorService()); } @@ -406,7 +406,7 @@ public class SchematicCommands { File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(working, player.getUniqueId().toString()) : working; File destDir = new File(dir, directory); if (!MainUtil.isInSubDirectory(working, destDir)) { - player.printError("Directory " + destDir + " does not exist!"); + player.print(Caption.of("worldedit.schematic.directory-does-not-exist", TextComponent.of(String.valueOf(destDir)))); return; } if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) { @@ -420,7 +420,7 @@ public class SchematicCommands { return; } if (!destDir.exists() && !destDir.mkdirs()) { - player.printError("Creation of " + destDir + " failed! (check file permissions)"); + player.print(Caption.of("worldedit.schematic.file-perm-fail", TextComponent.of(String.valueOf(destDir)))); return; } for (File source : sources) { @@ -483,7 +483,7 @@ public class SchematicCommands { first = false; } first = true; - actor.printInfo(TextComponent.of(builder.toString())); + actor.print(TextComponent.of(builder.toString())); } } @@ -506,7 +506,7 @@ public class SchematicCommands { @Arg(name = "filter", desc = "Filter for schematics", def = "all") String filter, Arguments arguments) throws WorldEditException { if (oldFirst && newFirst) { - throw new StopExecutionException(TextComponent.of("Cannot sort by oldest and newest.")); + throw new StopExecutionException(Caption.of("worldedit.schematic.sorting-old-new")); } String pageCommand = "/" + arguments.get(); LocalConfiguration config = worldEdit.getConfiguration(); @@ -536,50 +536,37 @@ public class SchematicCommands { List components = UtilityCommands.entryToComponent(dir, entries, isLoaded, (name, path, type, loaded) -> { - TextColor color = TextColor.GRAY; - switch (type) { - case URL: - color = TextColor.DARK_GRAY; - break; - case FILE: - color = TextColor.GREEN; - break; - case DIRECTORY: - color = TextColor.GOLD; - break; - } - TextComponentProducer msg = new TextComponentProducer(); - msg.append(TextComponent.of(" - ", color)); + msg.append(Caption.of("worldedit.schematic.dash.symbol")); if (loaded) { - msg.append(TextComponent.of("[-]", TextColor.RED) + msg.append(Caption.of("worldedit.schematic.minus.symbol") .clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, unload + " " + path)) - .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Unload")))); + .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.unload")))); } else { - msg.append(TextComponent.of("[+]", TextColor.GREEN) + msg.append(Caption.of("worldedit.schematic.plus.symbol") .clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, loadMulti + " " + path)) - .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Add to clipboard")))); + .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.clipboard")))); } if (type != UtilityCommands.URIType.DIRECTORY) { - msg.append(TextComponent.of("[X]", TextColor.DARK_RED) + msg.append(Caption.of("worldedit.schematic.x.symbol") .clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, delete + " " + path)) - .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("delete"))) + .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.delete"))) ); } else if (hasShow) { - msg.append(TextComponent.of("[O]", TextColor.DARK_AQUA) + msg.append(Caption.of("worldedit.schematic.0.symbol") .clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, showCmd + " " + path)) - .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("visualize"))) + .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.visualize"))) ); } - TextComponent msgElem = TextComponent.of(name, color); + TextComponent msgElem = TextComponent.of(name); if (type != UtilityCommands.URIType.DIRECTORY) { msgElem = msgElem.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, loadSingle + " " + path)); - msgElem = msgElem.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Load"))); + msgElem = msgElem.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.load"))); } else { msgElem = msgElem.clickEvent(ClickEvent.of(ClickEvent.Action.SUGGEST_COMMAND, list + " " + path)); - msgElem = msgElem.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("List"))); + msgElem = msgElem.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, Caption.of("worldedit.schematic.list"))); } msg.append(msgElem); @@ -929,7 +916,7 @@ public class SchematicCommands { private final File[] files; SchematicPaginationBox(String rootDir, File[] files, String pageCommand) { - super("Available schematics", pageCommand); + super("worldedit.schematic.available", pageCommand); this.prefix = rootDir == null ? "" : rootDir; this.files = files; } @@ -947,14 +934,12 @@ public class SchematicCommands { return TextComponent.builder() .content("") - .append(TextComponent.of("[L]") - .color(TextColor.GOLD) + .append(TranslatableComponent.of("worldedit.schematic.load.symbol") .clickEvent(ClickEvent .of(ClickEvent.Action.RUN_COMMAND, "/schem load \"" + path + "\"")) - .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to load")))) + .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TranslatableComponent.of("worldedit.schematic.click-to-load")))) .append(TextComponent.space()) .append(TextComponent.of(path) - .color(TextColor.DARK_GREEN) .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of(format)))) .build(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java index f3c27f631..c9d8ad602 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java @@ -312,14 +312,14 @@ public class SelectionCommands { ) @CommandPermissions("worldedit.wand.toggle") public void toggleWand(Player player) { - player.printInfo( + player.print( Caption.of( "worldedit.wand.selwand.now.tool", - TextComponent.of("/tool none", TextColor.AQUA).clickEvent( + TextComponent.of("/tool none").clickEvent( ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/tool none")), - TextComponent.of("/tool selwand", TextColor.AQUA).clickEvent( + TextComponent.of("/tool selwand").clickEvent( ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/tool selwand")), - TextComponent.of("//wand", TextColor.AQUA).clickEvent( + TextComponent.of("//wand").clickEvent( ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "//wand")) ) ); @@ -654,8 +654,8 @@ public class SelectionCommands { box.appendCommand("sphere", Caption.of("worldedit.select.sphere.description"), "//sel sphere"); box.appendCommand("cyl", Caption.of("worldedit.select.cyl.description"), "//sel cyl"); box.appendCommand("convex", Caption.of("worldedit.select.convex.description"), "//sel convex"); - box.appendCommand("polyhedral", "Select a hollow polyhedral", "//sel polyhedral"); - box.appendCommand("fuzzy[=]", "Select all connected blocks (magic wand)", "//sel fuzzy[=]"); + box.appendCommand("polyhedral", Caption.of("fawe.selection.sel.polyhedral"), "//sel polyhedral"); + box.appendCommand("fuzzy[=]", Caption.of("fawe.selection.sel.fuzzy-instruction"), "//sel fuzzy[=]"); actor.print(box.create(1)); return; @@ -718,13 +718,13 @@ public class SelectionCommands { final BlockState state = c.getID(); final BlockType blockType = state.getBlockType(); - Component blockName = blockType.getRichName().color(TextColor.LIGHT_PURPLE); + Component blockName = blockType.getRichName(); TextComponent toolTip; if (separateStates && state != blockType.getDefaultState()) { - toolTip = TextComponent.of(state.getAsString(), TextColor.GRAY); - blockName = blockName.append(TextComponent.of("*", TextColor.LIGHT_PURPLE)); + toolTip = TextComponent.of(state.getAsString()); + blockName = blockName.append(TextComponent.of("*")); } else { - toolTip = TextComponent.of(blockType.getId(), TextColor.GRAY); + toolTip = TextComponent.of(blockType.getId()); } blockName = blockName.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, toolTip)); line.append(blockName); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java index 9d8971903..cec4842fe 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/util/AsyncCommandBuilder.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.command.util; +import com.boydti.fawe.config.Caption; import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.ListenableFuture; @@ -29,6 +30,7 @@ import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.formatting.component.ErrorFormat; 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.format.TextColor; import com.sk89q.worldedit.util.task.FutureForwardingTask; import com.sk89q.worldedit.util.task.Supervisor; @@ -162,18 +164,18 @@ public final class AsyncCommandBuilder { if (message == null) { if (Strings.isNullOrEmpty(converted.getMessage())) { - message = TextComponent.of("Unknown error."); + message = TranslatableComponent.of("worldedit.error.unknown"); } else { message = converted.getRichMessage(); } } - sender.printError(failure.append(TextComponent.of(": ")).append(message)); + sender.print(failure.append(TextComponent.of(": ")).append(message)); } } else { throw orig; } } catch (Throwable unknown) { - sender.printError(failure.append(TextComponent.of(": Unknown error. Please see console."))); + sender.print(failure.append(Caption.of("worldedit.command.error.report"))); LOGGER.error("Uncaught exception occurred in task: " + description, orig); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java index b12abc4c4..e9eb62c99 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java @@ -433,10 +433,10 @@ public interface Player extends Entity, Actor { } catch (Exception event) { printError(TextComponent.of("====== INVALID CLIPBOARD ======")); event.printStackTrace(); - printError(Caption.of("fawe.error.stacktrace")); - printError(Caption.of("fawe.error.no-failure")); - printError(Caption.of("File: ", TextComponent.of(file.getName()), TextComponent.of(" (len:"), TextComponent.of(file.length()), TextComponent.of(")"))); - printError(Caption.of("fawe.error.stacktrace")); + print(Caption.of("fawe.error.stacktrace")); + print(Caption.of("fawe.error.no-failure")); + print(Caption.of("File: ", TextComponent.of(file.getName()), TextComponent.of(" (len:"), TextComponent.of(file.length()), TextComponent.of(")"))); + print(Caption.of("fawe.error.stacktrace")); } } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 138e0f830..df138cfb1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -667,13 +667,13 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public File openFileOpenDialog(String[] extensions) { - printError(Caption.of("worldedit.platform.no-file-dialog")); + print(Caption.of("worldedit.platform.no-file-dialog")); return null; } @Override public File openFileSaveDialog(String[] extensions) { - printError(Caption.of("worldedit.platform.no-file-dialog")); + print(Caption.of("worldedit.platform.no-file-dialog")); return null; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java index c880f365b..bd1e17da5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/CommandUtil.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.internal.command; +import com.boydti.fawe.config.Caption; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.sk89q.worldedit.extension.platform.Actor; @@ -26,9 +27,9 @@ import com.sk89q.worldedit.extension.platform.PlatformCommandManager; import com.sk89q.worldedit.internal.util.Substring; 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.format.TextColor; -import com.sk89q.worldedit.util.formatting.text.format.TextDecoration; import org.enginehub.piston.Command; import org.enginehub.piston.CommandParameters; import org.enginehub.piston.NoInputCommandParameters; @@ -50,14 +51,13 @@ import static java.util.stream.Collectors.toList; public class CommandUtil { - private static final Component DEPRECATION_MARKER = TextComponent.of("This command is deprecated."); + private static final Component DEPRECATION_MARKER = Caption.of("worldedit.command.deprecation"); private static Component makeDeprecatedFooter(String reason, Component replacement) { return TextComponent.builder() .append(DEPRECATION_MARKER) .append(" " + reason + ".") .append(TextComponent.newline()) - .append(replacement.color(TextColor.GOLD).decoration(TextDecoration.ITALIC, true)) .build(); } @@ -85,11 +85,9 @@ public class CommandUtil { } public static Component createNewCommandReplacementText(String suggestedCommand) { - return TextComponent.builder("Please use ", TextColor.GOLD) + return TranslatableComponent.builder("worldedit.command.deprecation-message") .append(TextComponent.of(suggestedCommand) - .decoration(TextDecoration.UNDERLINED, true) .clickEvent(ClickEvent.suggestCommand(suggestedCommand))) - .append(" instead.") .build(); } diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 5620b8b5e..2c57c27e6 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -14,6 +14,7 @@ "fawe.info.worldedit.bypassed": "Currently bypassing FAWE restriction.", "fawe.info.worldedit.restricted": "Your FAWE edits are now restricted.", "fawe.info.worldedit.oom.admin": "Possible options:\n - //fast\n - Do smaller edits\n - Allocate more memory\n - Disable `max-memory-percent`", + "fawe.info.temporarily-not-working": "Temporarily not working", "fawe.web.generating.link": "Uploading {0}, please wait...", "fawe.web.generating.link.failed": "Failed to generate download link!", @@ -153,7 +154,9 @@ "fawe.selection.sel.max": "{0} points maximum.", "fawe.selection.sel.fuzzy": "Fuzzy selector: Left click to select all contingent blocks, right click to add. To select an air cavity, use //pos1.", + "fawe.selection.sel.fuzzy-instruction": "Select all connected blocks (magic wand)", "fawe.selection.sel.convex.polyhedral": "Convex polyhedral selector: Left click=First vertex, right click to add more.", + "fawe.selection.sel.polyhedral": "Select a hollow polyhedral", "fawe.selection.sel.list": "For a list of selection types use: //sel list", "fawe.tips.tip.sel.list": "Tip: See the different selection modes with //sel list", @@ -345,6 +348,27 @@ "worldedit.schematic.delete.failed": "Deletion of {0} failed! Is it read-only?", "worldedit.schematic.delete.deleted": "{0} has been deleted.", "worldedit.schematic.formats.title": "Available clipboard formats (Name: Lookup names)", + "worldedit.schematic.load.symbol": "[L]", + "worldedit.schematic.plus.symbol": "[+]", + "worldedit.schematic.minus.symbol": "[-]", + "worldedit.schematic.x.symbol": "[X]", + "worldedit.schematic.0.symbol": "[O]", + "worldedit.schematic.dash.symbol": " - ", + "worldedit.schematic.click-to-load": "Click to load", + "worldedit.schematic.load": "Load", + "worldedit.schematic.list": "List", + "worldedit.schematic.available": "Available schematics", + "worldedit.schematic.unload": "Unload", + "worldedit.schematic.delete": "delete", + "worldedit.schematic.visualize": "visualize", + "worldedit.schematic.clipboard": "Add to clipboard", + "worldedit.schematic.unknown-filename": "Unknown filename: {0}", + "worldedit.schematic.file-not-exist": "File could not be read or it does not exist: {0}", + "worldedit.schematic.already-exists": "That schematic already exists!", + "worldedit.schematic.failed-to-save": "Failed to save schematic", + "worldedit.schematic.directory-does-not-exist": "Directory '{0}' does not exist!", + "worldedit.schematic.file-perm-fail": "Creation of '{0}' failed! Check file permission.", + "worldedit.schematic.sorting-old-new": "Cannot sort by oldest and newest.", "worldedit.pos.already-set": "Position already set.", "worldedit.pos.console-require-coords": "You must provide coordinates as console.", @@ -481,7 +505,9 @@ "worldedit.command.time-elapsed": "{0}s elapsed (history: {1} changed; {2} blocks/sec).", "worldedit.command.permissions": "You are not permitted to do that. Are you in the right mode?", "worldedit.command.player-only": "This command must be used with a player.", - "worldedit.command.error.report": "Please report this error: [See console]", + "worldedit.command.error.report": "&cPlease report this error: [See console]", + "worldedit.command.deprecation": "This command is deprecated.", + "worldedit.command.deprecation-message": "Please use '{0}' instead.", "worldedit.pastebin.uploading": "(Please wait... sending output to paste service...)", "worldedit.session.cant-find-session": "Unable to find session for {0}", "worldedit.platform.no-file-dialog": "File dialogs are not supported in your environment.",