mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
chore: Move minecraft protocol to games. (#153)
* chore: initial move and refactor of minecraft * fix: glob re-exports * fix: failing example sample * docs: update changelog to note the mc protocol implementation to games * docs: add back the reference query standard reference
This commit is contained in:
parent
bd73b657c7
commit
7416d54b14
15 changed files with 88 additions and 94 deletions
|
|
@ -21,7 +21,9 @@ Game:
|
||||||
- - Left 4 Dead: `left4dead` -> `l4d`.
|
- - Left 4 Dead: `left4dead` -> `l4d`.
|
||||||
- - 7 Days to Die: `7d2d` in definitions and `sd2d` in game declaration -> `sdtd`.
|
- - 7 Days to Die: `7d2d` in definitions and `sd2d` in game declaration -> `sdtd`.
|
||||||
- - Quake 3 Arena: `quake3arena` -> `q3a`.
|
- - Quake 3 Arena: `quake3arena` -> `q3a`.
|
||||||
- Minecraft Legacy 1.5 and 1.3 were renamed to 1.4 and beta 1.8 respectively to show the lowest version they support, this change includes Structs, Enum and game id renames, also removed the "v" from the game definition name.
|
- Minecraft:
|
||||||
|
- - Legacy 1.5 and 1.3 were renamed to 1.4 and beta 1.8 respectively to show the lowest version they support, this change includes Structs, Enum and game id renames, also removed the "v" from the game definition name.
|
||||||
|
- - Moved the Minecraft protocol implementation in the games folder as its proprietary.
|
||||||
|
|
||||||
Protocols:
|
Protocols:
|
||||||
- Valve: Removed `SteamApp` due to it not being really useful at all, replaced all instances with `Engine`.
|
- Valve: Removed `SteamApp` due to it not being really useful at all, replaced all instances with `Engine`.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use gamedig::games::minecraft;
|
use gamedig::minecraft;
|
||||||
use gamedig::protocols::minecraft::RequestSettings;
|
use gamedig::minecraft::types::RequestSettings;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// or Some(<port>), None is the default protocol port (which is 25565 for java
|
// or Some(<port>), None is the default protocol port (which is 25565 for java
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,7 @@
|
||||||
//! Static definitions of currently supported games
|
//! Static definitions of currently supported games
|
||||||
|
|
||||||
use crate::protocols::{
|
use crate::games::minecraft::types::{LegacyGroup, Server};
|
||||||
gamespy::GameSpyVersion,
|
use crate::protocols::{gamespy::GameSpyVersion, quake::QuakeVersion, valve::Engine, Protocol};
|
||||||
minecraft::{LegacyGroup, Server},
|
|
||||||
quake::QuakeVersion,
|
|
||||||
valve::Engine,
|
|
||||||
Protocol,
|
|
||||||
};
|
|
||||||
use crate::Game;
|
use crate::Game;
|
||||||
|
|
||||||
use crate::protocols::types::ProprietaryProtocol;
|
use crate::protocols::types::ProprietaryProtocol;
|
||||||
|
|
@ -36,14 +31,14 @@ macro_rules! game {
|
||||||
/// Map of all currently supported games
|
/// Map of all currently supported games
|
||||||
pub static GAMES: Map<&'static str, Game> = phf_map! {
|
pub static GAMES: Map<&'static str, Game> = phf_map! {
|
||||||
// Query with all minecraft protocols
|
// Query with all minecraft protocols
|
||||||
"minecraft" => game!("Minecraft", 25565, Protocol::Minecraft(None)),
|
"minecraft" => game!("Minecraft", 25565, Protocol::PROPRIETARY(ProprietaryProtocol::Minecraft(None))),
|
||||||
// Query with specific minecraft protocols
|
// Query with specific minecraft protocols
|
||||||
"minecraftbedrock" => game!("Minecraft (bedrock)", 19132, Protocol::Minecraft(Some(Server::Bedrock))),
|
"minecraftbedrock" => game!("Minecraft (bedrock)", 19132, Protocol::PROPRIETARY(ProprietaryProtocol::Minecraft(Some(Server::Bedrock)))),
|
||||||
"minecraftpocket" => game!("Minecraft (pocket)", 19132, Protocol::Minecraft(Some(Server::Bedrock))),
|
"minecraftpocket" => game!("Minecraft (pocket)", 19132, Protocol::PROPRIETARY(ProprietaryProtocol::Minecraft(Some(Server::Bedrock)))),
|
||||||
"minecraftjava" => game!("Minecraft (java)", 25565, Protocol::Minecraft(Some(Server::Java))),
|
"minecraftjava" => game!("Minecraft (java)", 25565, Protocol::PROPRIETARY(ProprietaryProtocol::Minecraft(Some(Server::Java)))),
|
||||||
"minecraftlegacy16" => game!("Minecraft (legacy 1.6)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_6)))),
|
"minecraftlegacy16" => game!("Minecraft (legacy 1.6)", 25565, Protocol::PROPRIETARY(ProprietaryProtocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_6))))),
|
||||||
"minecraftlegacy14" => game!("Minecraft (legacy 1.4)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_4)))),
|
"minecraftlegacy14" => game!("Minecraft (legacy 1.4)", 25565, Protocol::PROPRIETARY(ProprietaryProtocol::Minecraft(Some(Server::Legacy(LegacyGroup::V1_4))))),
|
||||||
"minecraftlegacyb18" => game!("Minecraft (legacy b1.8)", 25565, Protocol::Minecraft(Some(Server::Legacy(LegacyGroup::VB1_8)))),
|
"minecraftlegacyb18" => game!("Minecraft (legacy b1.8)", 25565, Protocol::PROPRIETARY(ProprietaryProtocol::Minecraft(Some(Server::Legacy(LegacyGroup::VB1_8))))),
|
||||||
"alienswarm" => game!("Alien Swarm", 27015, Protocol::Valve(Engine::new(630))),
|
"alienswarm" => game!("Alien Swarm", 27015, Protocol::Valve(Engine::new(630))),
|
||||||
"aoc" => game!("Age of Chivalry", 27015, Protocol::Valve(Engine::new(17510))),
|
"aoc" => game!("Age of Chivalry", 27015, Protocol::Valve(Engine::new(17510))),
|
||||||
"a2oa" => game!("ARMA 2: Operation Arrowhead", 2304, Protocol::Valve(Engine::new(33930))),
|
"a2oa" => game!("ARMA 2: Operation Arrowhead", 2304, Protocol::Valve(Engine::new(33930))),
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
use crate::protocols::minecraft::RequestSettings;
|
/// The implementation.
|
||||||
use crate::{
|
/// Reference: [Server List Ping](https://wiki.vg/Server_List_Ping)
|
||||||
protocols::minecraft::{self, BedrockResponse, JavaResponse, LegacyGroup},
|
pub mod protocol;
|
||||||
GDErrorKind,
|
/// All types used by the implementation.
|
||||||
GDResult,
|
pub mod types;
|
||||||
};
|
|
||||||
|
pub use protocol::*;
|
||||||
|
pub use types::*;
|
||||||
|
|
||||||
|
use crate::{GDErrorKind, GDResult};
|
||||||
use std::net::{IpAddr, SocketAddr};
|
use std::net::{IpAddr, SocketAddr};
|
||||||
|
|
||||||
/// Query with all the protocol variants one by one (Java -> Bedrock -> Legacy
|
/// Query with all the protocol variants one by one (Java -> Bedrock -> Legacy
|
||||||
|
|
@ -30,7 +34,7 @@ pub fn query_java(
|
||||||
port: Option<u16>,
|
port: Option<u16>,
|
||||||
request_settings: Option<RequestSettings>,
|
request_settings: Option<RequestSettings>,
|
||||||
) -> GDResult<JavaResponse> {
|
) -> GDResult<JavaResponse> {
|
||||||
minecraft::query_java(
|
protocol::query_java(
|
||||||
&SocketAddr::new(*address, port_or_java_default(port)),
|
&SocketAddr::new(*address, port_or_java_default(port)),
|
||||||
None,
|
None,
|
||||||
request_settings,
|
request_settings,
|
||||||
|
|
@ -39,12 +43,12 @@ pub fn query_java(
|
||||||
|
|
||||||
/// Query a (Java) Legacy Server (1.6 -> 1.4 -> Beta 1.8).
|
/// Query a (Java) Legacy Server (1.6 -> 1.4 -> Beta 1.8).
|
||||||
pub fn query_legacy(address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
pub fn query_legacy(address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||||
minecraft::query_legacy(&SocketAddr::new(*address, port_or_java_default(port)), None)
|
protocol::query_legacy(&SocketAddr::new(*address, port_or_java_default(port)), None)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Query a specific (Java) Legacy Server.
|
/// Query a specific (Java) Legacy Server.
|
||||||
pub fn query_legacy_specific(group: LegacyGroup, address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
pub fn query_legacy_specific(group: LegacyGroup, address: &IpAddr, port: Option<u16>) -> GDResult<JavaResponse> {
|
||||||
minecraft::query_legacy_specific(
|
protocol::query_legacy_specific(
|
||||||
group,
|
group,
|
||||||
&SocketAddr::new(*address, port_or_java_default(port)),
|
&SocketAddr::new(*address, port_or_java_default(port)),
|
||||||
None,
|
None,
|
||||||
|
|
@ -53,7 +57,7 @@ pub fn query_legacy_specific(group: LegacyGroup, address: &IpAddr, port: Option<
|
||||||
|
|
||||||
/// Query a Bedrock Server.
|
/// Query a Bedrock Server.
|
||||||
pub fn query_bedrock(address: &IpAddr, port: Option<u16>) -> GDResult<BedrockResponse> {
|
pub fn query_bedrock(address: &IpAddr, port: Option<u16>) -> GDResult<BedrockResponse> {
|
||||||
minecraft::query_bedrock(
|
protocol::query_bedrock(
|
||||||
&SocketAddr::new(*address, port_or_bedrock_default(port)),
|
&SocketAddr::new(*address, port_or_bedrock_default(port)),
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
|
|
@ -2,10 +2,8 @@
|
||||||
// (MIT) from https://github.com/gamedig/node-gamedig/blob/master/protocols/minecraftbedrock.js
|
// (MIT) from https://github.com/gamedig/node-gamedig/blob/master/protocols/minecraftbedrock.js
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::{Buffer, Utf8Decoder},
|
buffer::{Buffer, Utf8Decoder},
|
||||||
protocols::{
|
games::minecraft::{BedrockResponse, GameMode, Server},
|
||||||
minecraft::{BedrockResponse, GameMode, Server},
|
protocols::types::TimeoutSettings,
|
||||||
types::TimeoutSettings,
|
|
||||||
},
|
|
||||||
socket::{Socket, UdpSocket},
|
socket::{Socket, UdpSocket},
|
||||||
utils::{error_by_expected_size, retry_on_timeout},
|
utils::{error_by_expected_size, retry_on_timeout},
|
||||||
GDErrorKind::{PacketBad, TypeParse},
|
GDErrorKind::{PacketBad, TypeParse},
|
||||||
|
|
@ -1,20 +1,16 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::Buffer,
|
buffer::Buffer,
|
||||||
protocols::{
|
games::minecraft::{as_string, as_varint, get_string, get_varint, JavaResponse, Player, RequestSettings, Server},
|
||||||
minecraft::{as_varint, get_string, get_varint, JavaResponse, Player, Server},
|
protocols::types::TimeoutSettings,
|
||||||
types::TimeoutSettings,
|
|
||||||
},
|
|
||||||
socket::{Socket, TcpSocket},
|
socket::{Socket, TcpSocket},
|
||||||
utils::retry_on_timeout,
|
utils::retry_on_timeout,
|
||||||
GDErrorKind::{JsonParse, PacketBad},
|
GDErrorKind::{JsonParse, PacketBad},
|
||||||
GDResult,
|
GDResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::net::SocketAddr;
|
|
||||||
|
|
||||||
use crate::protocols::minecraft::{as_string, RequestSettings};
|
|
||||||
use byteorder::LittleEndian;
|
use byteorder::LittleEndian;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
pub struct Java {
|
pub struct Java {
|
||||||
socket: TcpSocket,
|
socket: TcpSocket,
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
use byteorder::BigEndian;
|
use byteorder::BigEndian;
|
||||||
|
|
||||||
|
use crate::minecraft::protocol::legacy_v1_6::LegacyV1_6;
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::{Buffer, Utf16Decoder},
|
buffer::{Buffer, Utf16Decoder},
|
||||||
protocols::{
|
games::minecraft::{JavaResponse, LegacyGroup, Server},
|
||||||
minecraft::{protocol::legacy_v1_6::LegacyV1_6, JavaResponse, LegacyGroup, Server},
|
protocols::types::TimeoutSettings,
|
||||||
types::TimeoutSettings,
|
|
||||||
},
|
|
||||||
socket::{Socket, TcpSocket},
|
socket::{Socket, TcpSocket},
|
||||||
utils::{error_by_expected_size, retry_on_timeout},
|
utils::{error_by_expected_size, retry_on_timeout},
|
||||||
GDErrorKind::{PacketBad, ProtocolFormat},
|
GDErrorKind::{PacketBad, ProtocolFormat},
|
||||||
|
|
@ -2,10 +2,8 @@ use byteorder::BigEndian;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::{Buffer, Utf16Decoder},
|
buffer::{Buffer, Utf16Decoder},
|
||||||
protocols::{
|
games::minecraft::{JavaResponse, LegacyGroup, Server},
|
||||||
minecraft::{JavaResponse, LegacyGroup, Server},
|
protocols::types::TimeoutSettings,
|
||||||
types::TimeoutSettings,
|
|
||||||
},
|
|
||||||
socket::{Socket, TcpSocket},
|
socket::{Socket, TcpSocket},
|
||||||
utils::{error_by_expected_size, retry_on_timeout},
|
utils::{error_by_expected_size, retry_on_timeout},
|
||||||
GDErrorKind::{PacketBad, ProtocolFormat},
|
GDErrorKind::{PacketBad, ProtocolFormat},
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::{Buffer, Utf16Decoder},
|
buffer::{Buffer, Utf16Decoder},
|
||||||
protocols::{
|
games::minecraft::{JavaResponse, LegacyGroup, Server},
|
||||||
minecraft::{JavaResponse, LegacyGroup, Server},
|
protocols::types::TimeoutSettings,
|
||||||
types::TimeoutSettings,
|
|
||||||
},
|
|
||||||
socket::{Socket, TcpSocket},
|
socket::{Socket, TcpSocket},
|
||||||
utils::{error_by_expected_size, retry_on_timeout},
|
utils::{error_by_expected_size, retry_on_timeout},
|
||||||
GDErrorKind::{PacketBad, ProtocolFormat},
|
GDErrorKind::{PacketBad, ProtocolFormat},
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::protocols::minecraft::types::RequestSettings;
|
use crate::games::minecraft::types::RequestSettings;
|
||||||
use crate::{
|
use crate::{
|
||||||
protocols::minecraft::{
|
games::minecraft::{
|
||||||
protocol::{
|
protocol::{
|
||||||
bedrock::Bedrock,
|
bedrock::Bedrock,
|
||||||
java::Java,
|
java::Java,
|
||||||
|
|
@ -293,3 +293,13 @@ pub(crate) fn as_string(value: &str) -> GDResult<Vec<u8>> {
|
||||||
|
|
||||||
Ok(buf)
|
Ok(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(tests)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn test_extra_request_settings() {
|
||||||
|
let settings = ExtraRequestSettings::default();
|
||||||
|
|
||||||
|
let _: minecraft::RequestSettings = settings.clone().into();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -89,32 +89,6 @@ pub fn query_with_timeout_and_extra_settings(
|
||||||
)
|
)
|
||||||
.map(Box::new)?
|
.map(Box::new)?
|
||||||
}
|
}
|
||||||
Protocol::Minecraft(version) => {
|
|
||||||
match version {
|
|
||||||
Some(protocols::minecraft::Server::Java) => {
|
|
||||||
protocols::minecraft::query_java(
|
|
||||||
&socket_addr,
|
|
||||||
timeout_settings,
|
|
||||||
extra_settings.map(ExtraRequestSettings::into),
|
|
||||||
)
|
|
||||||
.map(Box::new)?
|
|
||||||
}
|
|
||||||
Some(protocols::minecraft::Server::Bedrock) => {
|
|
||||||
protocols::minecraft::query_bedrock(&socket_addr, timeout_settings).map(Box::new)?
|
|
||||||
}
|
|
||||||
Some(protocols::minecraft::Server::Legacy(group)) => {
|
|
||||||
protocols::minecraft::query_legacy_specific(*group, &socket_addr, timeout_settings).map(Box::new)?
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
protocols::minecraft::query(
|
|
||||||
&socket_addr,
|
|
||||||
timeout_settings,
|
|
||||||
extra_settings.map(ExtraRequestSettings::into),
|
|
||||||
)
|
|
||||||
.map(Box::new)?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Protocol::Gamespy(version) => {
|
Protocol::Gamespy(version) => {
|
||||||
match version {
|
match version {
|
||||||
GameSpyVersion::One => protocols::gamespy::one::query(&socket_addr, timeout_settings).map(Box::new)?,
|
GameSpyVersion::One => protocols::gamespy::one::query(&socket_addr, timeout_settings).map(Box::new)?,
|
||||||
|
|
@ -148,6 +122,33 @@ pub fn query_with_timeout_and_extra_settings(
|
||||||
}
|
}
|
||||||
ProprietaryProtocol::FFOW => ffow::query_with_timeout(address, port, timeout_settings).map(Box::new)?,
|
ProprietaryProtocol::FFOW => ffow::query_with_timeout(address, port, timeout_settings).map(Box::new)?,
|
||||||
ProprietaryProtocol::JC2M => jc2m::query_with_timeout(address, port, timeout_settings).map(Box::new)?,
|
ProprietaryProtocol::JC2M => jc2m::query_with_timeout(address, port, timeout_settings).map(Box::new)?,
|
||||||
|
ProprietaryProtocol::Minecraft(version) => {
|
||||||
|
match version {
|
||||||
|
Some(minecraft::Server::Java) => {
|
||||||
|
minecraft::protocol::query_java(
|
||||||
|
&socket_addr,
|
||||||
|
timeout_settings,
|
||||||
|
extra_settings.map(ExtraRequestSettings::into),
|
||||||
|
)
|
||||||
|
.map(Box::new)?
|
||||||
|
}
|
||||||
|
Some(minecraft::Server::Bedrock) => {
|
||||||
|
minecraft::protocol::query_bedrock(&socket_addr, timeout_settings).map(Box::new)?
|
||||||
|
}
|
||||||
|
Some(minecraft::Server::Legacy(group)) => {
|
||||||
|
minecraft::protocol::query_legacy_specific(*group, &socket_addr, timeout_settings)
|
||||||
|
.map(Box::new)?
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
minecraft::protocol::query(
|
||||||
|
&socket_addr,
|
||||||
|
timeout_settings,
|
||||||
|
extra_settings.map(ExtraRequestSettings::into),
|
||||||
|
)
|
||||||
|
.map(Box::new)?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
/// The implementation.
|
|
||||||
pub mod protocol;
|
|
||||||
/// All types used by the implementation.
|
|
||||||
pub mod types;
|
|
||||||
|
|
||||||
pub use protocol::*;
|
|
||||||
pub use types::*;
|
|
||||||
|
|
@ -6,8 +6,6 @@
|
||||||
|
|
||||||
/// Reference: [node-GameDig](https://github.com/gamedig/node-gamedig/blob/master/protocols/gamespy1.js)
|
/// Reference: [node-GameDig](https://github.com/gamedig/node-gamedig/blob/master/protocols/gamespy1.js)
|
||||||
pub mod gamespy;
|
pub mod gamespy;
|
||||||
/// Reference: [Server List Ping](https://wiki.vg/Server_List_Ping)
|
|
||||||
pub mod minecraft;
|
|
||||||
/// Reference: [node-GameDig](https://github.com/gamedig/node-gamedig/blob/master/protocols/quake1.js)
|
/// Reference: [node-GameDig](https://github.com/gamedig/node-gamedig/blob/master/protocols/quake1.js)
|
||||||
pub mod quake;
|
pub mod quake;
|
||||||
/// General types that are used by all protocols.
|
/// General types that are used by all protocols.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::protocols::{gamespy, minecraft, quake, unreal2, valve};
|
use crate::protocols::{gamespy, quake, unreal2, valve};
|
||||||
use crate::GDErrorKind::InvalidInput;
|
use crate::GDErrorKind::InvalidInput;
|
||||||
use crate::GDResult;
|
use crate::{minecraft, GDResult};
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
|
@ -12,6 +12,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub enum ProprietaryProtocol {
|
pub enum ProprietaryProtocol {
|
||||||
TheShip,
|
TheShip,
|
||||||
|
Minecraft(Option<minecraft::types::Server>),
|
||||||
FFOW,
|
FFOW,
|
||||||
JC2M,
|
JC2M,
|
||||||
}
|
}
|
||||||
|
|
@ -21,7 +22,6 @@ pub enum ProprietaryProtocol {
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum Protocol {
|
pub enum Protocol {
|
||||||
Gamespy(gamespy::GameSpyVersion),
|
Gamespy(gamespy::GameSpyVersion),
|
||||||
Minecraft(Option<minecraft::types::Server>),
|
|
||||||
Quake(quake::QuakeVersion),
|
Quake(quake::QuakeVersion),
|
||||||
Valve(valve::Engine),
|
Valve(valve::Engine),
|
||||||
Unreal2,
|
Unreal2,
|
||||||
|
|
@ -33,11 +33,12 @@ pub enum Protocol {
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum GenericResponse<'a> {
|
pub enum GenericResponse<'a> {
|
||||||
GameSpy(gamespy::VersionedResponse<'a>),
|
GameSpy(gamespy::VersionedResponse<'a>),
|
||||||
Minecraft(minecraft::VersionedResponse<'a>),
|
|
||||||
Quake(quake::VersionedResponse<'a>),
|
Quake(quake::VersionedResponse<'a>),
|
||||||
Valve(&'a valve::Response),
|
Valve(&'a valve::Response),
|
||||||
Unreal2(&'a unreal2::Response),
|
Unreal2(&'a unreal2::Response),
|
||||||
#[cfg(feature = "games")]
|
#[cfg(feature = "games")]
|
||||||
|
Minecraft(minecraft::VersionedResponse<'a>),
|
||||||
|
#[cfg(feature = "games")]
|
||||||
TheShip(&'a crate::games::theship::Response),
|
TheShip(&'a crate::games::theship::Response),
|
||||||
#[cfg(feature = "games")]
|
#[cfg(feature = "games")]
|
||||||
FFOW(&'a crate::games::ffow::Response),
|
FFOW(&'a crate::games::ffow::Response),
|
||||||
|
|
@ -51,10 +52,11 @@ pub enum GenericPlayer<'a> {
|
||||||
Valve(&'a valve::ServerPlayer),
|
Valve(&'a valve::ServerPlayer),
|
||||||
QuakeOne(&'a quake::one::Player),
|
QuakeOne(&'a quake::one::Player),
|
||||||
QuakeTwo(&'a quake::two::Player),
|
QuakeTwo(&'a quake::two::Player),
|
||||||
Minecraft(&'a minecraft::Player),
|
|
||||||
Gamespy(gamespy::VersionedPlayer<'a>),
|
Gamespy(gamespy::VersionedPlayer<'a>),
|
||||||
Unreal2(&'a unreal2::Player),
|
Unreal2(&'a unreal2::Player),
|
||||||
#[cfg(feature = "games")]
|
#[cfg(feature = "games")]
|
||||||
|
Minecraft(&'a minecraft::Player),
|
||||||
|
#[cfg(feature = "games")]
|
||||||
TheShip(&'a crate::games::theship::TheShipPlayer),
|
TheShip(&'a crate::games::theship::TheShipPlayer),
|
||||||
#[cfg(feature = "games")]
|
#[cfg(feature = "games")]
|
||||||
JCMP2(&'a crate::games::jc2m::Player),
|
JCMP2(&'a crate::games::jc2m::Player),
|
||||||
|
|
@ -238,7 +240,8 @@ impl Default for TimeoutSettings {
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// Create minecraft settings with builder:
|
/// Create minecraft settings with builder:
|
||||||
/// ```
|
/// ```
|
||||||
/// use gamedig::protocols::{minecraft, ExtraRequestSettings};
|
/// use gamedig::games::minecraft;
|
||||||
|
/// use gamedig::protocols::ExtraRequestSettings;
|
||||||
/// let mc_settings: minecraft::RequestSettings = ExtraRequestSettings::default().set_hostname("mc.hypixel.net".to_string()).into();
|
/// let mc_settings: minecraft::RequestSettings = ExtraRequestSettings::default().set_hostname("mc.hypixel.net".to_string()).into();
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
@ -362,7 +365,6 @@ mod tests {
|
||||||
fn test_extra_request_settings() {
|
fn test_extra_request_settings() {
|
||||||
let settings = ExtraRequestSettings::default();
|
let settings = ExtraRequestSettings::default();
|
||||||
|
|
||||||
let _: minecraft::RequestSettings = settings.clone().into();
|
|
||||||
let _: valve::GatheringSettings = settings.into();
|
let _: valve::GatheringSettings = settings.into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue