Fix other code for compatible with new go-mc/net packet

This commit is contained in:
Tnze
2021-02-25 20:22:06 +08:00
parent 27a30efe7b
commit f8b3501b60
16 changed files with 461 additions and 478 deletions

View File

@ -59,17 +59,18 @@ func (p *UpdateHealth) Decode(pkt pk.Packet) error {
// PluginData encodes the custom data encoded in a plugin message.
type PluginData []byte
func (p PluginData) Encode() []byte {
return []byte(p)
func (p PluginData) WriteTo(w io.Writer) (int64, error) {
n, err := w.Write(p)
return int64(n), err
}
func (p *PluginData) Decode(r pk.DecodeReader) error {
func (p *PluginData) ReadFrom(r io.Reader) (int64, error) {
d, err := io.ReadAll(r)
if err != nil {
return err
return int64(len(d)), err
}
*p = d
return nil
return int64(len(d)), nil
}
// PluginMessage represents a packet with a customized payload.