Documentation ¶
Overview ¶
Example (Command) ¶
package main import ( "fmt" "log" rcon "github.com/Aton-Kish/gorcon" ) func main() { conn, err := rcon.Dial("localhost:25575", "minecraft") if err != nil { log.Fatal(err) } defer conn.Close() // NOTE: `/player` is a carpet mod command res, err := conn.Command("/player jeb_ spawn") if err != nil { log.Fatal(err) } res, err = conn.Command("/give jeb_ minecraft:dirt 1") if err != nil { log.Fatal(err) } // NOTE: `/player` is a carpet mod command res, err = conn.Command("/player jeb_ kill") if err != nil { log.Fatal(err) } fmt.Println(res) }
Output:
Example (NbtData) ¶
package main import ( "fmt" "log" "regexp" nbt "github.com/Aton-Kish/gonbt" rcon "github.com/Aton-Kish/gorcon" ) func main() { conn, err := rcon.Dial("localhost:25575", "minecraft") if err != nil { log.Fatal(err) } defer conn.Close() // NOTE: uuid `853c80ef-3c37-49fd-aa49-938b674adae6` is jeb_ res, err := conn.Command("/data get entity 853c80ef-3c37-49fd-aa49-938b674adae6") if err != nil { log.Fatal(err) } re := regexp.MustCompile(`^[a-zA-Z0-9_]{3,16} has the following entity data: (.*)$`) g := re.FindStringSubmatch(res) if len(g) < 2 { log.Fatal("invalid data") } // NOTE: parse NBT data snbt := g[1] dat, err := nbt.Parse(snbt) if err != nil { log.Fatal(err) } json := nbt.Json(dat) fmt.Println(json) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PacketError ¶ added in v0.4.0
func (*PacketError) Error ¶ added in v0.4.0
func (e *PacketError) Error() string
func (*PacketError) Unwrap ¶ added in v0.4.0
func (e *PacketError) Unwrap() error
type RCON ¶ added in v0.7.0
func Dial ¶
Example ¶
package main import ( "fmt" "log" rcon "github.com/Aton-Kish/gorcon" ) func main() { conn, err := rcon.Dial("localhost:25575", "minecraft") if err != nil { log.Fatal(err) } defer conn.Close() res, err := conn.Command("/seed") if err != nil { log.Fatal(err) } fmt.Println(res) }
Output:
func DialTimeout ¶
Example ¶
package main import ( "fmt" "log" "time" rcon "github.com/Aton-Kish/gorcon" ) func main() { conn, err := rcon.DialTimeout("localhost:25575", "minecraft", 500*time.Millisecond) if err != nil { log.Fatal(err) } defer conn.Close() res, err := conn.Command("/seed") if err != nil { log.Fatal(err) } fmt.Println(res) }
Output:
Click to show internal directories.
Click to hide internal directories.