Skip to content

Commit

Permalink
Implemented #515.
Browse files Browse the repository at this point in the history
  • Loading branch information
LinoxGH committed Jan 11, 2022
1 parent d8fe86e commit 10c8a84
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ final class MiniMessageParser {

@NotNull String escapeTokens(final @NotNull String richMessage, final @NotNull ContextImpl context) {
final StringBuilder sb = new StringBuilder(richMessage.length());
tryToNag(richMessage, context.strict());
this.escapeTokens(sb, richMessage, context);
return sb.toString();
}
Expand All @@ -86,6 +87,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());
tryToNag(richMessage, context.strict());
this.processTokens(sb, richMessage, context, (token, builder) -> {});
return sb.toString();
}
Expand Down Expand Up @@ -127,6 +129,7 @@ private void processTokens(final @NotNull StringBuilder sb, final @NotNull Strin
} catch (final IOException ignored) {
}
}
tryToNag(richMessage, context.strict());

final Function<TagNode, Transformation> transformationFactory;
if (debug != null) {
Expand Down Expand Up @@ -247,4 +250,10 @@ private Component handleModifying(final Modifying modTransformation, final Compo
private String sanitizePlaceholderName(final String name) {
return name.toLowerCase(Locale.ROOT);
}

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 10c8a84

Please sign in to comment.