Skip to content

Commit

Permalink
Merge pull request #34 from alteamc/codacy
Browse files Browse the repository at this point in the history
Fix Codacy issues
  • Loading branch information
dreamscached authored Jul 26, 2022
2 parents 105faec + 08ef051 commit bd3f3dd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 41 deletions.
7 changes: 0 additions & 7 deletions MIGRATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ All `Ping*` functions now take `*Pinger` 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.


# 🚀 Migrating from v1

Version 2 of MineQuery has several breaking changes from version 1. This section
Expand All @@ -35,7 +32,6 @@ also changed:
|----------------------------------------------|--------------------------------------------|
| `import "github.com/alteamc/minequery/ping"` | `import "github.com/alteamc/minequery/v2"` |


## New ping function signatures

To remove own names (Legacy, Ancient) of Minecraft versions, it has been decided to
Expand All @@ -47,7 +43,6 @@ 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

Per same reasoning as ping function renaming, response structs also have been renamed.
Expand All @@ -70,7 +65,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 @@ -86,5 +80,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
54 changes: 20 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,22 @@ might want to give it a read if you're planning to switch from v1 or v2.0.x.

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

[MIGRATING.md]: MIGRATING.md


# #️⃣ 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

[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
## 📚 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 @@ -79,12 +65,9 @@ fmt.Println(res)

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

[documentation]: https://pkg.go.dev/github.com/alteamc/minequery/v2


## 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 @@ -111,32 +94,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.

[MIGRATING.md]: MIGRATING.md
[Beta 1.8 to 1.3]: https://wiki.vg/Server_List_Ping#Beta_1.8_to_1.3
[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
[issue #25]: https://github.com/alteamc/minequery/issues/25
[documentation]: https://pkg.go.dev/github.com/alteamc/minequery/v2
[Basic usage]: #basic-usage

0 comments on commit bd3f3dd

Please sign in to comment.