Skip to content

Commit

Permalink
Merge branch 'dev' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamscached committed Jul 31, 2022
2 parents 320994f + 7a2b8a1 commit 817e636
Show file tree
Hide file tree
Showing 18 changed files with 921 additions and 736 deletions.
118 changes: 0 additions & 118 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ This file contains list of people who have either created this project initially
or heavily contributed to major releases development.

Herman S. <[email protected]>
Original idea and implementation of v1
Original idea and implementation of v1 and v2
45 changes: 33 additions & 12 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
# 🚀 Migrating from v1
# 🚀 Migrating MineQuery

MineQuery is in active development since its very release, and occasionally, newer
versions of it may introduce changes that might be breaking to existing codebase.

This page will help you migrating your code in order to adapt to changes.

## From v2.0.x

Version 2.1.0 has moved from value parameters, receivers and return values to pointers.

### Receivers

All `Ping*` functions now take `*Pinger` pointer as receiver.

`DescriptionText()` now takes `*Status17` pointer as receiver.

`IsIncompatible()` now takes `*Status16` pointer as receiver.

### Parameters

`WithDialer` option now takes `*net.Dialer` as parameter.

### Fields

`Pinger` struct now has `Dialer *net.Dialer` field.

## From v1

Version 2 of MineQuery has several breaking changes from version 1. This section
will help you migrate your existing codebase to v2.

[skip this section]: #-minecraft-version-support

## Package renaming
### Package renaming

MineQuery v2 has its package named `minequery/v2` instead of `ping`. Import path has
also changed:
Expand All @@ -14,8 +39,7 @@ also changed:
|----------------------------------------------|--------------------------------------------|
| `import "github.com/alteamc/minequery/ping"` | `import "github.com/alteamc/minequery/v2"` |


## New ping function signatures
### New ping function signatures

To remove own names (Legacy, Ancient) of Minecraft versions, it has been decided to
rename `Ping*` functions per `PingVERSION` scheme. See table below for reference.
Expand All @@ -26,13 +50,12 @@ rename `Ping*` functions per `PingVERSION` scheme. See table below for reference
| `ping.PingLegacy(host string, port int) (*ping.LegacyResponse, error)` | `minequery.Ping16(host string, port int) (*minequery.Status16, error)`<br><br>⚠️ **Note!** MineQuery v1 does not differentiate 1.4 and 1.6 pings and the above example pings 1.6 servers. Use `minequery.Ping14(host string, port int) (*minequery.Status14, error)` to ping 1.4 servers. |
| `ping.PingAncient(host string, port int) (*ping.AncientResponse, error)` | `minequery.PingBeta18(host string, port int) (*minequery.StatusBeta18, error)` |


## New response structure naming and signatures
### New response structure naming and signatures

Per same reasoning as ping function renaming, response structs also have been renamed.
See table below for reference.

Bear in mind that package name has also changed, see [Package renaming] section.
Bear in mind that package name has also changed, see [Package renaming][1] section.

| v1 name | v2 name |
|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
Expand All @@ -49,7 +72,6 @@ See table below for reference (applies both to `ping.LegacyResponse` and `ping.A
| `MessageOfTheDay` | `MOTD` |
| `PlayerCount` | `OnlinePlayers` |


`ping.Response` has been heavily reworked (mostly, due to flattening) with fields renamed,
nested structs flattened and new fields added. See table below for reference.

Expand All @@ -65,5 +87,4 @@ nested structs flattened and new fields added. See table below for reference.
| `Favicon` | `Icon`<br><br>⚠️ **Note!** MineQuery v1 did not process icon in any way, v2 decodes it into `image.Image` instance. |
| *New in v2* | `PreviewsChat` |


[Package renaming]: #package-renaming
[1]: #package-renaming
75 changes: 29 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<h1 align="center">📡 MineQuery</h1>
<h4 align="center">Minecraft Server List Ping library written in Go</h4>
<p align="center">
<a href="https://github.com/alteamc/minequery/actions/workflows/test.yml">
<img alt="Test workflow badge" src="https://img.shields.io/github/workflow/status/alteamc/minequery/Test/v2?label=Test&logo=github">
</a>
<a href="https://github.com/alteamc/minequery/blob/v2/go.mod">
<img alt="Go version badge" src="https://img.shields.io/github/go-mod/go-version/alteamc/minequery">
</a>
Expand All @@ -25,43 +22,29 @@
</a>
</p>

# 🚀 Migrating from v1
# 🚀 Migrating from v2.0.x or v1

If you're new to MineQuery, you can skip this part. If you have used it before, you
might want to give it a read if you're planning to switch from v1.

See [MIGRATING.md] for help with migrating from MineQuery v1 to v2.
might want to give it a read if you're planning to switch from v1 or v2.0.x.

[MIGRATING.md]: MIGRATING.md
See [MIGRATING.md][1] for help with migrating from MineQuery.


# #️⃣ Minecraft Version Support
## #️⃣ Minecraft Version Support

As of version 2.0.0, MineQuery supports pinging of all versions of Minecraft.

| [Beta 1.8 to 1.3] | [1.4] | [1.6 to 1.7] | [1.7+] |
|-------------------|-------------|--------------|-------------|
| ✅ Supported | ✅ Supported | ✅ Supported | ✅ Supported |

[Beta 1.8 to 1.3]: https://wiki.vg/Server_List_Ping#Beta_1.8_to_1.3
| [Beta 1.8 to 1.3][2] | [1.4][3] | [1.6 to 1.7][4] | [1.7+][5] |
|----------------------|-------------|-----------------|-------------|
| ✅ Supported | ✅ Supported | ✅ Supported | ✅ Supported |

[1.4]: https://wiki.vg/Server_List_Ping#1.4_to_1.5

[1.6 to 1.7]: https://wiki.vg/Server_List_Ping#1.6

[1.7+]: https://wiki.vg/Server_List_Ping#Current

## Query Protocol Support
### Query Protocol Support

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

[issue #25]: https://github.com/alteamc/minequery/issues/25
See [issue #25][6] to track progress.

## 📚 How to use

# 📚 How to use

## Basic usage
### Basic usage

For simple pinging with default parameters, use package-global `Ping*` functions
(where `*` is your respective Minecraft server version.)
Expand All @@ -77,14 +60,11 @@ if err != nil { panic(err) }
fmt.Println(res)
```

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

[documentation]: https://pkg.go.dev/github.com/alteamc/minequery/v2
For full info on response object structure, see [documentation][7].

### Advanced usage

## Advanced usage

### Pinger
#### Pinger

For more advanced usage, such as setting custom timeout or enabling more strict
response validation, you can use `Pinger` struct with `PingerOption` passed to it:
Expand All @@ -98,7 +78,7 @@ pinger := minequery.NewPinger(
)
```

Then, use `Ping*` functions on it the same way as described in [Basic usage] section:
Then, use `Ping*` functions on it the same way as described in [Basic usage][8] section:

```go
// Ping Beta 1.8+
Expand All @@ -111,32 +91,35 @@ pinger.Ping16("localhost", 25565)
pinger.Ping17("localhost", 25565)
```

[Basic usage]: #basic-usage


### WithTimeout
#### WithTimeout

By default, `Pinger` has 15-second timeout before connection aborts. If you need
to customize this duration, you can use `WithTimeout` option.


### WithUseStrict
#### WithUseStrict

By default, `Pinger` does not validate response data it receives and silently
omits erroneous values it processes (incorrect favicon or bad player UUID).
If you need it to return an error in case of invalid response, you can use
`WithUseStrict` option.


### WithProtocolVersion16
#### WithProtocolVersion16

By default, `Pinger` sends protocol version 74 in 1.6 ping packets. If you need
to customize protocol version sent, use `WithProtocolVersion16`. MineQuery provides
a convenient set of constants you can use &mdash; see `Ping16ProtocolVersion*` constants.


### WithProtocolVersion17
#### WithProtocolVersion17

By default, `Pinger` sends protocol version -1 in 1.7 ping packets. If you need
to customize protocol version sent, use `WithProtocolVersion17`. MineQuery provides
a convenient set of constants you can use &mdash; see `Ping17ProtocolVersion*` constants.
a convenient set of constants you can use &mdash; see `Ping17ProtocolVersion*` constants.

[1]: MIGRATING.md
[2]: https://wiki.vg/Server_List_Ping#Beta_1.8_to_1.3
[3]: https://wiki.vg/Server_List_Ping#1.4_to_1.5
[4]: https://wiki.vg/Server_List_Ping#1.6
[5]: https://wiki.vg/Server_List_Ping#Current
[6]: https://github.com/alteamc/minequery/issues/25
[7]: https://pkg.go.dev/github.com/alteamc/minequery/v2
[8]: #basic-usage
Loading

0 comments on commit 817e636

Please sign in to comment.