Skip to content

Commit

Permalink
text-minimessage: Remove unused parsing error consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Feb 14, 2022
1 parent 33bf939 commit 96b670a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -263,17 +262,6 @@ interface Builder extends Buildable.Builder<MiniMessage> {
*/
@NotNull Builder debug(final @Nullable Consumer<String> debugOutput);

/**
* If in lenient mode, MiniMessage will output helpful messages.
*
* <p>This method allows you to change how they should be printed. By default, they will be printed to standard out.</p>
*
* @param consumer the error message consumer
* @return this builder
* @since 4.10.0
*/
@NotNull Builder parsingErrorMessageConsumer(final @NotNull Consumer<List<String>> consumer);

/**
* Specify a function that takes the component at the end of the parser process.
* <p>By default, this compacts the resulting component with {@link Component#compact()}.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -41,22 +40,19 @@
* @since 4.10.0
*/
final class MiniMessageImpl implements MiniMessage {
static final Consumer<List<String>> DEFAULT_ERROR_CONSUMER = message -> message.forEach(System.out::println);
static final UnaryOperator<Component> 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<String> debugOutput;
private final Consumer<List<String>> parsingErrorMessageConsumer;
private final UnaryOperator<Component> postProcessor;
final MiniMessageParser parser;

MiniMessageImpl(final @NotNull TagResolver resolver, final boolean strict, final @Nullable Consumer<String> debugOutput, final @NotNull Consumer<List<String>> parsingErrorMessageConsumer, final @NotNull UnaryOperator<Component> postProcessor) {
MiniMessageImpl(final @NotNull TagResolver resolver, final boolean strict, final @Nullable Consumer<String> debugOutput, final @NotNull UnaryOperator<Component> postProcessor) {
this.parser = new MiniMessageParser(resolver);
this.strict = strict;
this.debugOutput = debugOutput;
this.parsingErrorMessageConsumer = parsingErrorMessageConsumer;
this.postProcessor = postProcessor;
}

Expand Down Expand Up @@ -114,16 +110,6 @@ final class MiniMessageImpl implements MiniMessage {
}
}

/**
* not public api.
*
* @return huhu.
* @since 4.10.0
*/
public @NotNull Consumer<List<String>> parsingErrorMessageConsumer() {
return this.parsingErrorMessageConsumer;
}

@Override
public @NotNull Builder toBuilder() {
return new BuilderImpl(this);
Expand All @@ -133,7 +119,6 @@ static final class BuilderImpl implements Builder {
private TagResolver tagResolver = TagResolver.standard();
private boolean strict = false;
private Consumer<String> debug = null;
private Consumer<List<String>> parsingErrorMessageConsumer = DEFAULT_ERROR_CONSUMER;
private UnaryOperator<Component> postProcessor = DEFAULT_COMPACTING_METHOD;

BuilderImpl() {
Expand All @@ -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
Expand Down Expand Up @@ -173,12 +157,6 @@ static final class BuilderImpl implements Builder {
return this;
}

@Override
public @NotNull Builder parsingErrorMessageConsumer(final @NotNull Consumer<List<String>> consumer) {
this.parsingErrorMessageConsumer = requireNonNull(consumer, "consumer");
return this;
}

@Override
public @NotNull Builder postProcessor(final @NotNull UnaryOperator<Component> postProcessor) {
this.postProcessor = Objects.requireNonNull(postProcessor, "postProcessor");
Expand All @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -280,7 +279,7 @@ void testMissingCloseOfHover() {
@Test
void testNonEndingComponent() {
final String input = "<red is already created! Try different name! :)";
MiniMessage.builder().parsingErrorMessageConsumer(strings -> 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
Expand Down

0 comments on commit 96b670a

Please sign in to comment.