Skip to content

playnet-public/minecraft-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minecraft-client

GoDoc Badge Travis Badge License Badge

A client for the Minecraft RCON protocol.

Fork Details

This library was forked for improvements needed to work with our projects.

Changes:

  • Fixed potential deadlocks on connection errors.
  • Added NewClientTimeout to prevent permanent blocking on reconnects.

Library Usage

// Create a new client and connect to the server.
client, err := minecraft.NewClient("127.0.0.1:25575")
if err != nil {
	log.Fatal(err)
}
defer client.Close()

// Send some commands.
if err := client.Authenticate("password"); err != nil {
	log.Fatal(err)
}
resp, err := client.SendCommand("seed")
if err != nil {
	log.Fatal(err)
}
log.Println(resp.Body) // "Seed: [1871644822592853811]"

Shell Utility

If you are looking for a tool rather than a library, try the shell command:

$ cd cmd/shell
$ go run main.go --hostport 127.0.0.1:25575 --password minecraft
Starting RCON shell. Use 'exit', 'quit', or Ctrl-C to exit.
> list
There are 0 of a max of 20 players online:
> seed
Seed: [5853448882787620410]

Limitations

Response bodies over 4KB will be truncated.

Starting a server for testing

$ docker pull itzg/minecraft-server
$ docker run --name=minecraft-server -p 25575:25575 -d -e EULA=TRUE itzg/minecraft-server

Running Tests

To run unit tests:

$ go test -v

To run integration tests after starting the test server in Docker:

$ go test -v --tags=integration

Reference

About

A Minecraft RCON client written in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%