mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 15:27:28 +00:00
[Protocol] Standardize fields (#84)
* [Protocol] Standardize The Ship fields * [Protocol] Standardize FFOW fields * [Protocol] Rename Valve's protocol field to protocol_version * [Protocol] Rename Minecraft's version_protocol field to protocol_version * [Protocol] Rename Valve's version field to game_version * [Protocol] Rename Minecraft java version_name to game_version * [Crate] Reformat RESPONSES.md * [Protocol] Renamed Minecraft Java players_sample to players * [Protocol] Rename Quake (1,2,3) version field to game_version * [Protocol] Rename quake (1 and 2) game_type field to game_mode * [Protocol] Rename Valve, FFOW, TS game field to game_mode * [Generics] Rename game field/function to game_mode * [Protocol] Change players_minimum, _maximum and _bots from those who werent u8 or u32 to u32 * [Protocol] Change instances of player score field type from u32 to i32 * [Crate] Nicer gramar in CHANGELOG * [Protocol] Apply clippy fixes
This commit is contained in:
parent
65c56dc196
commit
9d8fb1ba94
25 changed files with 249 additions and 200 deletions
|
|
@ -96,11 +96,11 @@ impl Java {
|
|||
let json_response = get_string(&mut buffer)?;
|
||||
let value_response: Value = serde_json::from_str(&json_response).map_err(|e| JsonParse.context(e))?;
|
||||
|
||||
let version_name = value_response["version"]["name"]
|
||||
let game_version = value_response["version"]["name"]
|
||||
.as_str()
|
||||
.ok_or(PacketBad)?
|
||||
.to_string();
|
||||
let version_protocol = value_response["version"]["protocol"]
|
||||
let protocol_version = value_response["version"]["protocol"]
|
||||
.as_i64()
|
||||
.ok_or(PacketBad)? as i32;
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ impl Java {
|
|||
let online_players = value_response["players"]["online"]
|
||||
.as_u64()
|
||||
.ok_or(PacketBad)? as u32;
|
||||
let sample_players: Option<Vec<Player>> = match value_response["players"]["sample"].is_null() {
|
||||
let players: Option<Vec<Player>> = match value_response["players"]["sample"].is_null() {
|
||||
true => None,
|
||||
false => {
|
||||
Some({
|
||||
|
|
@ -130,11 +130,11 @@ impl Java {
|
|||
};
|
||||
|
||||
Ok(JavaResponse {
|
||||
version_name,
|
||||
version_protocol,
|
||||
game_version,
|
||||
protocol_version,
|
||||
players_maximum: max_players,
|
||||
players_online: online_players,
|
||||
players_sample: sample_players,
|
||||
players,
|
||||
description: value_response["description"].to_string(),
|
||||
favicon: value_response["favicon"].as_str().map(str::to_string),
|
||||
previews_chat: value_response["previewsChat"].as_bool(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue