add deviceID to custom data

This commit is contained in:
olebeck 2023-02-23 10:23:35 +01:00
parent d6b2f53f48
commit 8365adb4cd
2 changed files with 28 additions and 27 deletions

View File

@ -69,41 +69,39 @@ func (s *skinsSession) AddPlayerSkin(playerID uuid.UUID, playerName string, skin
} }
} }
func (s *skinsSession) ProcessPacket(pk packet.Packet) { func (s *skinsSession) AddSkin(playerName string, playerID uuid.UUID, playerSkin *protocol.Skin) {
switch pk := pk.(type) {
case *packet.PlayerSkin:
playerName := s.playerNames[pk.UUID]
if playerName == "" { if playerName == "" {
playerName = pk.UUID.String() playerName = s.playerNames[playerID]
if playerName == "" {
playerName = playerID.String()
}
} }
if !strings.HasPrefix(playerName, s.PlayerNameFilter) { if !strings.HasPrefix(playerName, s.PlayerNameFilter) {
return return
} }
s.playerNames[playerID] = playerName
skin := Skin{&pk.Skin} skin := Skin{playerSkin}
if s.OnlyIfHasGeometry && !skin.HaveGeometry() { if s.OnlyIfHasGeometry && !skin.HaveGeometry() {
return return
} }
s.AddPlayerSkin(pk.UUID, playerName, &skin) s.AddPlayerSkin(playerID, playerName, &skin)
}
func (s *skinsSession) ProcessPacket(pk packet.Packet) {
switch pk := pk.(type) {
case *packet.PlayerSkin:
s.AddSkin("", pk.UUID, &pk.Skin)
case *packet.PlayerList: case *packet.PlayerList:
if pk.ActionType == 1 { // remove if pk.ActionType == 1 { // remove
return return
} }
for _, player := range pk.Entries { for _, player := range pk.Entries {
playerName := utils.CleanupName(player.Username) s.AddSkin(utils.CleanupName(player.Username), player.UUID, &player.Skin)
if playerName == "" {
playerName = player.UUID.String()
} }
if !strings.HasPrefix(playerName, s.PlayerNameFilter) { case *packet.AddPlayer:
return if _, ok := s.playerNames[pk.UUID]; !ok {
} s.playerNames[pk.UUID] = utils.CleanupName(pk.Username)
s.playerNames[player.UUID] = playerName
skin := Skin{&player.Skin}
if s.OnlyIfHasGeometry && !skin.HaveGeometry() {
return
}
s.AddPlayerSkin(player.UUID, playerName, &skin)
} }
} }
} }

View File

@ -99,6 +99,7 @@ type CustomClientData struct {
// misc // misc
IsEditorMode bool IsEditorMode bool
LanguageCode string LanguageCode string
DeviceID string
} }
func (p *ProxyContext) LoadCustomUserData(path string) error { func (p *ProxyContext) LoadCustomUserData(path string) error {
@ -148,6 +149,8 @@ func (p *ProxyContext) LoadCustomUserData(path string) error {
p.CustomClientData.SkinGeometry = base64.RawStdEncoding.EncodeToString(data) p.CustomClientData.SkinGeometry = base64.RawStdEncoding.EncodeToString(data)
} }
p.CustomClientData.DeviceID = customData.DeviceID
return nil return nil
} }