Skip to content

Commit

Permalink
mmm upgrasde the actiondump
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeRNG committed Mar 6, 2023
1 parent 2b1ba2d commit 8642eb4
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.network.Packet;
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;
import net.minecraft.util.Formatting;

import java.io.IOException;
import java.util.Date;
Expand Down Expand Up @@ -37,8 +39,20 @@ public void init() {
public boolean onReceivePacket(Packet<?> packet) {
if(capturedData == null || isDone) return false;
if(packet instanceof GameMessageS2CPacket message) {
TextColor lastColor = null;
for(Text text : message.content().getSiblings()) {
TextColor color = text.getStyle().getColor();
if(lastColor != color) {
lastColor = color;
if(color.getName().contains("#")) {
capturedData.append(String.join("§",color.getName().split("")).replace("#","§x").toLowerCase());
} else {
capturedData.append(Formatting.valueOf(String.valueOf(color).toUpperCase()));
}
}
capturedData.append(text.getString());
}
String content = message.content().getString();
capturedData.append(content);
capturedData.append("\n");
lines += 1;
length += content.length();
Expand Down

0 comments on commit 8642eb4

Please sign in to comment.