mirror of
https://github.com/MinecraftServerControl/mscs.git
synced 2024-11-15 14:58:18 -07:00
query: merge queryDetailedStatus and querySendDetailedInformationPacket
This commit is contained in:
parent
a5b36880cc
commit
f224730d3f
@ -1512,56 +1512,6 @@ querySendInformationPacket() {
|
||||
printf "$RESPONSE\n"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Send a detailed information request packet to the Minecraft query server.
|
||||
#
|
||||
# @param 1 The world server of interest.
|
||||
# @param 2 The challenge token.
|
||||
# @return Tab separated values:
|
||||
# type - The packet type.
|
||||
# id - The packet identifier.
|
||||
# * - The string 'splitnum'.
|
||||
# * - The value 128.
|
||||
# * - The value 0.
|
||||
# * - The string 'hostname'.
|
||||
# MOTD - The world's message of the day.
|
||||
# * - The string 'gametype'.
|
||||
# gametype - The world's game type, hardcoded to 'SMP'.
|
||||
# * - The string 'game_id'.
|
||||
# gameid - The world's game ID, hardcoded to 'MINECRAFT'.
|
||||
# * - The string 'version'.
|
||||
# version - The world's Minecraft version.
|
||||
# * - The string 'plugins'.
|
||||
# plugins - The world's plugins.
|
||||
# * - The string 'map'.
|
||||
# map - The world's name.
|
||||
# * - The string 'numplayers'.
|
||||
# numplayers - The world's current number of players.
|
||||
# * - The string 'maxplayers'.
|
||||
# maxplayers - The world's maximum number of players.
|
||||
# * - The string 'hostport'.
|
||||
# hostport - The world's host port.
|
||||
# * - The string 'hostip'.
|
||||
# hostip - The world's host IP address.
|
||||
# * - The value 0.
|
||||
# * - The value 1.
|
||||
# * - The string 'player_'.
|
||||
# * - The value 0.
|
||||
# players - The players currently logged onto the world.
|
||||
# ---------------------------------------------------------------------------
|
||||
querySendDetailedInformationPacket() {
|
||||
local ID PACKET RESPONSE
|
||||
# The packet identifier.
|
||||
ID="00000001"
|
||||
# Use the challenge token for the packet, with the ID on the end.
|
||||
PACKET=$(printf "%.8x%s" $2 $ID)
|
||||
# Send the information request packet to the Minecraft query server.
|
||||
RESPONSE=$(querySendPacket "$1" "00" "$PACKET" \
|
||||
"Cl>Z*CCZ*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*CCZ*C(Z*)*")
|
||||
# Return the response.
|
||||
printf "$RESPONSE\n"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Send a status query to the Minecraft query server.
|
||||
#
|
||||
@ -1628,13 +1578,18 @@ queryStatus() {
|
||||
# players - The players currently logged onto the world.
|
||||
# ---------------------------------------------------------------------------
|
||||
queryDetailedStatus() {
|
||||
local TOKEN RESPONSE
|
||||
local CHALLENGE ID PACKET RESPONSE TOKEN
|
||||
if [ "$(getPropertiesValue $1 'enable-query')" = "true" ]; then
|
||||
# Send a challenge packet to the Minecraft query server.
|
||||
TOKEN=$(querySendChallengePacket $1 | cut -f 3)
|
||||
if [ -n "$TOKEN" ]; then
|
||||
# Send an information request packet to the Minecraft query server.
|
||||
RESPONSE=$(querySendDetailedInformationPacket $1 $TOKEN)
|
||||
CHALLENGE=$(querySendChallengePacket $1)
|
||||
ID=$(echo "$CHALLENGE" | cut -f 2)
|
||||
TOKEN=$(echo "$CHALLENGE" | cut -f 3)
|
||||
if [ -n "$ID" ] && [ -n "$TOKEN" ]; then
|
||||
# Use the challenge token for the packet, with the ID on the end.
|
||||
PACKET=$(printf "%.8x%.8x" $TOKEN $ID)
|
||||
# Send the information request packet to the Minecraft query server.
|
||||
RESPONSE=$(querySendPacket "$1" "00" "$PACKET" \
|
||||
"Cl>Z*CCZ*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*Z*CCZ*C(Z*)*")
|
||||
fi
|
||||
fi
|
||||
# Return the response.
|
||||
|
Loading…
Reference in New Issue
Block a user