First support 1.21.130

This commit is contained in:
AkmalFairuz
2025-12-10 23:05:46 +07:00
parent 2b6358ea51
commit 65693b1e85
22 changed files with 10348 additions and 40 deletions

View File

@@ -50,7 +50,7 @@ type Text struct {
PlatformChatID string
// FilteredMessage is a filtered version of Message with all the profanity removed. The client will use
// this over Message if this field is not empty and they have the "Filter Profanity" setting enabled.
FilteredMessage string
FilteredMessage protocol.Optional[string]
}
// ID ...
@@ -59,8 +59,21 @@ func (*Text) ID() uint32 {
}
func (pk *Text) Marshal(io protocol.IO) {
io.Uint8(&pk.TextType)
if proto.IsProtoLT(io, proto.ID898) {
io.Uint8(&pk.TextType)
}
io.Bool(&pk.NeedsTranslation)
if proto.IsProtoGTE(io, proto.ID898) {
var categoryType uint8
if pk.TextType == TextTypeRaw || pk.TextType == TextTypeTip || pk.TextType == TextTypeSystem || pk.TextType == TextTypeObjectWhisper || pk.TextType == TextTypeObjectAnnouncement || pk.TextType == TextTypeObject {
categoryType = protocol.TextCategoryMessageOnly
} else if pk.TextType == TextTypeChat || pk.TextType == TextTypeWhisper || pk.TextType == TextTypeAnnouncement {
categoryType = protocol.TextCategoryAuthoredMessage
} else {
categoryType = protocol.TextCategoryMessageWithParameters
}
io.TextCategory(&categoryType)
}
switch pk.TextType {
case TextTypeChat, TextTypeWhisper, TextTypeAnnouncement:
io.String(&pk.SourceName)
@@ -74,6 +87,12 @@ func (pk *Text) Marshal(io protocol.IO) {
io.String(&pk.XUID)
io.String(&pk.PlatformChatID)
if proto.IsProtoGTE(io, proto.ID685) {
io.String(&pk.FilteredMessage)
if proto.IsProtoGTE(io, proto.ID898) {
protocol.OptionalFunc(io, &pk.FilteredMessage, io.String)
} else {
v, _ := pk.FilteredMessage.Value()
io.String(&v)
pk.FilteredMessage = protocol.Option(v)
}
}
}