Skip to content

Commit

Permalink
Add query examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamscached committed Jul 31, 2022
1 parent 817e636 commit a8ad5fa
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ As of version 2.0.0, MineQuery supports pinging of all versions of Minecraft.

### Query Protocol Support

As of version 2.0.0, query protocol is not yet supported.
See [issue #25][6] to track progress.
As of version 2.1.0, query protocol is fully supported. See examples below.

## 📚 How to use

Expand All @@ -54,12 +53,24 @@ all previous version pings (e.g. 1.7+ server will respond to 1.6 ping, and so on

Here's a quick example how to:

#### Pinging (1.7+ servers)

```go
res, err := minequery.Ping17("localhost", 25565)
if err != nil { panic(err) }
fmt.Println(res)
```

#### Querying

```go
res, err := minequery.QueryBasic("localhost", 25565)
// ... or ...
res, err := minequery.QueryFull("localhost", 25565)
if err != nil { panic(err) }
fmt.Println(res)
```

For full info on response object structure, see [documentation][7].

### Advanced usage
Expand Down Expand Up @@ -91,6 +102,15 @@ pinger.Ping16("localhost", 25565)
pinger.Ping17("localhost", 25565)
```

Or `Query*`:

```go
// Query basic stats
res, err := pinger.QueryBasic("localhost", 25565)
// Query full stats
res, err := pinger.QueryFull("localhost", 25565)
```

#### WithTimeout

By default, `Pinger` has 15-second timeout before connection aborts. If you need
Expand Down

0 comments on commit a8ad5fa

Please sign in to comment.