0
0
mirror of https://github.com/Wurst-Imperium/Wurst7.git synced 2024-09-20 01:12:13 +02:00

Port AntiSpam fix from 1.20.5 snapshots

This commit is contained in:
Alexander01998 2024-03-27 04:03:54 +01:00
parent 334a3a2024
commit 7297743b20

View File

@ -135,7 +135,17 @@ public final class AntiSpamHack extends Hack implements ChatInputListener
}
if(spamCounter > 1)
event.setComponent(((MutableText)event.getComponent())
.append(" [x" + spamCounter + "]"));
{
// Someone, somewhere, is creating a MutableText object with an
// immutable List<Text> siblings parameter, which causes the game to
// crash when calling append(). So we always have to create a new
// MutableText object to avoid that.
MutableText oldText = (MutableText)event.getComponent();
MutableText newText = MutableText.of(oldText.getContent());
newText.setStyle(oldText.getStyle());
oldText.getSiblings().forEach(newText::append);
event.setComponent(newText.append(" [x" + spamCounter + "]"));
}
}
}