From 96b670ad8cfd3ec05ff7e44a76361191396f9e2e Mon Sep 17 00:00:00 2001 From: zml Date: Sun, 13 Feb 2022 19:09:31 -0800 Subject: [PATCH] text-minimessage: Remove unused parsing error consumer --- .../text/minimessage/MiniMessage.java | 12 -------- .../text/minimessage/MiniMessageImpl.java | 28 ++----------------- .../text/minimessage/MiniMessageTest.java | 3 +- 3 files changed, 4 insertions(+), 39 deletions(-) diff --git a/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/MiniMessage.java b/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/MiniMessage.java index 3b925c538..f2e36bc0d 100644 --- a/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/MiniMessage.java +++ b/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/MiniMessage.java @@ -23,7 +23,6 @@ */ package net.kyori.adventure.text.minimessage; -import java.util.List; import java.util.function.Consumer; import java.util.function.UnaryOperator; import net.kyori.adventure.text.Component; @@ -263,17 +262,6 @@ interface Builder extends Buildable.Builder { */ @NotNull Builder debug(final @Nullable Consumer debugOutput); - /** - * If in lenient mode, MiniMessage will output helpful messages. - * - *

This method allows you to change how they should be printed. By default, they will be printed to standard out.

- * - * @param consumer the error message consumer - * @return this builder - * @since 4.10.0 - */ - @NotNull Builder parsingErrorMessageConsumer(final @NotNull Consumer> consumer); - /** * Specify a function that takes the component at the end of the parser process. *

By default, this compacts the resulting component with {@link Component#compact()}.

diff --git a/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/MiniMessageImpl.java b/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/MiniMessageImpl.java index c2fc4806d..50da6402c 100644 --- a/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/MiniMessageImpl.java +++ b/text-minimessage/src/main/java/net/kyori/adventure/text/minimessage/MiniMessageImpl.java @@ -23,7 +23,6 @@ */ package net.kyori.adventure.text.minimessage; -import java.util.List; import java.util.Objects; import java.util.function.Consumer; import java.util.function.UnaryOperator; @@ -41,22 +40,19 @@ * @since 4.10.0 */ final class MiniMessageImpl implements MiniMessage { - static final Consumer> DEFAULT_ERROR_CONSUMER = message -> message.forEach(System.out::println); static final UnaryOperator DEFAULT_COMPACTING_METHOD = Component::compact; - static final MiniMessage INSTANCE = new MiniMessageImpl(TagResolver.standard(), false, null, DEFAULT_ERROR_CONSUMER, DEFAULT_COMPACTING_METHOD); + static final MiniMessage INSTANCE = new MiniMessageImpl(TagResolver.standard(), false, null, DEFAULT_COMPACTING_METHOD); private final boolean strict; private final @Nullable Consumer debugOutput; - private final Consumer> parsingErrorMessageConsumer; private final UnaryOperator postProcessor; final MiniMessageParser parser; - MiniMessageImpl(final @NotNull TagResolver resolver, final boolean strict, final @Nullable Consumer debugOutput, final @NotNull Consumer> parsingErrorMessageConsumer, final @NotNull UnaryOperator postProcessor) { + MiniMessageImpl(final @NotNull TagResolver resolver, final boolean strict, final @Nullable Consumer debugOutput, final @NotNull UnaryOperator postProcessor) { this.parser = new MiniMessageParser(resolver); this.strict = strict; this.debugOutput = debugOutput; - this.parsingErrorMessageConsumer = parsingErrorMessageConsumer; this.postProcessor = postProcessor; } @@ -114,16 +110,6 @@ final class MiniMessageImpl implements MiniMessage { } } - /** - * not public api. - * - * @return huhu. - * @since 4.10.0 - */ - public @NotNull Consumer> parsingErrorMessageConsumer() { - return this.parsingErrorMessageConsumer; - } - @Override public @NotNull Builder toBuilder() { return new BuilderImpl(this); @@ -133,7 +119,6 @@ static final class BuilderImpl implements Builder { private TagResolver tagResolver = TagResolver.standard(); private boolean strict = false; private Consumer debug = null; - private Consumer> parsingErrorMessageConsumer = DEFAULT_ERROR_CONSUMER; private UnaryOperator postProcessor = DEFAULT_COMPACTING_METHOD; BuilderImpl() { @@ -143,7 +128,6 @@ static final class BuilderImpl implements Builder { this.tagResolver = serializer.parser.tagResolver; this.strict = serializer.strict; this.debug = serializer.debugOutput; - this.parsingErrorMessageConsumer = serializer.parsingErrorMessageConsumer; } @Override @@ -173,12 +157,6 @@ static final class BuilderImpl implements Builder { return this; } - @Override - public @NotNull Builder parsingErrorMessageConsumer(final @NotNull Consumer> consumer) { - this.parsingErrorMessageConsumer = requireNonNull(consumer, "consumer"); - return this; - } - @Override public @NotNull Builder postProcessor(final @NotNull UnaryOperator postProcessor) { this.postProcessor = Objects.requireNonNull(postProcessor, "postProcessor"); @@ -187,7 +165,7 @@ static final class BuilderImpl implements Builder { @Override public @NotNull MiniMessage build() { - return new MiniMessageImpl(this.tagResolver, this.strict, this.debug, this.parsingErrorMessageConsumer, this.postProcessor); + return new MiniMessageImpl(this.tagResolver, this.strict, this.debug, this.postProcessor); } } } diff --git a/text-minimessage/src/test/java/net/kyori/adventure/text/minimessage/MiniMessageTest.java b/text-minimessage/src/test/java/net/kyori/adventure/text/minimessage/MiniMessageTest.java index f65af635b..4ed59d53c 100644 --- a/text-minimessage/src/test/java/net/kyori/adventure/text/minimessage/MiniMessageTest.java +++ b/text-minimessage/src/test/java/net/kyori/adventure/text/minimessage/MiniMessageTest.java @@ -25,7 +25,6 @@ import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.function.Predicate; import net.kyori.adventure.text.Component; @@ -280,7 +279,7 @@ void testMissingCloseOfHover() { @Test void testNonEndingComponent() { final String input = " assertEquals(strings, Collections.singletonList("Expected end sometimes after open tag + name, but got name = Token{type=NAME, value=\"red is already created! Try different name! \"} and inners = []"))).build().deserialize(input); + this.assertParsedEquals(Component.text(input), input); } @Test