mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Return dummy string instead of empty optional
This commit is contained in:
parent
6a200a1663
commit
c848b33030
1 changed files with 8 additions and 7 deletions
|
@ -130,15 +130,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> visitor) {
|
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> visitor) {
|
||||||
+ // Paper start
|
+ // Paper start - Count visited parts
|
||||||
+ try {
|
+ try {
|
||||||
+ return this.visit(new TranslatableContentConsumer<>(visitor));
|
+ return this.visit(new TranslatableContentConsumer<>(visitor));
|
||||||
+ } catch (IllegalArgumentException var5) {
|
+ } catch (IllegalArgumentException ignored) {
|
||||||
+ return Optional.empty();
|
+ return visitor.accept("...");
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ private <T> Optional<T> visit(TranslatableContentConsumer<T> visitor) {
|
+ private <T> Optional<T> visit(TranslatableContentConsumer<T> visitor) {
|
||||||
+ // Paper end
|
+ // Paper end - Count visited parts
|
||||||
this.decompose();
|
this.decompose();
|
||||||
|
|
||||||
for(FormattedText formattedText : this.decomposedParts) {
|
for(FormattedText formattedText : this.decomposedParts) {
|
||||||
|
@ -146,8 +146,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
+ // Paper start
|
+ // Paper start - Count visited parts
|
||||||
+ private static final class TranslatableContentConsumer<T> implements FormattedText.ContentConsumer<T> {
|
+ private static final class TranslatableContentConsumer<T> implements FormattedText.ContentConsumer<T> {
|
||||||
|
+ private static final IllegalArgumentException EX = new IllegalArgumentException("Too long");
|
||||||
+ private final FormattedText.ContentConsumer<T> visitor;
|
+ private final FormattedText.ContentConsumer<T> visitor;
|
||||||
+ private int visited;
|
+ private int visited;
|
||||||
+
|
+
|
||||||
|
@ -158,12 +159,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Optional<T> accept(final String asString) {
|
+ public Optional<T> accept(final String asString) {
|
||||||
+ if (visited++ > 32) {
|
+ if (visited++ > 32) {
|
||||||
+ throw new IllegalArgumentException("Too long");
|
+ throw EX;
|
||||||
+ }
|
+ }
|
||||||
+ return this.visitor.accept(asString);
|
+ return this.visitor.accept(asString);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end - Count visited parts
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MutableComponent resolve(@Nullable CommandSourceStack source, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
public MutableComponent resolve(@Nullable CommandSourceStack source, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
||||||
|
|
Loading…
Reference in a new issue