cleanup code
This commit is contained in:
@ -73,7 +73,6 @@ func (b *botClient) Inventory() bot.InventoryHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *botClient) Connect(ctx context.Context, addr string, options *bot.ConnectOptions) error {
|
func (b *botClient) Connect(ctx context.Context, addr string, options *bot.ConnectOptions) error {
|
||||||
// 套用 go-mc 的連接邏輯
|
|
||||||
host, portStr, err := net.SplitHostPort(addr)
|
host, portStr, err := net.SplitHostPort(addr)
|
||||||
var port uint64
|
var port uint64
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -92,14 +91,12 @@ func (b *botClient) Connect(ctx context.Context, addr string, options *bot.Conne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 建立連接
|
|
||||||
dialer := &mcnet.DefaultDialer
|
dialer := &mcnet.DefaultDialer
|
||||||
b.conn, err = dialer.DialMCContext(ctx, addr)
|
b.conn, err = dialer.DialMCContext(ctx, addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 執行握手
|
|
||||||
if options != nil && options.FakeHost != "" {
|
if options != nil && options.FakeHost != "" {
|
||||||
host = options.FakeHost
|
host = options.FakeHost
|
||||||
}
|
}
|
||||||
@ -121,7 +118,6 @@ func (b *botClient) Connect(ctx context.Context, addr string, options *bot.Conne
|
|||||||
|
|
||||||
b.connected = true
|
b.connected = true
|
||||||
|
|
||||||
// 啟動封包處理 goroutine
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
package client
|
|
Reference in New Issue
Block a user