From 21b6f582e1141e8c6e88ed5b6708770ce74e692b Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 3 Nov 2021 18:33:19 +0000 Subject: [PATCH] Switch some Caption#of to TextComponent#of --- .../extension/factory/parser/mask/RichMaskParser.java | 4 ++-- .../factory/parser/pattern/LinearPatternParser.java | 2 +- .../parser/pattern/RandomFullClipboardPatternParser.java | 2 +- .../factory/parser/pattern/RichPatternParser.java | 4 ++-- .../factory/parser/transform/RichTransformParser.java | 2 +- .../core/extension/platform/binding/ConsumeBindings.java | 2 +- .../java/com/fastasyncworldedit/core/util/WEManager.java | 2 +- .../com/fastasyncworldedit/core/util/image/ImageUtil.java | 8 ++++---- .../extension/factory/parser/DefaultBlockParser.java | 4 +++- .../extension/platform/AbstractNonPlayerActor.java | 3 ++- .../worldedit/extension/platform/AbstractPlayerActor.java | 3 ++- .../worldedit/extension/platform/PlatformManager.java | 4 ++-- worldedit-core/src/main/resources/lang/strings.json | 1 + 13 files changed, 23 insertions(+), 18 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/RichMaskParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/RichMaskParser.java index ae202848f..75bbc6bf1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/RichMaskParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/mask/RichMaskParser.java @@ -213,7 +213,7 @@ public class RichMaskParser extends FaweParser { return result; } catch (Throwable e2) { e2.printStackTrace(); - throw new InputParseException(Caption.of(e2.getMessage())); + throw new InputParseException(TextComponent.of(e2.getMessage())); } }); } @@ -227,7 +227,7 @@ public class RichMaskParser extends FaweParser { throw rethrow; } catch (Throwable e) { e.printStackTrace(); - throw new InputParseException(Caption.of(e.getMessage()), e); + throw new InputParseException(TextComponent.of(e.getMessage()), e); } List maskUnions = new ArrayList<>(); for (List maskList : masks) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/LinearPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/LinearPatternParser.java index 7d7813c4a..32d63cbba 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/LinearPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/LinearPatternParser.java @@ -57,7 +57,7 @@ public class LinearPatternParser extends RichParser { Set patterns = ((RandomPattern) inner).getPatterns(); return new LinearBlockPattern(patterns.toArray(new Pattern[0])); } - throw new InputParseException(Caption.of("Pattern " + inner.getClass().getSimpleName() + throw new InputParseException(TextComponent.of("Pattern " + inner.getClass().getSimpleName() + " cannot be used with " + getPrefix())); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomFullClipboardPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomFullClipboardPatternParser.java index ff5d8471b..44043dc4d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomFullClipboardPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RandomFullClipboardPatternParser.java @@ -94,7 +94,7 @@ public class RandomFullClipboardPatternParser extends RichParser { } return new RandomFullClipboardPattern(clipboards, rotate, flip); } catch (IOException e) { - throw new InputParseException(Caption.of(e.getMessage()), e); + throw new InputParseException(TextComponent.of(e.getMessage()), e); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RichPatternParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RichPatternParser.java index f192cf720..8c93cb0e4 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RichPatternParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/pattern/RichPatternParser.java @@ -175,7 +175,7 @@ public class RichPatternParser extends FaweParser { return result; } catch (Throwable e2) { e2.printStackTrace(); - throw new InputParseException(Caption.of(e2.getMessage())); + throw new InputParseException(TextComponent.of(e2.getMessage())); } }); } @@ -189,7 +189,7 @@ public class RichPatternParser extends FaweParser { throw rethrow; } catch (Throwable e) { e.printStackTrace(); - throw new InputParseException(Caption.of(e.getMessage()), e); + throw new InputParseException(TextComponent.of(e.getMessage()), e); } if (patterns.isEmpty()) { return null; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/transform/RichTransformParser.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/transform/RichTransformParser.java index 8d5a70026..555134c68 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/transform/RichTransformParser.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/factory/parser/transform/RichTransformParser.java @@ -126,7 +126,7 @@ public class RichTransformParser extends FaweParser { } } } catch (Throwable e) { - throw new InputParseException(Caption.of(e.getMessage()), e); + throw new InputParseException(TextComponent.of(e.getMessage()), e); } if (!intersection.isEmpty()) { if (intersection.size() == 1) { diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java index a4395a66a..62e4adaa8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extension/platform/binding/ConsumeBindings.java @@ -168,7 +168,7 @@ public class ConsumeBindings extends Bindings { try { return getWorldEdit().getBlockFactory().parseFromInput(argument, parserContext); } catch (NoMatchException e) { - throw new InputParseException(Caption.of(e.getMessage())); + throw new InputParseException(TextComponent.of(e.getMessage())); } } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java index 1aab4c83f..cbb5695ec 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/WEManager.java @@ -114,7 +114,7 @@ public class WEManager { backupRegions.add(region); } } else { - player.print(Caption.of("Invalid Mask")); + player.print(Caption.of("fawe.error.region-mask-invalid", mask.getClass().getSimpleName())); removed = true; iterator.remove(); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java index ffc0eab2f..ee8ee6251 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/util/image/ImageUtil.java @@ -179,7 +179,7 @@ public class ImageUtil { try { return MainUtil.readImage(getInputStream(uri)); } catch (IOException e) { - throw new InputParseException(Caption.of(e.getMessage())); + throw new InputParseException(TextComponent.of(e.getMessage())); } } @@ -192,7 +192,7 @@ public class ImageUtil { } return new URL(uriStr).openStream(); } catch (IOException e) { - throw new InputParseException(Caption.of(e.getMessage())); + throw new InputParseException(TextComponent.of(e.getMessage())); } } @@ -219,7 +219,7 @@ public class ImageUtil { } throw new InputParseException(Caption.of("fawe.error.invalid-image", TextComponent.of(arg))); } catch (IOException e) { - throw new InputParseException(Caption.of(e.getMessage())); + throw new InputParseException(TextComponent.of(e.getMessage())); } } @@ -253,7 +253,7 @@ public class ImageUtil { } throw new InputParseException(Caption.of("fawe.error.invalid-image", TextComponent.of(arg))); } catch (IOException | URISyntaxException e) { - throw new InputParseException(Caption.of(e.getMessage())); + throw new InputParseException(TextComponent.of(e.getMessage())); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java index 0532227d1..9d6ed43b4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java @@ -495,14 +495,16 @@ public class DefaultBlockParser extends InputParser { throw new NoMatchException(Caption.of("worldedit.error.unknown-block", TextComponent.of(input))); } + //FAWE start if (blockAndExtraData.length > 1 && blockAndExtraData[1].startsWith("{")) { String joined = StringMan.join(Arrays.copyOfRange(blockAndExtraData, 1, blockAndExtraData.length), "|"); try { nbt = JSON2NBT.getTagFromJson(joined); } catch (NBTException e) { - throw new NoMatchException(Caption.of(e.getMessage())); + throw new NoMatchException(TextComponent.of(e.getMessage())); } } + //FAWE end // Check if the item is allowed BlockType blockType = state.getBlockType(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java index 4ede6bdee..1edad0ba1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractNonPlayerActor.java @@ -25,6 +25,7 @@ import com.fastasyncworldedit.core.util.TaskManager; import com.fastasyncworldedit.core.util.task.AsyncNotifyQueue; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.internal.cui.CUIEvent; +import com.sk89q.worldedit.util.formatting.text.TextComponent; import java.io.File; import java.util.Map; @@ -72,7 +73,7 @@ public abstract class AbstractNonPlayerActor implements Actor { throwable = throwable.getCause(); } if (throwable instanceof WorldEditException) { - printError(Caption.of(throwable.getLocalizedMessage())); + printError(TextComponent.of(throwable.getLocalizedMessage())); } else { FaweException fe = FaweException.get(throwable); if (fe != null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index e768f2682..87d137283 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -50,6 +50,7 @@ import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.auth.AuthorizationException; +import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockCategories; @@ -86,7 +87,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { throwable = throwable.getCause(); } if (throwable instanceof WorldEditException) { - printError(Caption.of(throwable.getLocalizedMessage())); + printError(TextComponent.of(throwable.getLocalizedMessage())); } else { FaweException fe = FaweException.get(throwable); if (fe != null) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 4a6dea5ef..406964c24 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -448,7 +448,7 @@ public class PlatformManager { actor.print(Caption.of("fawe.cancel.reason", faweException.getComponent())); } else { actor.print(Caption.of("worldedit.command.error.report")); - actor.print(Caption.of(e.getClass().getName(), TextComponent.of(": "), TextComponent.of(e.getMessage()))); + actor.print(TextComponent.of(e.getClass().getName()+ ": " + e.getMessage())); e.printStackTrace(); } } @@ -502,7 +502,7 @@ public class PlatformManager { player.print(Caption.of("fawe.cancel.reason", faweException.getComponent())); } else { player.print(Caption.of("worldedit.command.error.report")); - player.print(Caption.of(e.getClass().getName() + ": " + e.getMessage())); + player.print(TextComponent.of(e.getClass().getName() + ": " + e.getMessage())); e.printStackTrace(); } //FAWE end diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 54b07c8a6..54c0a9c44 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -129,6 +129,7 @@ "fawe.error.clipboard.on.disk.version.mismatch": "Clipboard version mismatch. Please delete your clipboards folder and restart the server.", "fawe.error.limit.disallowed-block": "Your limit disallows use of block '{0}'", "fawe.error.limit.disallowed-property": "Your limit disallows use of property '{0}'", + "fawe.error.region-mask-invalid": "Invalid region mask: {0}", "fawe.cancel.count": "Cancelled {0} edits.", "fawe.cancel.reason.confirm": "Use //confirm to execute {0}", "fawe.cancel.reason.confirm.region": "Your selection is large ({0} -> {1}, containing {3} blocks). Use //confirm to execute {2}",