Skip to content

Commit

Permalink
Allow parsing with custom Tag Resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
Joo200 committed Feb 23, 2022
1 parent 8eaa402 commit e675885
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -42,10 +43,11 @@ public interface Context {
* Parses a MiniMessage string using all the settings of this context.
*
* @param message the message to parse
* @param resolvers additional tag resolvers
* @return the parsed message
* @since 4.10.0
*/
@NotNull Component parse(final @NotNull String message);
@NotNull Component parse(final @NotNull String message, final @NotNull TagResolver@NotNull... resolvers);

/**
* Create a new parsing exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ public UnaryOperator<Component> postProcessor() {
}

@Override
public @NotNull Component parse(final @NotNull String message) {
return this.miniMessage.deserialize(requireNonNull(message, "message"), this.tagResolver);
public @NotNull Component parse(final @NotNull String message, final @NotNull TagResolver@NotNull... resolvers) {
return this.miniMessage.deserialize(requireNonNull(message, "message"),
TagResolver.resolver(this.tagResolver, TagResolver.resolver(resolvers)));
}

@Override
Expand Down

0 comments on commit e675885

Please sign in to comment.