Skip to content

Commit

Permalink
Fix nil pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
robinbraemer committed Sep 8, 2022
1 parent a12d7f1 commit ed3aa70
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion minecraft/component/codec/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,16 @@ const (
)

func (j *Json) encodeText(o obj, t *Text) error {
if t == nil {
return nil
}
o[text] = t.Content
return j.encodeComponent(o, t, extra)
}
func (j *Json) encodeTranslation(o obj, t *Translation) error {
if t == nil {
return nil
}
o[translate] = t.Key
return j.encodeComponent(o, t, translateWith)
}
Expand Down Expand Up @@ -317,7 +323,7 @@ func (j *Json) decodeComponent(o obj) (c Component, err error) {
c = &Translation{Key: k}
}
} else {
return nil, errors.New("unknown object, could not find any known key")
c = &Text{}
}

if o.Has(extra) {
Expand Down

0 comments on commit ed3aa70

Please sign in to comment.