Skip to content

Commit

Permalink
Implemented KyoriPowered#515.
Browse files Browse the repository at this point in the history
  • Loading branch information
LinoxGH authored and zml2008 committed Feb 28, 2022
1 parent ce84982 commit 03ad7a3
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ final class MiniMessageParser {

@NotNull String escapeTokens(final @NotNull String richMessage, final @NotNull ContextImpl context) {
final StringBuilder sb = new StringBuilder(richMessage.length());
this.tryToNag(richMessage, context.strict());
this.escapeTokens(sb, richMessage, context);
return sb.toString();
}
Expand All @@ -84,6 +85,7 @@ void escapeTokens(final StringBuilder sb, final @NotNull String richMessage, fin

@NotNull String stripTokens(final @NotNull String richMessage, final @NotNull ContextImpl context) {
final StringBuilder sb = new StringBuilder(richMessage.length());
this.tryToNag(richMessage, context.strict());
this.processTokens(sb, richMessage, context, (token, builder) -> {});
return sb.toString();
}
Expand Down Expand Up @@ -125,6 +127,7 @@ private void processTokens(final @NotNull StringBuilder sb, final @NotNull Strin
debug.accept(richMessage);
debug.accept("\n");
}
this.tryToNag(richMessage, context.strict());

final TokenParser.TagProvider transformationFactory;
if (debug != null) {
Expand Down Expand Up @@ -265,4 +268,10 @@ private Component handleModifying(final Modifying modTransformation, final Compo
}
return newComp;
}

private void tryToNag(final String input, final boolean strict) {
if (input.contains("§") && strict) {
throw new IllegalArgumentException("Legacy formatting codes have been detected in a component - this is unsupported behaviour. Please refer to the Adventure documentation (https://docs.adventure.kyori.net) for more information.");
}
}
}

0 comments on commit 03ad7a3

Please sign in to comment.