correct loginplugindata type

This commit is contained in:
MscBaiMeow
2021-06-19 16:02:43 +08:00
parent 76a32e21a4
commit 7f0641a094
2 changed files with 16 additions and 1 deletions

View File

@ -70,6 +70,9 @@ type (
//ByteArray is []byte with prefix VarInt as length
ByteArray []byte
//PluginMessageData is only used in LoginPlugin,and it will read all left bytes
PluginMessageData []byte
)
const MaxVarIntLen = 5
@ -490,3 +493,15 @@ func (u *UUID) ReadFrom(r io.Reader) (n int64, err error) {
nn, err := io.ReadFull(r, (*u)[:])
return int64(nn), err
}
// Encode a PluginsMessageData
func (p *PluginMessageData) WriteTo(w io.Writer) (n int64, err error) {
nn, err := w.Write(*p)
return int64(nn), err
}
// Decode a PluginsMessageData
func (p *PluginMessageData) ReadFrom(r io.Reader) (n int64, err error) {
*p, err = io.ReadAll(r)
return int64(len(*p)), err
}