Regenerate files, moves packet id from data package
This commit is contained in:
20
offline/uuid.go
Normal file
20
offline/uuid.go
Normal file
@ -0,0 +1,20 @@
|
||||
package offline
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// NameToUUID return the UUID from player name in offline mode
|
||||
func NameToUUID(name string) uuid.UUID {
|
||||
var version = 3
|
||||
h := md5.New()
|
||||
h.Reset()
|
||||
h.Write([]byte("OfflinePlayer:" + name))
|
||||
s := h.Sum(nil)
|
||||
var id uuid.UUID
|
||||
copy(id[:], s)
|
||||
id[6] = (id[6] & 0x0f) | uint8((version&0xf)<<4)
|
||||
id[8] = (id[8] & 0x3f) | 0x80 // RFC 4122 variant
|
||||
return id
|
||||
}
|
Reference in New Issue
Block a user