Skip to content

Commit

Permalink
Clean chat code and fix skins
Browse files Browse the repository at this point in the history
  • Loading branch information
rtm516 committed Jun 29, 2020
1 parent f2f59e4 commit 70009c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<dependency>
<groupId>com.github.GeyserMC</groupId>
<artifactId>MCProtocolLib</artifactId>
<version>feature~1.16-1.12.1-1-g74ee57a-310</version>
<version>feature~1.16-1.12.1-1-ge4798a3-318</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.github.steveice10.mc.protocol.data.message.TranslationMessage;
import com.github.steveice10.mc.protocol.data.message.style.ChatColor;
import com.github.steveice10.mc.protocol.data.message.style.ChatFormat;
import com.github.steveice10.mc.protocol.data.message.style.MessageStyle;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.kyori.text.Component;
Expand Down Expand Up @@ -216,25 +217,19 @@ private static Message fixMessageStyle(Message message, Message parent) {
if (parent == null) {
return message;
}
Message newMessage = message;
MessageStyle.Builder styleBuilder = message.getStyle().toBuilder();

// Copy color from parent
if (newMessage.getStyle().getColor() == ChatColor.NONE) {
JsonObject messageObject = MessageSerializer.toJsonObject(newMessage);
messageObject.addProperty("color", parent.getStyle().getColor());
newMessage = MessageSerializer.fromJson(messageObject);
if (message.getStyle().getColor() == ChatColor.NONE) {
styleBuilder.color(parent.getStyle().getColor());
}

// Copy formatting from parent
if (newMessage.getStyle().getFormats().size() == 0) {
JsonObject messageObject = MessageSerializer.toJsonObject(newMessage);
for(ChatFormat format : parent.getStyle().getFormats()) {
messageObject.addProperty(format.toString(), true);
}
newMessage = MessageSerializer.fromJson(messageObject);
if (message.getStyle().getFormats().size() == 0) {
styleBuilder.formats(parent.getStyle().getFormats());
}

return newMessage;
return message.toBuilder().style(styleBuilder.build()).build();
}

public static String getBedrockMessage(Message message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public static PlayerListPacket.Entry buildEntryManually(UUID uuid, String userna
entry.setXuid("");
entry.setPlatformChatId("");
entry.setTeacher(false);
entry.setTrustedSkin(true);
return entry;
}

Expand Down

0 comments on commit 70009c4

Please sign in to comment.