Fix packets changed with text replacement

This commit is contained in:
Draycia 2020-05-04 01:01:12 -07:00
parent 3e657bbba9
commit 9e9e979104
6 changed files with 16 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package net.minestom.server.network.packet.server.play;
import net.minestom.server.chat.Chat;
import net.minestom.server.item.ItemStack;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.network.packet.server.ServerPacket;
@ -91,8 +92,8 @@ public class AdvancementsPacket implements ServerPacket {
public float y;
private void write(PacketWriter writer) {
writer.writeSizedString(title);
writer.writeSizedString(description);
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(title)));
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(title)));
writer.writeItemStack(icon);
writer.writeVarInt(frameType.ordinal());
writer.writeInt(flags);

View File

@ -2,6 +2,7 @@ package net.minestom.server.network.packet.server.play;
import net.minestom.server.bossbar.BarColor;
import net.minestom.server.bossbar.BarDivision;
import net.minestom.server.chat.Chat;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.network.packet.server.ServerPacket;
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
@ -27,7 +28,7 @@ public class BossBarPacket implements ServerPacket {
switch (action) {
case ADD:
writer.writeSizedString(title);
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(title)));
writer.writeFloat(health);
writer.writeVarInt(color.ordinal());
writer.writeVarInt(division.ordinal());
@ -40,7 +41,7 @@ public class BossBarPacket implements ServerPacket {
writer.writeFloat(health);
break;
case UPDATE_TITLE:
writer.writeSizedString(title);
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(title)));
break;
case UPDATE_STYLE:
writer.writeVarInt(color.ordinal());

View File

@ -1,5 +1,6 @@
package net.minestom.server.network.packet.server.play;
import net.minestom.server.chat.Chat;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.network.packet.server.ServerPacket;
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
@ -10,7 +11,7 @@ public class DisconnectPacket implements ServerPacket {
@Override
public void write(PacketWriter writer) {
writer.writeSizedString(message);
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(message)));
}
@Override

View File

@ -1,5 +1,6 @@
package net.minestom.server.network.packet.server.play;
import net.minestom.server.chat.Chat;
import net.minestom.server.network.packet.PacketWriter;
import net.minestom.server.network.packet.server.ServerPacket;
import net.minestom.server.network.packet.server.ServerPacketIdentifier;
@ -17,7 +18,7 @@ public class ScoreboardObjectivePacket implements ServerPacket {
writer.writeByte(mode);
if (mode == 0 || mode == 2) {
writer.writeSizedString(objectiveValue);
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(objectiveValue)));
writer.writeVarInt(type);
}
}

View File

@ -27,13 +27,13 @@ public class TeamsPacket implements ServerPacket {
switch (action) {
case CREATE_TEAM:
case UPDATE_TEAM_INFO:
writer.writeSizedString(teamDisplayName);
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(teamDisplayName)));
writer.writeByte(friendlyFlags);
writer.writeSizedString(nameTagVisibility.getIdentifier());
writer.writeSizedString(collisionRule.getIdentifier());
writer.writeVarInt(teamColor);
writer.writeSizedString(teamPrefix);
writer.writeSizedString(teamSuffix);
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(teamPrefix)));
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(teamSuffix)));
break;
case REMOVE_TEAM:

View File

@ -25,13 +25,13 @@ public class TitlePacket implements ServerPacket {
switch (action) {
case SET_TITLE:
writer.writeSizedString(titleText);
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(titleText)));
break;
case SET_SUBTITLE:
writer.writeSizedString(subtitleText);
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(subtitleText)));
break;
case SET_ACTION_BAR:
writer.writeSizedString(actionBarText);
writer.writeSizedString(Chat.toJsonString(Chat.fromLegacyText(actionBarText)));
break;
case SET_TIMES_AND_DISPLAY:
writer.writeInt(fadeIn);