diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java index 8044b4829..ae622c7b6 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitCommand.java @@ -1,6 +1,7 @@ package com.boydti.fawe.bukkit; import com.boydti.fawe.config.BBC; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.FaweCommand; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitBlockCommandSender; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java index b6c0a68eb..053edcfad 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java @@ -77,7 +77,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements @Override public void print(String msg) { for (String part : msg.split("\n")) { - print(TextComponent.of(part, TextColor.LIGHT_PURPLE)); + print(TextComponent.of(part, TextColor.GRAY)); } } 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 1bb75d1f2..3da921251 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 @@ -21,6 +21,8 @@ package com.sk89q.worldedit.bukkit; import com.boydti.fawe.Fawe; import com.boydti.fawe.bukkit.FaweBukkit; +import com.boydti.fawe.config.BBC; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.util.TaskManager; @@ -40,11 +42,17 @@ import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.formatting.WorldEditText; 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.adapter.bukkit.TextAdapter; +import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer; +import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; +import java.util.ArrayList; +import java.util.List; import java.util.Locale; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.gamemode.GameMode; @@ -167,28 +175,25 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public void print(String msg) { - for (String part : msg.split("\n")) { - player.sendMessage("\u00A7d" + part); - } + print(LegacyComponentSerializer.legacy().deserialize("&7" + msg, '&')); } @Override public void printDebug(String msg) { - for (String part : msg.split("\n")) { - player.sendMessage("\u00A77" + part); - } + print(LegacyComponentSerializer.legacy().deserialize("&3" + msg, '&')); } @Override public void printError(String msg) { - for (String part : msg.split("\n")) { - player.sendMessage("\u00A7c" + part); - } + print(LegacyComponentSerializer.legacy().deserialize("&c" + msg, '&')); } @Override public void print(Component component) { - TextAdapter.sendComponent(player, WorldEditText.format(component, getLocale())); + Component prefix = TranslatableComponent.of("fawe.prefix"); + component = TextComponent.builder().append(prefix).append(component).build(); + component = BBC.color(component, getLocale()); + TextAdapter.sendComponent(player, component); } @Override @@ -366,10 +371,10 @@ public class BukkitPlayer extends AbstractPlayerActor { } @Override - public void sendTitle(String title, String sub) { - player.sendTitle(ChatColor.GOLD + title, ChatColor.GOLD + sub, 0, 70, 20); - Bukkit.getServer().dispatchCommand(player, "title " + getName() + " subtitle [{\"text\":\"" + sub + "\",\"color\":\"gold\"}]"); - Bukkit.getServer().dispatchCommand(player, "title " + getName() + " title [{\"text\":\"" + title + "\",\"color\":\"gold\"}]"); + public void sendTitle(Component title, Component sub) { + String titleStr = WorldEditText.reduceToText(title, getLocale()); + String subStr = WorldEditText.reduceToText(sub, getLocale()); + player.sendTitle(titleStr, subStr, 0, 70, 20); } @Override diff --git a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java index 69754c103..820696abe 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/Fawe.java @@ -2,6 +2,7 @@ package com.boydti.fawe; import com.boydti.fawe.beta.implementation.queue.QueueHandler; import com.boydti.fawe.config.BBC; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.brush.visualization.VisualQueue; import com.boydti.fawe.regions.general.integrations.plotquared.PlotSquaredFeature; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java index 62bce6fea..d513718e1 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -2,6 +2,8 @@ package com.boydti.fawe; import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.config.BBC; +import com.sk89q.worldedit.util.formatting.text.Component; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.changeset.DiskStorageHistory; @@ -232,7 +234,7 @@ public class FaweAPI { * @param reason * @see EditSession#getRegionExtent() To get the FaweExtent for an EditSession */ - public static void cancelEdit(Extent extent, BBC reason) { + public static void cancelEdit(Extent extent, Component reason) { try { WEManager.IMP.cancelEdit(extent, new FaweException(reason)); } catch (WorldEditException ignore) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java index 658a45046..e15476b1f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/FaweCache.java @@ -5,6 +5,7 @@ import static org.slf4j.LoggerFactory.getLogger; import com.boydti.fawe.beta.Trimable; import com.boydti.fawe.config.BBC; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.collection.BitArray4096; import com.boydti.fawe.object.collection.CleanableThreadLocal; @@ -199,15 +200,15 @@ public enum FaweCache implements Trimable { */ public static final FaweChunkLoadException CHUNK = new FaweChunkLoadException(); public static final FaweBlockBagException BLOCK_BAG = new FaweBlockBagException(); - public static final FaweException MANUAL = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MANUAL); - public static final FaweException NO_REGION = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_NO_REGION); - public static final FaweException OUTSIDE_REGION = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_OUTSIDE_REGION); - public static final FaweException MAX_CHECKS = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); - public static final FaweException MAX_CHANGES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHANGES); - public static final FaweException LOW_MEMORY = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY); - public static final FaweException MAX_ENTITIES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_ENTITIES); - public static final FaweException MAX_TILES = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_TILES); - public static final FaweException MAX_ITERATIONS = new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_ITERATIONS); + public static final FaweException MANUAL = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual")); + public static final FaweException NO_REGION = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.no.region")); + public static final FaweException OUTSIDE_REGION = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region")); + public static final FaweException MAX_CHECKS = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.checks")); + public static final FaweException MAX_CHANGES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.changes")); + public static final FaweException LOW_MEMORY = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.low.memory")); + public static final FaweException MAX_ENTITIES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.entities")); + public static final FaweException MAX_TILES = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.tiles")); + public static final FaweException MAX_ITERATIONS = new FaweException(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.max.iterations")); /* thread cache diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java index 950237b4f..295ff09be 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/AnvilCommands.java @@ -52,7 +52,7 @@ public class AnvilCommands { // boolean copy = false; // if (FaweAPI.getWorld(folder) != null) { // if (!force) { -// BBC.WORLD_IS_LOADED.send(player); +// player.print(TranslatableComponent.of("fawe.worldedit.anvil.world.is.loaded")) // return null; // } // copy = true; @@ -80,7 +80,7 @@ public class AnvilCommands { // @Deprecated // public static > T runWithSelection(Player player, EditSession editSession, Region selection, T filter) { // if (!(selection instanceof CuboidRegion)) { -// BBC.NO_REGION.send(player); +// player.print(TranslatableComponent.of("fawe.error.no.region")) // return null; // } // CuboidRegion cuboid = (CuboidRegion) selection; @@ -131,7 +131,7 @@ public class AnvilCommands { // final FaweBlockMatcher matchTo = FaweBlockMatcher.setBlocks(worldEdit.getBlocks(player, to, true)); // ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); // ReplaceSimpleFilter result = runWithWorld(player, folder, filter, true); -// if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); } @Command( @@ -148,7 +148,7 @@ public class AnvilCommands { // RemapFilter filter = new RemapFilter(from, to); // RemapFilter result = runWithWorld(player, folder, filter, true); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -167,7 +167,7 @@ public class AnvilCommands { // DeleteUninhabitedFilter filter = new DeleteUninhabitedFilter(fileDurationMillis, inhabitedTicks, fileDurationMillis); TODO NOT IMPLEMENTED // DeleteUninhabitedFilter result = runWithWorld(player, folder, filter, true); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -190,7 +190,7 @@ public class AnvilCommands { // } // DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -212,7 +212,7 @@ public class AnvilCommands { // } // DeleteUnclaimedFilter result = runWithSelection(player, editSession, selection, filter); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -229,7 +229,7 @@ public class AnvilCommands { // DeleteOldFilter filter = new DeleteOldFilter(duration); // DeleteOldFilter result = runWithWorld(player, folder, filter, true); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -249,7 +249,7 @@ public class AnvilCommands { // MCAQueue queue = new MCAQueue(defaultQueue); // PlotTrimFilter result = queue.filterWorld(filter); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -262,7 +262,7 @@ public class AnvilCommands { // DeleteBiomeFilterSimple filter = new DeleteBiomeFilterSimple(biome); TODO NOT IMPLEMENTED // DeleteBiomeFilterSimple result = runWithWorld(player, folder, filter, true, unsafe); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -275,7 +275,7 @@ public class AnvilCommands { // TrimAirFilter filter = new TrimAirFilter(); TODO NOT IMPLEMENTED // TrimAirFilter result = runWithWorld(player, folder, filter, true, unsafe); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -289,7 +289,7 @@ public class AnvilCommands { // DebugFixP2Roads filter = new DebugFixP2Roads(); TODO NOT IMPLEMENTED // DebugFixP2Roads result = runWithWorld(player, folder, filter, true, true); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -319,7 +319,7 @@ public class AnvilCommands { // filter = new ReplacePatternFilter(matchFrom, to); // } // MCAFilterCounter result = runWithWorld(player, folder, filter, true); -// if (result != null) player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); } // @@ -341,7 +341,7 @@ public class AnvilCommands { // filter = counter; // } // MCAFilterCounter result = runWithWorld(player, folder, filter, true); -// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal())); +// if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.selection.selection.count", (result.getTotal()))); } @Command( @@ -393,7 +393,7 @@ public class AnvilCommands { // }; // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -415,7 +415,7 @@ public class AnvilCommands { // filter = counter; // } // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); -// if (result != null) player.print(BBC.SELECTION_COUNT.format(result.getTotal())); +// if (result != null) player.print(TranslatableComponent.of("fawe.worldedit.selection.selection.count", (result.getTotal()))); } // @@ -514,7 +514,7 @@ public class AnvilCommands { // ReplaceSimpleFilter filter = new ReplaceSimpleFilter(matchFrom, matchTo); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -546,7 +546,7 @@ public class AnvilCommands { // } // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -560,7 +560,7 @@ public class AnvilCommands { // MCAFilterCounter filter = new SetPatternFilter(to); TODO NOT IMPLEMENTED // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -578,7 +578,7 @@ public class AnvilCommands { // RemoveLayerFilter filter = new RemoveLayerFilter(minY, maxY, id); // MCAFilterCounter result = runWithSelection(player, editSession, selection, filter); // if (result != null) { -// player.print(BBC.VISITOR_BLOCK.format(result.getTotal())); +// player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block", (result.getTotal()))); // } } @@ -590,7 +590,7 @@ public class AnvilCommands { @CommandPermissions("worldedit.anvil.copychunks") public void copy(Player player, LocalSession session, EditSession editSession, @Selection Region selection) throws WorldEditException { // if (!(selection instanceof CuboidRegion)) { TODO NOT IMPLEMENTED -// BBC.NO_REGION.send(player); +// player.print(TranslatableComponent.of("fawe.error.no.region")) // return; // } // CuboidRegion cuboid = (CuboidRegion) selection; @@ -601,7 +601,7 @@ public class AnvilCommands { // MCAClipboard clipboard = new MCAClipboard(queue, cuboid, origin); // FawePlayer fp = FawePlayer.wrap(player); // fp.setMeta(FawePlayer.METADATA_KEYS.ANVIL_CLIPBOARD, clipboard); -// BBC.COMMAND_COPY.send(player, selection.getArea()); +// player.print(TranslatableComponent.of("fawe.worldedit.copy.command.copy" , selection.getArea())); } @Command( @@ -638,6 +638,6 @@ public class AnvilCommands { // pasteQueue.pasteRegion(copyQueue, copyRegion, offset, iAnvilHistory); // } catch (IOException e) { throw new RuntimeException(e); } // }); -// BBC.COMMAND_PASTE.send(player, player.getPosition().toBlockVector()); +// player.print(TranslatableComponent.of("fawe.worldedit.paste.command.paste" , player.getPosition().toBlockVector())); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java index 6ec3e86e2..0cec178df 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java @@ -8,6 +8,7 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock; import com.boydti.fawe.config.BBC; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.clipboard.MultiClipboardHolder; @@ -949,7 +950,7 @@ public class CFICommands { JsonObject data1 = obj.get("data").getAsJsonObject(); String link = data1.get("link").getAsString(); URL url = new URL(link); - BBC.DOWNLOAD_LINK.send(player, url); + player.print(TranslatableComponent.of("fawe.web.download.link" , url)); } @Command( diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java index 9beca2402..2ed1d0f54 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java @@ -3,6 +3,7 @@ package com.boydti.fawe.command; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.config.BBC; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweCommand; import com.boydti.fawe.object.RegionWrapper; @@ -34,11 +35,11 @@ public class Rollback extends FaweCommand { } Player player = (Player) actor; if (!Settings.IMP.HISTORY.USE_DATABASE) { - BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )"); + player.print(TranslatableComponent.of("fawe.error.setting.disable" , "history.use-database (Import with /frb #import )")); return false; } if (args.length != 3) { - BBC.COMMAND_SYNTAX.send(player, "/frb u: r: t: