mirror of
https://github.com/Nan1t/NanoLimbo.git
synced 2025-07-16 06:00:13 +02:00
Fix chat packet
This commit is contained in:
parent
09cc1db851
commit
8d1dca1334
@ -126,7 +126,7 @@ public final class PacketSnapshots {
|
|||||||
if (server.getConfig().isUseJoinMessage()) {
|
if (server.getConfig().isUseJoinMessage()) {
|
||||||
PacketChatMessage joinMessage = new PacketChatMessage();
|
PacketChatMessage joinMessage = new PacketChatMessage();
|
||||||
joinMessage.setJsonData(server.getConfig().getJoinMessage());
|
joinMessage.setJsonData(server.getConfig().getJoinMessage());
|
||||||
joinMessage.setPosition(PacketChatMessage.Position.CHAT);
|
joinMessage.setPosition(PacketChatMessage.PositionLegacy.SYSTEM_MESSAGE);
|
||||||
joinMessage.setSender(UUID.randomUUID());
|
joinMessage.setSender(UUID.randomUUID());
|
||||||
PACKET_JOIN_MESSAGE = PacketSnapshot.of(joinMessage);
|
PACKET_JOIN_MESSAGE = PacketSnapshot.of(joinMessage);
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,14 @@ import java.util.UUID;
|
|||||||
public class PacketChatMessage implements PacketOut {
|
public class PacketChatMessage implements PacketOut {
|
||||||
|
|
||||||
private String jsonData;
|
private String jsonData;
|
||||||
private Position position;
|
private PositionLegacy position;
|
||||||
private UUID sender;
|
private UUID sender;
|
||||||
|
|
||||||
public void setJsonData(String jsonData) {
|
public void setJsonData(String jsonData) {
|
||||||
this.jsonData = jsonData;
|
this.jsonData = jsonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(Position position) {
|
public void setPosition(PositionLegacy position) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,13 +44,18 @@ public class PacketChatMessage implements PacketOut {
|
|||||||
@Override
|
@Override
|
||||||
public void encode(ByteMessage msg, Version version) {
|
public void encode(ByteMessage msg, Version version) {
|
||||||
msg.writeString(jsonData);
|
msg.writeString(jsonData);
|
||||||
|
if (version.moreOrEqual(Version.V1_19)) {
|
||||||
|
msg.writeVarInt(position.index);
|
||||||
|
}
|
||||||
|
else {
|
||||||
msg.writeByte(position.index);
|
msg.writeByte(position.index);
|
||||||
|
}
|
||||||
|
|
||||||
if (version.moreOrEqual(Version.V1_16))
|
if (version.moreOrEqual(Version.V1_16) && version.less(Version.V1_19))
|
||||||
msg.writeUuid(sender);
|
msg.writeUuid(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Position {
|
public enum PositionLegacy {
|
||||||
|
|
||||||
CHAT(0),
|
CHAT(0),
|
||||||
SYSTEM_MESSAGE(1),
|
SYSTEM_MESSAGE(1),
|
||||||
@ -58,7 +63,7 @@ public class PacketChatMessage implements PacketOut {
|
|||||||
|
|
||||||
private final int index;
|
private final int index;
|
||||||
|
|
||||||
Position(int index) {
|
PositionLegacy(int index) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,175 @@
|
|||||||
{
|
{
|
||||||
|
"minecraft:chat_type": {
|
||||||
|
type: "minecraft:chat_type",
|
||||||
|
value: [
|
||||||
|
{
|
||||||
|
name: "minecraft:chat",
|
||||||
|
id: 0,
|
||||||
|
element: {
|
||||||
|
chat: {
|
||||||
|
decoration: {
|
||||||
|
style: {},
|
||||||
|
translation_key: "chat.type.text",
|
||||||
|
parameters: [
|
||||||
|
"sender",
|
||||||
|
"content",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
narration: {
|
||||||
|
priority: "chat",
|
||||||
|
decoration: {
|
||||||
|
style: {},
|
||||||
|
translation_key: "chat.type.text.narrate",
|
||||||
|
parameters: [
|
||||||
|
"sender",
|
||||||
|
"content",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "minecraft:system",
|
||||||
|
id: 1,
|
||||||
|
element: {
|
||||||
|
chat: {},
|
||||||
|
narration: {
|
||||||
|
priority: "system",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "minecraft:game_info",
|
||||||
|
id: 2,
|
||||||
|
element: {
|
||||||
|
overlay: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "minecraft:say_command",
|
||||||
|
id: 3,
|
||||||
|
element: {
|
||||||
|
chat: {
|
||||||
|
decoration: {
|
||||||
|
style: {},
|
||||||
|
translation_key: "chat.type.announcement",
|
||||||
|
parameters: [
|
||||||
|
"sender",
|
||||||
|
"content",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
narration: {
|
||||||
|
priority: "chat",
|
||||||
|
decoration: {
|
||||||
|
style: {},
|
||||||
|
translation_key: "chat.type.text.narrate",
|
||||||
|
parameters: [
|
||||||
|
"sender",
|
||||||
|
"content",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "minecraft:msg_command",
|
||||||
|
id: 4,
|
||||||
|
element: {
|
||||||
|
chat: {
|
||||||
|
decoration: {
|
||||||
|
style: {
|
||||||
|
color: "gray",
|
||||||
|
italic: 1,
|
||||||
|
},
|
||||||
|
translation_key: "commands.message.display.incoming",
|
||||||
|
parameters: [
|
||||||
|
"sender",
|
||||||
|
"content",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
narration: {
|
||||||
|
priority: "chat",
|
||||||
|
decoration: {
|
||||||
|
style: {},
|
||||||
|
translation_key: "chat.type.text.narrate",
|
||||||
|
parameters: [
|
||||||
|
"sender",
|
||||||
|
"content",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "minecraft:team_msg_command",
|
||||||
|
id: 5,
|
||||||
|
element: {
|
||||||
|
chat: {
|
||||||
|
decoration: {
|
||||||
|
style: {},
|
||||||
|
translation_key: "chat.type.team.text",
|
||||||
|
parameters: [
|
||||||
|
"team_name",
|
||||||
|
"sender",
|
||||||
|
"content",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
narration: {
|
||||||
|
priority: "chat",
|
||||||
|
decoration: {
|
||||||
|
style: {},
|
||||||
|
translation_key: "chat.type.text.narrate",
|
||||||
|
parameters: [
|
||||||
|
"sender",
|
||||||
|
"content",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "minecraft:emote_command",
|
||||||
|
id: 6,
|
||||||
|
element: {
|
||||||
|
chat: {
|
||||||
|
decoration: {
|
||||||
|
style: {},
|
||||||
|
translation_key: "chat.type.emote",
|
||||||
|
parameters: [
|
||||||
|
"sender",
|
||||||
|
"content",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
narration: {
|
||||||
|
priority: "chat",
|
||||||
|
decoration: {
|
||||||
|
style: {},
|
||||||
|
translation_key: "chat.type.emote",
|
||||||
|
parameters: [
|
||||||
|
"sender",
|
||||||
|
"content",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "minecraft:tellraw_command",
|
||||||
|
id: 7,
|
||||||
|
element: {
|
||||||
|
chat: {},
|
||||||
|
narration: {
|
||||||
|
priority: "chat",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
"minecraft:dimension_type": {
|
"minecraft:dimension_type": {
|
||||||
type: "minecraft:dimension_type",
|
type: "minecraft:dimension_type",
|
||||||
value: [
|
value: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user