Remove TranslatableComponent override

use Caption class
This commit is contained in:
Jesse Boyd 2019-12-16 09:01:41 +00:00
parent fe1215ff38
commit aac30742de
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
29 changed files with 131 additions and 265 deletions

View File

@ -7,7 +7,7 @@ import static com.sk89q.worldedit.util.formatting.text.TextComponent.newline;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock; import com.boydti.fawe.beta.implementation.filter.block.SingleFilterBlock;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Caption;
import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
@ -949,7 +949,7 @@ public class CFICommands {
JsonObject data1 = obj.get("data").getAsJsonObject(); JsonObject data1 = obj.get("data").getAsJsonObject();
String link = data1.get("link").getAsString(); String link = data1.get("link").getAsString();
URL url = new URL(link); URL url = new URL(link);
player.print(TranslatableComponent.of("fawe.web.download.link" , url)); player.print(Caption.of("fawe.web.download.link" , url));
} }
@Command( @Command(

View File

@ -4,12 +4,19 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.util.formatting.WorldEditText; import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; 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.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer; import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Objects;
import java.util.stream.Collectors;
public class Caption { public class Caption {
public static String toString(Component component) { public static String toString(Component component) {
@ -74,4 +81,15 @@ public class Caption {
return parent; return parent;
} }
public static TranslatableComponent of(@Nonnull final String key, @Nullable final TextColor color, @Nonnull final List<? extends Component> args) {
return TranslatableComponent.of(key, color, Collections.emptySet(), args);
}
@Nonnull
public static TranslatableComponent of(@Nonnull final String key, final Object... args) {
List<Component> components = Arrays.stream(args)
.map(arg -> arg instanceof Component ? (Component) arg : TextComponent.of(Objects.toString(arg)))
.collect(Collectors.toList());
return TranslatableComponent.of(key, components);
}
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
@ -35,14 +36,14 @@ public class CatenaryBrush implements Brush, ResettableTool {
if (pos1 == null || pos2.equals(pos1)) { if (pos1 == null || pos2.equals(pos1)) {
if (!visual) { if (!visual) {
pos1 = pos2; pos1 = pos2;
editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.line.primary", pos2)); editSession.getPlayer().print(Caption.of("fawe.worldedit.brush.brush.line.primary", pos2));
} }
return; return;
} }
if (this.vertex == null) { if (this.vertex == null) {
vertex = getVertex(pos1.toVector3(), pos2.toVector3(), slack); vertex = getVertex(pos1.toVector3(), pos2.toVector3(), slack);
if (this.direction) { if (this.direction) {
editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.catenary.direction", 2)); editSession.getPlayer().print(Caption.of("fawe.worldedit.brush.brush.catenary.direction", 2));
return; return;
} }
} else if (this.direction) { } else if (this.direction) {

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder; import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder;
@ -87,7 +88,7 @@ public class CopyPastaBrush implements Brush, ResettableTool {
ClipboardHolder holder = new ClipboardHolder(newClipboard); ClipboardHolder holder = new ClipboardHolder(newClipboard);
session.setClipboard(holder); session.setClipboard(holder);
int blocks = builder.size(); int blocks = builder.size();
player.print(TranslatableComponent.of("fawe.worldedit.copy.command.copy" , blocks)); player.print(Caption.of("fawe.worldedit.copy.command.copy" , blocks));
} else { } else {
AffineTransform transform = null; AffineTransform transform = null;
if (randomRotate) { if (randomRotate) {

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Caption;
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory; import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
@ -8,7 +9,6 @@ import com.boydti.fawe.config.Settings;
import com.boydti.fawe.database.DBHandler; import com.boydti.fawe.database.DBHandler;
import com.boydti.fawe.database.RollbackDatabase; import com.boydti.fawe.database.RollbackDatabase;
import com.boydti.fawe.object.change.MutableFullBlockChange; import com.boydti.fawe.object.change.MutableFullBlockChange;
import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
@ -62,11 +62,11 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
public boolean perform(final Player player, LocalSession session, boolean rightClick) { public boolean perform(final Player player, LocalSession session, boolean rightClick) {
if (!session.isToolControlEnabled() || !player.hasPermission("worldedit.tool.inspect")) { if (!session.isToolControlEnabled() || !player.hasPermission("worldedit.tool.inspect")) {
player.print(TranslatableComponent.of("", "worldedit.tool.inspect")); player.print(Caption.of("", "worldedit.tool.inspect"));
return false; return false;
} }
if (!Settings.IMP.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
player.print(TranslatableComponent.of("fawe.error.setting.disable", ("history.use-database (Import with /history import )"))); player.print(Caption.of("fawe.error.setting.disable", ("history.use-database (Import with /history import )")));
return false; return false;
} }
try { try {
@ -95,7 +95,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
String ageFormatted = MainUtil.secToTime(age / 1000); String ageFormatted = MainUtil.secToTime(age / 1000);
BlockState blockFrom = BlockState.getFromOrdinal(from); BlockState blockFrom = BlockState.getFromOrdinal(from);
BlockState blockTo = BlockState.getFromOrdinal(to); BlockState blockTo = BlockState.getFromOrdinal(to);
TranslatableComponent msg = TranslatableComponent.of("fawe.worldedit.tool.tool.inspect.info", name, blockFrom, blockTo, ageFormatted); TranslatableComponent msg = Caption.of("fawe.worldedit.tool.tool.inspect.info", name, blockFrom, blockTo, ageFormatted);
String cmd = edit.getCommand(); String cmd = edit.getCommand();
TextComponent hover = TextComponent.of(cmd, TextColor.GOLD); TextComponent hover = TextComponent.of(cmd, TextColor.GOLD);
@ -105,7 +105,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
player.print(msg); player.print(msg);
} }
} }
player.print(TranslatableComponent.of("fawe.worldedit.tool.tool.inspect.info.footer" , count)); player.print(Caption.of("fawe.worldedit.tool.tool.inspect.info.footer" , count));
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.brush; package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.visualization.VisualExtent; import com.boydti.fawe.object.brush.visualization.VisualExtent;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
@ -25,7 +26,7 @@ public class LineBrush implements Brush, ResettableTool {
if (pos1 == null) { if (pos1 == null) {
if (!visual) { if (!visual) {
pos1 = position; pos1 = position;
editSession.getPlayer().print(TranslatableComponent.of("fawe.worldedit.brush.brush.line.primary", position)); editSession.getPlayer().print(Caption.of("fawe.worldedit.brush.brush.line.primary", position));
} }
return; return;
} }

View File

@ -1,6 +1,6 @@
package com.boydti.fawe.object.brush.scroll; package com.boydti.fawe.object.brush.scroll;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Caption;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -46,7 +46,7 @@ public abstract class Scroll implements ScrollTool {
return null; return null;
case CLIPBOARD: case CLIPBOARD:
if (arguments.size() != 2) { if (arguments.size() != 2) {
if (message) player.print(TranslatableComponent.of("fawe.error.command.syntax" , "clipboard [file]")); if (message) player.print(Caption.of("fawe.error.command.syntax" , "clipboard [file]"));
return null; return null;
} }
String filename = arguments.get(1); String filename = arguments.get(1);
@ -61,7 +61,7 @@ public abstract class Scroll implements ScrollTool {
} }
case MASK: case MASK:
if (arguments.size() < 2) { if (arguments.size() < 2) {
if (message) player.print(TranslatableComponent.of("fawe.error.command.syntax" , "mask [mask 1] [mask 2] [mask 3]...")); if (message) player.print(Caption.of("fawe.error.command.syntax" , "mask [mask 1] [mask 2] [mask 3]..."));
return null; return null;
} }
Mask[] masks = new Mask[arguments.size() - 1]; Mask[] masks = new Mask[arguments.size() - 1];
@ -72,7 +72,7 @@ public abstract class Scroll implements ScrollTool {
return (new ScrollMask(tool, masks)); return (new ScrollMask(tool, masks));
case PATTERN: case PATTERN:
if (arguments.size() < 2) { if (arguments.size() < 2) {
if (message) player.print(TranslatableComponent.of("fawe.error.command.syntax" , "pattern [pattern 1] [pattern 2] [pattern 3]...")); if (message) player.print(Caption.of("fawe.error.command.syntax" , "pattern [pattern 1] [pattern 2] [pattern 3]..."));
return null; return null;
} }
Pattern[] patterns = new Pattern[arguments.size() - 1]; Pattern[] patterns = new Pattern[arguments.size() - 1];

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.progress; package com.boydti.fawe.object.progress;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
@ -114,7 +115,7 @@ public class DefaultProgressTracker implements BiConsumer<DefaultProgressTracker
String speedStr = StringMan.padRight("" + speed, 3); String speedStr = StringMan.padRight("" + speed, 3);
String percent = StringMan.padRight("" + (amountDispatch != 0 ? (amountDispatch * 100) / totalQueue : 0), 3); String percent = StringMan.padRight("" + (amountDispatch != 0 ? (amountDispatch * 100) / totalQueue : 0), 3);
int remaining = speed != 0 ? amountQueue / speed : -1; int remaining = speed != 0 ? amountQueue / speed : -1;
sendTile(TextComponent.empty(), TranslatableComponent.of("fawe.progress.progress.message", queue, dispatch, percent, StringMan.padLeft("" + speed, 3), StringMan.padLeft("" + remaining, 3))); sendTile(TextComponent.empty(), Caption.of("fawe.progress.progress.message", queue, dispatch, percent, StringMan.padLeft("" + speed, 3), StringMan.padLeft("" + remaining, 3)));
} }
public void sendTile(Component title, Component sub) { public void sendTile(Component title, Component sub) {

View File

@ -1,6 +1,6 @@
package com.boydti.fawe.object.regions.selector; package com.boydti.fawe.object.regions.selector;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Caption;
import com.boydti.fawe.object.regions.FuzzyRegion; import com.boydti.fawe.object.regions.FuzzyRegion;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.ExtentTraverser; import com.boydti.fawe.util.ExtentTraverser;
@ -88,13 +88,13 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele
@Override @Override
public void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position) { public void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position) {
int size = this.region.getArea(); int size = this.region.getArea();
player.print(TranslatableComponent.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getArea() + ")")); player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos1", position, "(" + region.getArea() + ")"));
} }
@Override @Override
public void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position) { public void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position) {
int size = this.region.getArea(); int size = this.region.getArea();
player.print(TranslatableComponent.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getArea() + ")")); player.print(Caption.of("fawe.worldedit.selector.selector.fuzzy.pos2", position, "(" + region.getArea() + ")"));
} }
@Override @Override

View File

@ -20,7 +20,7 @@
package com.sk89q.worldedit; package com.sk89q.worldedit;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
@ -138,7 +138,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -685,7 +684,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
} }
} }
player.print(TranslatableComponent.of("fawe.error.worldedit.some.fails.blockbag", str.toString())); player.print(Caption.of("fawe.error.worldedit.some.fails.blockbag", str.toString()));
} }
} }
return Collections.emptyMap(); return Collections.emptyMap();
@ -1005,7 +1004,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
FaweLimit used = getLimitUsed(); FaweLimit used = getLimitUsed();
if (used.MAX_FAILS > 0) { if (used.MAX_FAILS > 0) {
if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) { if (used.MAX_CHANGES > 0 || used.MAX_ENTITIES > 0) {
player.print(TranslatableComponent.of("fawe.error.worldedit.some.fails", used.MAX_FAILS)); player.print(Caption.of("fawe.error.worldedit.some.fails", used.MAX_FAILS));
} else if (new ExtentTraverser<>(getExtent()).findAndGet(FaweRegionExtent.class) != null){ } else if (new ExtentTraverser<>(getExtent()).findAndGet(FaweRegionExtent.class) != null){
player.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region")); player.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.outside.region"));
} else { } else {

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
@ -270,7 +271,7 @@ public class BrushCommands {
@Arg(desc = "The radius to sample for blending", def = "25") @Arg(desc = "The radius to sample for blending", def = "25")
Expression radius) throws WorldEditException { Expression radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline", (radius))); player.print(Caption.of("fawe.worldedit.brush.brush.spline", (radius)));
set(context, set(context,
new SplineBrush(player)) new SplineBrush(player))
.setSize(radius) .setSize(radius)
@ -331,7 +332,7 @@ public class BrushCommands {
@Arg(desc = "double", def = "0") double bias, @Arg(desc = "double", def = "0") double bias,
@Arg(desc = "double", def = "0") double continuity, @Arg(desc = "double", def = "0") double continuity,
@Arg(desc = "double", def = "10") double quality) throws WorldEditException { @Arg(desc = "double", def = "10") double quality) throws WorldEditException {
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.spline", (radius))); player.print(Caption.of("fawe.worldedit.brush.brush.spline", (radius)));
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
set(context, set(context,
new SurfaceSpline(tension, bias, continuity, quality)) new SurfaceSpline(tension, bias, continuity, quality))
@ -537,12 +538,12 @@ public class BrushCommands {
try { try {
MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true); MultiClipboardHolder clipboards = ClipboardFormats.loadAllFromInput(player, clipboardStr, null, true);
if (clipboards == null) { if (clipboards == null) {
player.print(TranslatableComponent.of("fawe.error.schematic.not.found" , clipboardStr)); player.print(Caption.of("fawe.error.schematic.not.found" , clipboardStr));
return; return;
} }
List<ClipboardHolder> holders = clipboards.getHolders(); List<ClipboardHolder> holders = clipboards.getHolders();
if (holders == null) { if (holders == null) {
player.print(TranslatableComponent.of("fawe.error.schematic.not.found" , clipboardStr)); player.print(Caption.of("fawe.error.schematic.not.found" , clipboardStr));
return; return;
} }
@ -843,7 +844,7 @@ public class BrushCommands {
@Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name = 'r', desc = "Apply random rotation on paste") boolean randomRotate,
@Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate) throws WorldEditException { @Switch(name = 'a', desc = "Apply auto view based rotation on paste") boolean autoRotate) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.copy", (radius))); player.print(Caption.of("fawe.worldedit.brush.brush.copy", (radius)));
set(context, set(context,
new CopyPastaBrush(player, session, randomRotate, autoRotate)) new CopyPastaBrush(player, session, randomRotate, autoRotate))
@ -918,7 +919,7 @@ public class BrushCommands {
tool.setPrimary(settings); tool.setPrimary(settings);
tool.setSecondary(settings); tool.setSecondary(settings);
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.equipped" , arguments.get().split(" ")[1])); player.print(Caption.of("fawe.worldedit.brush.brush.equipped" , arguments.get().split(" ")[1]));
} }
return settings; return settings;
} }
@ -981,7 +982,7 @@ public class BrushCommands {
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
} }
player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.saved" , name)); player.print(Caption.of("fawe.worldedit.schematic.schematic.saved" , name));
} else { } else {
player.printError(TranslatableComponent.of("fawe.worldedit.brush.brush.none")); player.printError(TranslatableComponent.of("fawe.worldedit.brush.brush.none"));
} }
@ -1004,7 +1005,7 @@ public class BrushCommands {
} }
if (!file.exists()) { if (!file.exists()) {
File[] files = folder.listFiles(pathname -> false); File[] files = folder.listFiles(pathname -> false);
player.print(TranslatableComponent.of("fawe.error.brush.not.found" , name)); player.print(Caption.of("fawe.error.brush.not.found" , name));
return; return;
} }
try (DataInputStream in = new DataInputStream( try (DataInputStream in = new DataInputStream(
@ -1013,7 +1014,7 @@ public class BrushCommands {
BrushTool tool = BrushTool.fromString(player, session, json); BrushTool tool = BrushTool.fromString(player, session, json);
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND); BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(item, tool, player); session.setTool(item, tool, player);
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.equipped" , name)); player.print(Caption.of("fawe.worldedit.brush.brush.equipped" , name));
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
player.printError(TranslatableComponent.of("fawe.error.brush.incompatible")); player.printError(TranslatableComponent.of("fawe.error.brush.incompatible"));

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import com.boydti.fawe.config.Caption;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
@ -182,7 +183,7 @@ public class ClipboardCommands {
lazyClipboard.setOrigin(session.getPlacementPosition(actor)); lazyClipboard.setOrigin(session.getPlacementPosition(actor));
session.setClipboard(new ClipboardHolder(lazyClipboard)); session.setClipboard(new ClipboardHolder(lazyClipboard));
actor.print(TranslatableComponent.of("fawe.worldedit.copy.command.copy" , region.getArea())); actor.print(Caption.of("fawe.worldedit.copy.command.copy" , region.getArea()));
if (!actor.hasPermission("fawe.tips")) { if (!actor.hasPermission("fawe.tips")) {
System.out.println("TODO FIXME tips"); System.out.println("TODO FIXME tips");
// TranslatableComponent.of("fawe.tips.tip.paste").or(TranslatableComponent.of("fawe.tips.tip.lazycopy"), TranslatableComponent.of("fawe.tips.tip.download"), TranslatableComponent.of("fawe.tips.tip.rotate"), TranslatableComponent.of("fawe.tips.tip.copypaste"), TranslatableComponent.of("fawe.tips.tip.replace.marker"), TranslatableComponent.of("fawe.tips.tip.copy.pattern")).send(actor); // TranslatableComponent.of("fawe.tips.tip.paste").or(TranslatableComponent.of("fawe.tips.tip.lazycopy"), TranslatableComponent.of("fawe.tips.tip.download"), TranslatableComponent.of("fawe.tips.tip.rotate"), TranslatableComponent.of("fawe.tips.tip.copypaste"), TranslatableComponent.of("fawe.tips.tip.replace.marker"), TranslatableComponent.of("fawe.tips.tip.copy.pattern")).send(actor);
@ -287,11 +288,11 @@ public class ClipboardCommands {
public void download(final Player player, final LocalSession session, @Arg(name = "format", desc = "String", def = "schem") final String formatName) throws WorldEditException { public void download(final Player player, final LocalSession session, @Arg(name = "format", desc = "String", def = "schem") final String formatName) throws WorldEditException {
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName); final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
if (format == null) { if (format == null) {
player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.invalid.format" , formatName)); player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format" , formatName));
return; return;
} }
player.print(TranslatableComponent.of("fawe.web.generating.link" , formatName)); player.print(Caption.of("fawe.web.generating.link" , formatName));
ClipboardHolder holder = session.getClipboard(); ClipboardHolder holder = session.getClipboard();
URL url; URL url;
@ -360,7 +361,7 @@ public class ClipboardCommands {
} }
} else { } else {
if (Settings.IMP.WEB.URL.isEmpty()) { if (Settings.IMP.WEB.URL.isEmpty()) {
player.print(TranslatableComponent.of("fawe.error.setting.disable", "web.url")); player.print(Caption.of("fawe.error.setting.disable", "web.url"));
return; return;
} }
url = FaweAPI.upload(target, format); url = FaweAPI.upload(target, format);
@ -377,7 +378,7 @@ public class ClipboardCommands {
e.printStackTrace(); e.printStackTrace();
} }
} }
player.print(TranslatableComponent.of("fawe.web.download.link" , urlText)); player.print(Caption.of("fawe.web.download.link" , urlText));
} }
} }
@ -401,16 +402,16 @@ public class ClipboardCommands {
} else { } else {
target = clipboard; target = clipboard;
} }
player.print(TranslatableComponent.of("fawe.web.generating.link" , format.getName())); player.print(Caption.of("fawe.web.generating.link" , format.getName()));
if (Settings.IMP.WEB.ASSETS.isEmpty()) { if (Settings.IMP.WEB.ASSETS.isEmpty()) {
player.print(TranslatableComponent.of("fawe.error.setting.disable", "web.assets")); player.print(Caption.of("fawe.error.setting.disable", "web.assets"));
return; return;
} }
URL url = format.uploadPublic(target, category.replaceAll("[/|\\\\]", "."), player.getName()); URL url = format.uploadPublic(target, category.replaceAll("[/|\\\\]", "."), player.getName());
if (url == null) { if (url == null) {
player.printError(TranslatableComponent.of("fawe.web.generating.link.failed")); player.printError(TranslatableComponent.of("fawe.web.generating.link.failed"));
} else { } else {
player.print(TranslatableComponent.of("fawe.web.download.link" , Settings.IMP.WEB.ASSETS)); player.print(Caption.of("fawe.web.download.link" , Settings.IMP.WEB.ASSETS));
} }
} }
@ -528,7 +529,7 @@ public class ClipboardCommands {
selector.learnChanges(); selector.learnChanges();
selector.explainRegionAdjust(actor, session); selector.explainRegionAdjust(actor, session);
} }
actor.print(TranslatableComponent.of("fawe.worldedit.paste.command.paste" , to)); actor.print(Caption.of("fawe.worldedit.paste.command.paste" , to));
if (!actor.hasPermission("fawe.tips")) { if (!actor.hasPermission("fawe.tips")) {
actor.print(TranslatableComponent.of("fawe.tips.tip.copypaste")); actor.print(TranslatableComponent.of("fawe.tips.tip.copypaste"));

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.extent.ResettableExtent; import com.boydti.fawe.object.extent.ResettableExtent;
import com.boydti.fawe.util.CachedTextureUtil; import com.boydti.fawe.util.CachedTextureUtil;
@ -398,7 +399,7 @@ public class GeneralCommands {
} }
if (!(util instanceof CachedTextureUtil)) util = new CachedTextureUtil(util); if (!(util instanceof CachedTextureUtil)) util = new CachedTextureUtil(util);
session.setTextureUtil(util); session.setTextureUtil(util);
player.print(TranslatableComponent.of("fawe.worldedit.general.texture.set" , StringMan.join(arguments, " "))); player.print(Caption.of("fawe.worldedit.general.texture.set" , StringMan.join(arguments, " ")));
} }
} }

View File

@ -24,6 +24,7 @@ import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument; import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
@ -109,7 +110,7 @@ public class GenerationCommands {
@Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt) throws WorldEditException { @Arg(name = "pocketMax", desc = "TODO", def = "3") int pocketMaxOpt) throws WorldEditException {
CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt); CavesGen gen = new CavesGen(sizeOpt, frequencyOpt, rarityOpt, minYOpt, maxYOpt, systemFrequencyOpt, individualRarityOpt, pocketChanceOpt, pocketMinOpt, pocketMaxOpt);
editSession.generate(region, gen); editSession.generate(region, gen);
actor.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount())); actor.print(Caption.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
} }
@ -122,7 +123,7 @@ public class GenerationCommands {
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException { public void ores(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask) throws WorldEditException {
editSession.addOres(region, mask); editSession.addOres(region, mask);
actor.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount())); actor.print(Caption.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
} }
@Command( @Command(
@ -164,7 +165,7 @@ public class GenerationCommands {
return false; return false;
}); });
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
actor.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount())); actor.print(Caption.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
} }
@Command( @Command(
@ -176,7 +177,7 @@ public class GenerationCommands {
@Confirm(Confirm.Processor.REGION) @Confirm(Confirm.Processor.REGION)
public void ore(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern") Pattern material, @Arg(desc="Ore vein size") @Range(from = 0, to=Integer.MAX_VALUE) int size, int freq, @Range(from=0, to=100) int rarity, @Range(from=0, to=255) int minY, @Range(from=0, to=255) int maxY) throws WorldEditException { public void ore(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Mask") Mask mask, @Arg(desc = "Pattern") Pattern material, @Arg(desc="Ore vein size") @Range(from = 0, to=Integer.MAX_VALUE) int size, int freq, @Range(from=0, to=100) int rarity, @Range(from=0, to=255) int minY, @Range(from=0, to=255) int maxY) throws WorldEditException {
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY); editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
actor.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount())); actor.print(Caption.of("fawe.worldedit.visitor.visitor.block" , editSession.getBlockChangeCount()));
} }
@Command( @Command(

View File

@ -2,6 +2,7 @@ package com.sk89q.worldedit.command;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.Caption;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.database.DBHandler; import com.boydti.fawe.database.DBHandler;
import com.boydti.fawe.database.RollbackDatabase; import com.boydti.fawe.database.RollbackDatabase;
@ -9,9 +10,7 @@ import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Suppliers;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -21,15 +20,10 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.annotation.Confirm; import com.sk89q.worldedit.command.util.annotation.Confirm;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.internal.annotation.AllowedRegion; import com.sk89q.worldedit.internal.annotation.AllowedRegion;
import com.sk89q.worldedit.internal.annotation.Time; import com.sk89q.worldedit.internal.annotation.Time;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
@ -54,13 +48,10 @@ import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.lang.ref.Reference; import java.lang.ref.Reference;
import java.lang.ref.SoftReference; import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.atomic.LongAdder;
import java.util.function.Supplier; import java.util.function.Supplier;
@ -109,7 +100,7 @@ public class HistorySubCommands {
@ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0") @Time long timeDiff, @ArgFlag(name = 't', desc = "Time e.g. 20s", def = "0") @Time long timeDiff,
@Switch(name = 'f', desc = "Restore instead of rollback") boolean restore) throws WorldEditException { @Switch(name = 'f', desc = "Restore instead of rollback") boolean restore) throws WorldEditException {
if (!Settings.IMP.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
player.print(TranslatableComponent.of("fawe.error.setting.disable" , "history.use-database (Import with /history import )")); player.print(Caption.of("fawe.error.setting.disable" , "history.use-database (Import with /history import )"));
return; return;
} }
checkCommandArgument(radius > 0, "Radius must be >= 0"); checkCommandArgument(radius > 0, "Radius must be >= 0");
@ -140,9 +131,9 @@ public class HistorySubCommands {
RollbackOptimizedHistory edit = supplier.get(); RollbackOptimizedHistory edit = supplier.get();
edit.undo(player, allowedRegions); edit.undo(player, allowedRegions);
String path = edit.getWorld().getName() + "/" + finalOther + "-" + edit.getIndex(); String path = edit.getWorld().getName() + "/" + finalOther + "-" + edit.getIndex();
player.print(TranslatableComponent.of("fawe.worldedit.rollback.rollback.element", path)); player.print(Caption.of("fawe.worldedit.rollback.rollback.element", path));
} }
player.print(TranslatableComponent.of("fawe.worldedit.tool.tool.inspect.info.footer" , count)); player.print(Caption.of("fawe.worldedit.tool.tool.inspect.info.footer" , count));
} }
@Command( @Command(
@ -292,7 +283,7 @@ public class HistorySubCommands {
@Time long timeDiff, @Time long timeDiff,
@ArgFlag(name = 'p', desc = "Page to view.", def = "1") int page) throws WorldEditException { @ArgFlag(name = 'p', desc = "Page to view.", def = "1") int page) throws WorldEditException {
if (!Settings.IMP.HISTORY.USE_DATABASE) { if (!Settings.IMP.HISTORY.USE_DATABASE) {
player.print(TranslatableComponent.of("fawe.error.setting.disable" , "history.use-database (Import with //history import )")); player.print(Caption.of("fawe.error.setting.disable" , "history.use-database (Import with //history import )"));
return; return;
} }
checkCommandArgument(radius > 0, "Radius must be >= 0"); checkCommandArgument(radius > 0, "Radius must be >= 0");
@ -355,10 +346,10 @@ public class HistorySubCommands {
int size = edit.size(); int size = edit.size();
TranslatableComponent elem = TranslatableComponent.of("fawe.worldedit.history.find.element", name, timeStr, distance, direction.name(), cmd); TranslatableComponent elem = Caption.of("fawe.worldedit.history.find.element", name, timeStr, distance, direction.name(), cmd);
String infoCmd = "//history summary " + uuid + " " + index; String infoCmd = "//history summary " + uuid + " " + index;
TranslatableComponent hover = TranslatableComponent.of("fawe.worldedit.history.find.hover", size); TranslatableComponent hover = Caption.of("fawe.worldedit.history.find.hover", size);
elem = elem.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, hover)); elem = elem.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, hover));
elem = elem.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, infoCmd)); elem = elem.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, infoCmd));

View File

@ -29,6 +29,7 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.Caption;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
@ -153,7 +154,7 @@ public class RegionCommands {
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
} }
int count = FaweAPI.fixLighting(player.getWorld(), selection,null); int count = FaweAPI.fixLighting(player.getWorld(), selection,null);
player.print(TranslatableComponent.of("fawe.info.lighting.propagate.selection" , count)); player.print(Caption.of("fawe.info.lighting.propagate.selection" , count));
} }
@Command( @Command(
@ -181,7 +182,7 @@ public class RegionCommands {
selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16)); selection = new CuboidRegion(BlockVector3.at(cx - 8, 0, cz - 8).multiply(16), BlockVector3.at(cx + 8, 0, cz + 8).multiply(16));
} }
int count = FaweAPI.fixLighting(player.getWorld(), selection, null); int count = FaweAPI.fixLighting(player.getWorld(), selection, null);
player.print(TranslatableComponent.of("fawe.info.updated.lighting.selection" , count)); player.print(Caption.of("fawe.info.updated.lighting.selection" , count));
} }
@Command( @Command(
@ -338,7 +339,7 @@ public class RegionCommands {
editSession.setBlock(x, y, z, patternArg); editSession.setBlock(x, y, z, patternArg);
affected++; affected++;
} }
player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , affected)); player.print(Caption.of("fawe.worldedit.visitor.visitor.block" , affected));
} }
@Command( @Command(
@ -532,7 +533,7 @@ public class RegionCommands {
@Arg(desc = "BlockStateHolder", def = "air") BlockStateHolder replace, @Arg(desc = "BlockStateHolder", def = "air") BlockStateHolder replace,
@Switch(name = 'm', desc = "TODO") boolean notFullHeight) throws WorldEditException { @Switch(name = 'm', desc = "TODO") boolean notFullHeight) throws WorldEditException {
int affected = editSession.fall(region, !notFullHeight, replace); int affected = editSession.fall(region, !notFullHeight, replace);
player.print(TranslatableComponent.of("fawe.worldedit.visitor.visitor.block" , affected)); player.print(Caption.of("fawe.worldedit.visitor.visitor.block" , affected));
} }
@Command( @Command(

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import static com.boydti.fawe.util.ReflectionUtils.as; import static com.boydti.fawe.util.ReflectionUtils.as;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
@ -131,14 +132,14 @@ public class SchematicCommands {
boolean randomRotate) throws FilenameException { boolean randomRotate) throws FilenameException {
final ClipboardFormat format = ClipboardFormats.findByAlias(formatName); final ClipboardFormat format = ClipboardFormats.findByAlias(formatName);
if (format == null) { if (format == null) {
player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.invalid.format" , formatName)); player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format" , formatName));
return; return;
} }
try { try {
MultiClipboardHolder all = ClipboardFormats.loadAllFromInput(player, filename, null, true); MultiClipboardHolder all = ClipboardFormats.loadAllFromInput(player, filename, null, true);
if (all != null) { if (all != null) {
session.addClipboard(all); session.addClipboard(all);
player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.loaded" , filename)); player.print(Caption.of("fawe.worldedit.schematic.schematic.loaded" , filename));
} }
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -186,7 +187,7 @@ public class SchematicCommands {
return; return;
} }
} }
player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.uri.not.found" , fileName)); player.print(Caption.of("fawe.worldedit.clipboard.clipboard.uri.not.found" , fileName));
} }
@Command( @Command(
@ -222,7 +223,7 @@ public class SchematicCommands {
URI uri; URI uri;
if (filename.startsWith("url:")) { if (filename.startsWith("url:")) {
if (!actor.hasPermission("worldedit.schematic.load.web")) { if (!actor.hasPermission("worldedit.schematic.load.web")) {
actor.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.web")); actor.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.web"));
return; return;
} }
UUID uuid = UUID.fromString(filename.substring(4)); UUID uuid = UUID.fromString(filename.substring(4));
@ -249,7 +250,7 @@ public class SchematicCommands {
} }
} else { } else {
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !actor.hasPermission("worldedit.schematic.load.other") && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(filename).find()) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !actor.hasPermission("worldedit.schematic.load.other") && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(filename).find()) {
actor.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.other")); actor.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.other"));
return; return;
} }
if (format == null && filename.matches(".*\\.[\\w].*")) { if (format == null && filename.matches(".*\\.[\\w].*")) {
@ -279,7 +280,7 @@ public class SchematicCommands {
uri = file.toURI(); uri = file.toURI();
} }
format.hold(actor, uri, in); format.hold(actor, uri, in);
actor.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.loaded" , filename)); actor.print(Caption.of("fawe.worldedit.schematic.schematic.loaded" , filename));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
actor.printError("Unknown filename: " + filename); actor.printError("Unknown filename: " + filename);
} catch (URISyntaxException | IOException e) { } catch (URISyntaxException | IOException e) {
@ -328,7 +329,7 @@ public class SchematicCommands {
if (filename.contains("../")) { if (filename.contains("../")) {
other = true; other = true;
if (!actor.hasPermission("worldedit.schematic.save.other")) { if (!actor.hasPermission("worldedit.schematic.save.other")) {
actor.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.save.other")); actor.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.save.other"));
return; return;
} }
if (filename.startsWith("../")) { if (filename.startsWith("../")) {
@ -346,7 +347,7 @@ public class SchematicCommands {
} }
if (other) { if (other) {
if (!actor.hasPermission("worldedit.schematic.delete.other")) { if (!actor.hasPermission("worldedit.schematic.delete.other")) {
actor.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.delete.other")); actor.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.delete.other"));
return; return;
} }
} }
@ -392,7 +393,7 @@ public class SchematicCommands {
return; return;
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, destDir) && !player.hasPermission("worldedit.schematic.move.other")) {
player.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.move.other")); player.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.move.other"));
return; return;
} }
ClipboardHolder clipboard = session.getClipboard(); ClipboardHolder clipboard = session.getClipboard();
@ -408,19 +409,19 @@ public class SchematicCommands {
for (File source : sources) { for (File source : sources) {
File destFile = new File(destDir, source.getName()); File destFile = new File(destDir, source.getName());
if (destFile.exists()) { if (destFile.exists()) {
player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.move.exists" , destFile)); player.print(Caption.of("fawe.worldedit.schematic.schematic.move.exists" , destFile));
continue; continue;
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(dir, destFile) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && (!MainUtil.isInSubDirectory(dir, destFile) || !MainUtil.isInSubDirectory(dir, source)) && !player.hasPermission("worldedit.schematic.delete.other")) {
player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.move.failed", destFile, player.print(Caption.of("fawe.worldedit.schematic.schematic.move.failed", destFile,
TranslatableComponent.of("fawe.error.no.perm", ("worldedit.schematic.move.other")))); Caption.of("fawe.error.no.perm", ("worldedit.schematic.move.other"))));
continue; continue;
} }
try { try {
File cached = new File(source.getParentFile(), "." + source.getName() + ".cached"); File cached = new File(source.getParentFile(), "." + source.getName() + ".cached");
Files.move(source.toPath(), destFile.toPath()); Files.move(source.toPath(), destFile.toPath());
if (cached.exists()) Files.move(cached.toPath(), destFile.toPath()); if (cached.exists()) Files.move(cached.toPath(), destFile.toPath());
player.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.move.success" , source, destFile)); player.print(Caption.of("fawe.worldedit.schematic.schematic.move.success" , source, destFile));
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -712,7 +713,7 @@ public class SchematicCommands {
writer.write(target); writer.write(target);
} }
log.info(actor.getName() + " saved " + file.getCanonicalPath()); log.info(actor.getName() + " saved " + file.getCanonicalPath());
actor.print(TranslatableComponent.of("fawe.worldedit.schematic.schematic.saved" , file.getName())); actor.print(Caption.of("fawe.worldedit.schematic.schematic.saved" , file.getName()));
} else { } else {
actor.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual")); actor.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.manual"));
} }
@ -828,14 +829,14 @@ public class SchematicCommands {
continue; continue;
} }
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission("worldedit.schematic.delete.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && !MainUtil.isInSubDirectory(dir, f) && !actor.hasPermission("worldedit.schematic.delete.other")) {
actor.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.delete.other")); actor.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.delete.other"));
continue; continue;
} }
if (!deleteFile(f)) { if (!deleteFile(f)) {
actor.printError(TranslatableComponent.of("worldedit.schematic.delete.failed", TextComponent.of(filename))); actor.printError(TranslatableComponent.of("worldedit.schematic.delete.failed", TextComponent.of(filename)));
continue; continue;
} }
actor.print(TranslatableComponent.of("worldedit.schematic.delete.deleted" , filename)); actor.print(Caption.of("worldedit.schematic.delete.deleted" , filename));
} }
} }

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import com.boydti.fawe.config.Caption;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION; import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
@ -683,7 +684,7 @@ public class SelectionCommands {
newSelector = new PolyhedralRegionSelector(world); newSelector = new PolyhedralRegionSelector(world);
actor.print(TranslatableComponent.of("fawe.selection.sel.convex.polyhedral")); actor.print(TranslatableComponent.of("fawe.selection.sel.convex.polyhedral"));
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit(); Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
limit.ifPresent(integer -> actor.print(TranslatableComponent.of("fawe.selection.sel.max", (integer)))); limit.ifPresent(integer -> actor.print(Caption.of("fawe.selection.sel.max", (integer))));
actor.print(TranslatableComponent.of("fawe.selection.sel.list")); actor.print(TranslatableComponent.of("fawe.selection.sel.list"));
break; break;
case FUZZY: case FUZZY:

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.command; package com.sk89q.worldedit.command;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.BrushSettings; import com.boydti.fawe.object.brush.BrushSettings;
import com.boydti.fawe.object.brush.TargetMode; import com.boydti.fawe.object.brush.TargetMode;
@ -263,7 +264,7 @@ public class ToolUtilCommands {
VisualMode[] modes = VisualMode.values(); VisualMode[] modes = VisualMode.values();
VisualMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)]; VisualMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
tool.setVisualMode(player, newMode); tool.setVisualMode(player, newMode);
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.visual.mode.set" , newMode)); player.print(Caption.of("fawe.worldedit.brush.brush.visual.mode.set" , newMode));
} }
@Command( @Command(
@ -282,7 +283,7 @@ public class ToolUtilCommands {
TargetMode[] modes = TargetMode.values(); TargetMode[] modes = TargetMode.values();
TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)]; TargetMode newMode = modes[MathMan.wrap(mode, 0, modes.length - 1)];
tool.setTargetMode(newMode); tool.setTargetMode(newMode);
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.target.mode.set" , newMode)); player.print(Caption.of("fawe.worldedit.brush.brush.target.mode.set" , newMode));
} }
@Command( @Command(
@ -299,7 +300,7 @@ public class ToolUtilCommands {
return; return;
} }
tool.setTargetOffset(offset); tool.setTargetOffset(offset);
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.target.offset.set" , offset)); player.print(Caption.of("fawe.worldedit.brush.brush.target.offset.set" , offset));
} }
@Command( @Command(
@ -328,7 +329,7 @@ public class ToolUtilCommands {
} else if (action != null) { } else if (action != null) {
String full = (mode.name().toLowerCase() + " " + StringMan.join(commandStr, " ")).trim(); String full = (mode.name().toLowerCase() + " " + StringMan.join(commandStr, " ")).trim();
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full); settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full);
player.print(TranslatableComponent.of("fawe.worldedit.brush.brush.scroll.action.set" , mode)); player.print(Caption.of("fawe.worldedit.brush.brush.scroll.action.set" , mode));
} }
bt.update(); bt.update();
} }

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT; import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.DelegateConsumer; import com.boydti.fawe.object.DelegateConsumer;
@ -188,7 +189,7 @@ public class UtilityCommands {
@SkipQueue @SkipQueue
public void cancel(Player player) { public void cancel(Player player) {
int cancelled = player.cancel(false); int cancelled = player.cancel(false);
player.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.count" , cancelled)); player.print(Caption.of("fawe.cancel.worldedit.cancel.count" , cancelled));
} }
@Command( @Command(

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.command.tool; package com.sk89q.worldedit.command.tool;
import static com.boydti.fawe.object.brush.BrushSettings.SettingType.BRUSH;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger; import static org.slf4j.LoggerFactory.getLogger;
@ -27,6 +26,7 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.beta.implementation.IChunkExtent; import com.boydti.fawe.beta.implementation.IChunkExtent;
import com.boydti.fawe.beta.implementation.processors.NullProcessor; import com.boydti.fawe.beta.implementation.processors.NullProcessor;
import com.boydti.fawe.beta.implementation.processors.PersistentChunkSendProcessor; import com.boydti.fawe.beta.implementation.processors.PersistentChunkSendProcessor;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.object.brush.BrushSettings; import com.boydti.fawe.object.brush.BrushSettings;
import com.boydti.fawe.object.brush.MovableTool; import com.boydti.fawe.object.brush.MovableTool;
@ -79,8 +79,6 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier; import java.util.function.Supplier;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -493,7 +491,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
if (brush == null) return false; if (brush == null) return false;
if (current.setWorld(player.getWorld().getName()) && !current.canUse(player)) { if (current.setWorld(player.getWorld().getName()) && !current.canUse(player)) {
player.print(TranslatableComponent.of("fawe.error.no.perm" , StringMan.join(current.getPermissions(), ","))); player.print(Caption.of("fawe.error.no.perm" , StringMan.join(current.getPermissions(), ",")));
return false; return false;
} }
try (EditSession editSession = session.createEditSession(player, current.toString())) { try (EditSession editSession = session.createEditSession(player, current.toString())) {

View File

@ -1,5 +1,6 @@
package com.sk89q.worldedit.command.util.annotation; package com.sk89q.worldedit.command.util.annotation;
import com.boydti.fawe.config.Caption;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.util.task.InterruptableCondition; import com.boydti.fawe.util.task.InterruptableCondition;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
@ -47,7 +48,7 @@ public @interface Confirm {
long area = (pos2.getX() - pos1.getX()) * (pos2.getZ() - pos1.getZ() + 1) * (long) value; long area = (pos2.getX() - pos1.getX()) * (pos2.getZ() - pos1.getZ() + 1) * (long) value;
long max = 2 << 18; long max = 2 << 18;
if (max != -1 && area > max) { if (max != -1 && area > max) {
actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , pos1, pos2, getArgs(context))); actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , pos1, pos2, getArgs(context)));
return confirm(actor, context); return confirm(actor, context);
} }
return true; return true;
@ -58,7 +59,7 @@ public @interface Confirm {
public boolean passes(Actor actor, InjectedValueAccess context, double value) { public boolean passes(Actor actor, InjectedValueAccess context, double value) {
int max = WorldEdit.getInstance().getConfiguration().maxRadius; int max = WorldEdit.getInstance().getConfiguration().maxRadius;
if (max != -1 && value > max) { if (max != -1 && value > max) {
actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context))); actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context)));
return Processor.confirm(actor, context); return Processor.confirm(actor, context);
} }
return true; return true;
@ -69,7 +70,7 @@ public @interface Confirm {
public boolean passes(Actor actor, InjectedValueAccess context, double value) { public boolean passes(Actor actor, InjectedValueAccess context, double value) {
int max = 50;// TODO configurable, get Key.of(Method.class) @Limit int max = 50;// TODO configurable, get Key.of(Method.class) @Limit
if (max != -1 && value > max) { if (max != -1 && value > max) {
actor.print(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context))); actor.print(Caption.of("fawe.cancel.worldedit.cancel.reason.confirm.region" , value, max, getArgs(context)));
return Processor.confirm(actor, context); return Processor.confirm(actor, context);
} }
return true; return true;

View File

@ -22,8 +22,6 @@ package com.sk89q.worldedit.extension.factory.parser;
import com.boydti.fawe.config.Caption; import com.boydti.fawe.config.Caption;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.sk89q.worldedit.util.formatting.WorldEditText;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.boydti.fawe.jnbt.JSON2NBT; import com.boydti.fawe.jnbt.JSON2NBT;
import com.boydti.fawe.jnbt.NBTException; import com.boydti.fawe.jnbt.NBTException;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
@ -423,7 +421,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (context.isRestricted()) { if (context.isRestricted()) {
Actor actor = context.requireActor(); Actor actor = context.requireActor();
if (!actor.hasPermission("worldedit.anyblock") && worldEdit.getConfiguration().checkDisallowedBlocks(holder)) { if (!actor.hasPermission("worldedit.anyblock") && worldEdit.getConfiguration().checkDisallowedBlocks(holder)) {
throw new DisallowedUsageException(Caption.toString(TranslatableComponent.of("fawe.error.block.not.allowed", holder))); throw new DisallowedUsageException(Caption.toString(Caption.of("fawe.error.block.not.allowed", holder)));
} }
CompoundTag nbt = holder.getNbtData(); CompoundTag nbt = holder.getNbtData();
if (nbt != null) { if (nbt != null) {

View File

@ -21,7 +21,7 @@ package com.sk89q.worldedit.extension.factory.parser.mask;
import com.boydti.fawe.command.FaweParser; import com.boydti.fawe.command.FaweParser;
import com.boydti.fawe.command.SuggestInputParseException; import com.boydti.fawe.command.SuggestInputParseException;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Caption;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.sk89q.minecraft.util.commands.CommandLocals; import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -145,7 +145,7 @@ public class DefaultMaskParser extends FaweParser<Mask> {
input = input.substring(input.indexOf(char0) + 1); input = input.substring(input.indexOf(char0) + 1);
mask = parseFromInput(char0 + "[" + input + "]", context); mask = parseFromInput(char0 + "[" + input + "]", context);
if (actor != null) { if (actor != null) {
actor.print(TranslatableComponent.of("fawe.worldedit.help.command.clarifying.bracket" , char0 + "[" + input + "]")); actor.print(Caption.of("fawe.worldedit.help.command.clarifying.bracket" , char0 + "[" + input + "]"));
} }
return mask; return mask;
} }

View File

@ -619,7 +619,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override @Override
public void checkPermission(String permission) throws AuthorizationException { public void checkPermission(String permission) throws AuthorizationException {
if (!hasPermission(permission)) { if (!hasPermission(permission)) {
throw new AuthorizationException(Caption.toString(TranslatableComponent.of("fawe.error.no.perm", permission))); throw new AuthorizationException(Caption.toString(Caption.of("fawe.error.no.perm", permission)));
} }
} }

View File

@ -24,6 +24,7 @@ import com.boydti.fawe.command.AnvilCommands;
import com.boydti.fawe.command.AnvilCommandsRegistration; import com.boydti.fawe.command.AnvilCommandsRegistration;
import com.boydti.fawe.command.CFICommands; import com.boydti.fawe.command.CFICommands;
import com.boydti.fawe.command.CFICommandsRegistration; import com.boydti.fawe.command.CFICommandsRegistration;
import com.boydti.fawe.config.Caption;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.sk89q.worldedit.command.HistorySubCommands; import com.sk89q.worldedit.command.HistorySubCommands;
import com.sk89q.worldedit.command.HistorySubCommandsRegistration; import com.sk89q.worldedit.command.HistorySubCommandsRegistration;
@ -34,7 +35,6 @@ import com.boydti.fawe.object.changeset.CFIChangeSet;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.task.ThrowableSupplier; import com.boydti.fawe.object.task.ThrowableSupplier;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -106,7 +106,6 @@ import com.sk89q.worldedit.command.argument.RegistryConverter;
import com.sk89q.worldedit.command.argument.VectorConverter; import com.sk89q.worldedit.command.argument.VectorConverter;
import com.sk89q.worldedit.command.argument.WorldConverter; import com.sk89q.worldedit.command.argument.WorldConverter;
import com.sk89q.worldedit.command.argument.ZonedDateTimeConverter; import com.sk89q.worldedit.command.argument.ZonedDateTimeConverter;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandQueuedCondition; import com.sk89q.worldedit.command.util.CommandQueuedCondition;
import com.sk89q.worldedit.command.util.PermissionCondition; import com.sk89q.worldedit.command.util.PermissionCondition;
import com.sk89q.worldedit.command.util.PrintCommandHelp; import com.sk89q.worldedit.command.util.PrintCommandHelp;
@ -133,7 +132,6 @@ import com.sk89q.worldedit.internal.util.Substring;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.session.SessionKey;
import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.auth.AuthorizationException;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
@ -168,14 +166,11 @@ import org.slf4j.LoggerFactory;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.logging.FileHandler; import java.util.logging.FileHandler;
@ -704,7 +699,7 @@ public final class PlatformCommandManager {
} }
} catch (ConditionFailedException e) { } catch (ConditionFailedException e) {
if (e.getCondition() instanceof PermissionCondition) { if (e.getCondition() instanceof PermissionCondition) {
actor.printError(TranslatableComponent.of("fawe.error.no.perm", StringMan.getString(((PermissionCondition) e.getCondition()).getPermissions()))); actor.printError(Caption.of("fawe.error.no.perm", StringMan.getString(((PermissionCondition) e.getCondition()).getPermissions())));
} else { } else {
actor.print(e.getRichMessage()); actor.print(e.getRichMessage());
} }

View File

@ -24,8 +24,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Identifiable; import com.sk89q.worldedit.util.Identifiable;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
@ -35,11 +33,7 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.registry.BiomeRegistry; import com.sk89q.worldedit.world.registry.BiomeRegistry;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.converter.ConversionResult;
import org.enginehub.piston.exception.StopExecutionException;
import org.enginehub.piston.inject.InjectedValueAccess; import org.enginehub.piston.inject.InjectedValueAccess;
import org.enginehub.piston.inject.Key;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
@ -129,7 +123,7 @@ public class ConsumeBindings extends Bindings {
uuid = Fawe.imp().getUUID(argument); uuid = Fawe.imp().getUUID(argument);
} }
if (uuid == null) { if (uuid == null) {
throw new InputParseException(Caption.toString(TranslatableComponent.of("fawe.error.player.not.found" , argument))); throw new InputParseException(Caption.toString(Caption.of("fawe.error.player.not.found" , argument)));
} }
return uuid; return uuid;
} }

View File

@ -21,7 +21,7 @@ package com.sk89q.worldedit.extent.clipboard.io;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Caption;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.clipboard.LazyClipboardHolder; import com.boydti.fawe.object.clipboard.LazyClipboardHolder;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder; import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
@ -170,7 +170,7 @@ public class ClipboardFormats {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = worldEdit.getConfiguration();
if (input.startsWith("url:")) { if (input.startsWith("url:")) {
if (!player.hasPermission("worldedit.schematic.load.web")) { if (!player.hasPermission("worldedit.schematic.load.web")) {
if (message) player.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.web")); if (message) player.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.web"));
return null; return null;
} }
URL base = new URL(Settings.IMP.WEB.URL); URL base = new URL(Settings.IMP.WEB.URL);
@ -178,19 +178,19 @@ public class ClipboardFormats {
} }
if (input.startsWith("http")) { if (input.startsWith("http")) {
if (!player.hasPermission("worldedit.schematic.load.asset")) { if (!player.hasPermission("worldedit.schematic.load.asset")) {
if (message) player.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.asset")); if (message) player.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.asset"));
return null; return null;
} }
URL url = new URL(input); URL url = new URL(input);
URL webInterface = new URL(Settings.IMP.WEB.ASSETS); URL webInterface = new URL(Settings.IMP.WEB.ASSETS);
if (!url.getHost().equalsIgnoreCase(webInterface.getHost())) { if (!url.getHost().equalsIgnoreCase(webInterface.getHost())) {
if (message) player.print(TranslatableComponent.of("fawe.error.web.unauthorized", url)); if (message) player.print(Caption.of("fawe.error.web.unauthorized", url));
return null; return null;
} }
return loadAllFromUrl(url); return loadAllFromUrl(url);
} else { } else {
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) {
player.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.other")); player.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.other"));
return null; return null;
} }
File working = worldEdit.getWorkingDirectoryFile(config.saveDir); File working = worldEdit.getWorkingDirectoryFile(config.saveDir);
@ -210,7 +210,7 @@ public class ClipboardFormats {
} }
} else { } else {
if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) { if (Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS && Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}").matcher(input).find() && !player.hasPermission("worldedit.schematic.load.other")) {
if (message) player.print(TranslatableComponent.of("fawe.error.no.perm", "worldedit.schematic.load.other")); if (message) player.print(Caption.of("fawe.error.no.perm", "worldedit.schematic.load.other"));
return null; return null;
} }
if (format == null && input.matches(".*\\.[\\w].*")) { if (format == null && input.matches(".*\\.[\\w].*")) {
@ -232,12 +232,12 @@ public class ClipboardFormats {
if (format == null && f.isFile()) { if (format == null && f.isFile()) {
format = findByFile(f); format = findByFile(f);
if (format == null) { if (format == null) {
player.print(TranslatableComponent.of("fawe.worldedit.clipboard.clipboard.invalid.format" , f.getName())); player.print(Caption.of("fawe.worldedit.clipboard.clipboard.invalid.format" , f.getName()));
return null; return null;
} }
} }
if (!f.exists()) { if (!f.exists()) {
if (message) player.print(TranslatableComponent.of("fawe.error.schematic.not.found" , input)); if (message) player.print(Caption.of("fawe.error.schematic.not.found" , input));
return null; return null;
} }
if (!f.isDirectory()) { if (!f.isDirectory()) {
@ -247,7 +247,7 @@ public class ClipboardFormats {
} }
URIClipboardHolder[] clipboards = loadAllFromDirectory(f); URIClipboardHolder[] clipboards = loadAllFromDirectory(f);
if (clipboards.length < 1) { if (clipboards.length < 1) {
if (message) player.print(TranslatableComponent.of("fawe.error.schematic.not.found" , input)); if (message) player.print(Caption.of("fawe.error.schematic.not.found" , input));
return null; return null;
} }
return new MultiClipboardHolder(f.toURI(), clipboards); return new MultiClipboardHolder(f.toURI(), clipboards);

View File

@ -1,141 +0,0 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package com.sk89q.worldedit.util.formatting.text;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponentImpl.BuilderImpl;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.formatting.text.format.TextDecoration;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;
public interface TranslatableComponent extends BuildableComponent<TranslatableComponent, TranslatableComponent.Builder>, ScopedComponent<TranslatableComponent> {
@Nonnull
static TranslatableComponent.Builder builder() {
return new BuilderImpl();
}
@Nonnull
static TranslatableComponent.Builder builder(@Nonnull final String key) {
return builder().key(key);
}
@Nonnull
static TranslatableComponent of(@Nonnull final String key) {
return (TranslatableComponent)builder(key).build();
}
@Nonnull
static TranslatableComponent of(@Nonnull final String key, @Nullable final TextColor color) {
return (TranslatableComponent)((TranslatableComponent.Builder)builder(key).color(color)).build();
}
@Nonnull
static TranslatableComponent of(@Nonnull final String key, @Nullable final TextColor color, @Nonnull final TextDecoration... decorations) {
Set<TextDecoration> activeDecorations = new HashSet(decorations.length);
Collections.addAll(activeDecorations, decorations);
return of(key, color, (Set)activeDecorations);
}
@Nonnull
static TranslatableComponent of(@Nonnull final String key, @Nullable final TextColor color, @Nonnull final Set<TextDecoration> decorations) {
return (TranslatableComponent)((TranslatableComponent.Builder)((TranslatableComponent.Builder)builder(key).color(color)).decorations(decorations, true)).build();
}
@Nonnull
static TranslatableComponent of(@Nonnull final String key, final Component... args) {
return of(key, (TextColor)null, (Component[])args);
}
@Nonnull
static TranslatableComponent of(@Nonnull final String key, @Nullable final TextColor color, final Component... args) {
return of(key, color, Collections.emptySet(), args);
}
@Nonnull
static TranslatableComponent of(@Nonnull final String key, @Nullable final TextColor color, @Nonnull final Set<TextDecoration> decorations, final Component... args) {
return of(key, color, decorations, Arrays.asList(args));
}
@Nonnull
static TranslatableComponent of(@Nonnull final String key, @Nonnull final List<? extends Component> args) {
return of(key, (TextColor)null, (List)args);
}
static TranslatableComponent of(@Nonnull final String key, @Nullable final TextColor color, @Nonnull final List<? extends Component> args) {
return of(key, color, Collections.emptySet(), args);
}
@Nonnull
static TranslatableComponent of(@Nonnull final String key, @Nullable final TextColor color, @Nonnull final Set<TextDecoration> decorations, @Nonnull final List<? extends Component> args) {
return (TranslatableComponent)((TranslatableComponent.Builder)((TranslatableComponent.Builder)builder(key).color(color)).decorations(decorations, true)).args(args).build();
}
@Nonnull
static TranslatableComponent make(@Nonnull final Consumer<? super TranslatableComponent.Builder> consumer) {
TranslatableComponent.Builder builder = builder();
consumer.accept(builder);
return (TranslatableComponent)builder.build();
}
@Nonnull
static TranslatableComponent make(@Nonnull final String key, @Nonnull final Consumer<? super TranslatableComponent.Builder> consumer) {
TranslatableComponent.Builder builder = builder(key);
consumer.accept(builder);
return (TranslatableComponent)builder.build();
}
@Nonnull
static TranslatableComponent make(@Nonnull final String key, @Nonnull final List<? extends Component> args, @Nonnull final Consumer<? super TranslatableComponent.Builder> consumer) {
TranslatableComponent.Builder builder = builder(key).args(args);
consumer.accept(builder);
return (TranslatableComponent)builder.build();
}
@Nonnull
String key();
@Nonnull
TranslatableComponent key(@Nonnull final String key);
@Nonnull
List<Component> args();
@Nonnull
TranslatableComponent args(@Nonnull final List<? extends Component> args);
public interface Builder extends ComponentBuilder<TranslatableComponent, TranslatableComponent.Builder> {
@Nonnull
TranslatableComponent.Builder key(@Nonnull final String key);
@Nonnull
TranslatableComponent.Builder args(final ComponentBuilder... args);
@Nonnull
TranslatableComponent.Builder args(final Component... args);
@Nonnull
TranslatableComponent.Builder args(@Nonnull final List<? extends Component> args);
}
// FAWE added
//TODO REMOVE THIS BECAUSE IT'S SO STUPID!
@Nonnull
public static TranslatableComponent of(@Nonnull final String key, final Object... args) {
List<Component> components = Arrays.stream(args)
.map(arg -> arg instanceof Component ? (Component) arg : TextComponent.of(Objects.toString(arg)))
.collect(Collectors.toList());
return of(key, components);
}
}