Fix registry hunter
This commit is contained in:
@@ -27,9 +27,8 @@ func wontFail[T any](v T, err error) T {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// Edit these two
|
// Edit these two
|
||||||
|
Version = "1.21.11"
|
||||||
SaveAs = "1.21.8"
|
SaveAs = "data/registry/" + Version + ".nbt"
|
||||||
Version = "1.21.8"
|
|
||||||
|
|
||||||
CompatibleProtocolVersion = wontFail(data.LookUpVersionByName(Version)).Version
|
CompatibleProtocolVersion = wontFail(data.LookUpVersionByName(Version)).Version
|
||||||
FinishedConfigErr = errors.New("finished configuration")
|
FinishedConfigErr = errors.New("finished configuration")
|
||||||
@@ -48,14 +47,6 @@ type Proxy struct {
|
|||||||
Data nbt.Tag
|
Data nbt.Tag
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Proxy) OnStart() (err error) {
|
|
||||||
p.Client.RegisterCritical(p.OnAnything)
|
|
||||||
p.Servee.RegisterCritical(p.OnAnything)
|
|
||||||
|
|
||||||
p.Client.RegisterCriticalUntilLatest(p.OnFinishConfiguration)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Proxy) OnAnything(e event.Anything) (err error) {
|
func (p *Proxy) OnAnything(e event.Anything) (err error) {
|
||||||
packet, ok := e.Val.(proto_base.EncodeDecodeAble)
|
packet, ok := e.Val.(proto_base.EncodeDecodeAble)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -111,26 +102,28 @@ func handleClient(c *proto.Conn) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sockPuppet, err := client.Connect(":25566")
|
sockPuppet, err := client.Login(":25565", acc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer sockPuppet.Close()
|
defer sockPuppet.Close()
|
||||||
err = sockPuppet.StartLoop()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
p := &Proxy{Client: sockPuppet, Servee: c}
|
p := &Proxy{Client: sockPuppet, Servee: c}
|
||||||
p.Data.Value = map[string]any{"Registries": []any{}}
|
p.Data.Value = map[string]any{"Registries": []any{}}
|
||||||
|
p.Client.RegisterCritical(p.OnAnything)
|
||||||
|
p.Servee.RegisterCritical(p.OnAnything)
|
||||||
|
p.Client.RegisterCriticalUntilLatest(p.OnData)
|
||||||
|
p.Client.RegisterCriticalUntilLatest(p.OnTags)
|
||||||
|
|
||||||
|
p.Client.RegisterCriticalUntilLatest(p.OnFinishConfiguration)
|
||||||
go func() {
|
go func() {
|
||||||
errChan <- p.Client.StartLoop()
|
errChan <- p.Client.StartConn()
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
errChan <- p.Servee.StartLoop()
|
errChan <- p.Servee.StartConn()
|
||||||
}()
|
}()
|
||||||
err = <-errChan
|
err = <-errChan
|
||||||
f, err := os.Create("data/registry/" + SaveAs + ".nbt")
|
f, err := os.Create(SaveAs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -141,7 +134,7 @@ func handleClient(c *proto.Conn) (err error) {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
slog.SetLogLoggerLevel(slog.LevelDebug)
|
slog.SetLogLoggerLevel(slog.LevelDebug)
|
||||||
err := server.StartServerWithOnConn(":25565", handleClient)
|
err := server.StartServerWithOnConn(":25566", handleClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user