minestat 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/minestat.rb +30 -3
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: affbc3d1ec0778e630ea341dbd8afcf5f79a907f2da08554703f4b52d6f7f553
|
4
|
+
data.tar.gz: c65a8af83bc4c81695892c3447480ccde9fc731bab00e28ac7700012b7203341
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62da41df1030d258d4f72ac64c9d4e8f882372e43c2a342712e48b75e016634076ac4537a928e5631ed61448df1e35210e697e0c9dd1023032079e9b6bfb0d54
|
7
|
+
data.tar.gz: f442d1bbe7a625d5ae7eb665da4caf6612465abbb83e031a1ea010e6aa3f7aa0b41c8b74da15f2e06a987702ac440091dd3495701864c2682d0a5b72cf492281
|
data/lib/minestat.rb
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
17
17
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
18
18
|
|
19
|
+
require 'base64'
|
19
20
|
require 'json'
|
20
21
|
require 'socket'
|
21
22
|
require 'timeout'
|
@@ -24,7 +25,7 @@ require 'timeout'
|
|
24
25
|
# Provides a ruby interface for polling Minecraft server status.
|
25
26
|
class MineStat
|
26
27
|
# MineStat version
|
27
|
-
VERSION = "2.2.
|
28
|
+
VERSION = "2.2.2"
|
28
29
|
# Number of values expected from server
|
29
30
|
NUM_FIELDS = 6
|
30
31
|
# Number of values expected from a 1.8b/1.3 server
|
@@ -91,10 +92,13 @@ class MineStat
|
|
91
92
|
@max_players # maximum player capacity
|
92
93
|
@protocol # protocol level
|
93
94
|
@json_data # JSON data for 1.7 queries
|
95
|
+
@favicon_b64 # base64-encoded favicon possibly contained in JSON 1.7 responses
|
96
|
+
@favicon # decoded favicon data
|
94
97
|
@latency # ping time to server in milliseconds
|
95
98
|
@timeout = timeout # TCP/UDP timeout
|
96
99
|
@server # server socket
|
97
|
-
@request_type #
|
100
|
+
@request_type # protocol version
|
101
|
+
@connection_status # status of connection ("Success", "Fail", "Timeout", or "Unknown")
|
98
102
|
@try_all = false # try all protocols?
|
99
103
|
|
100
104
|
@try_all = true if request_type == Request::NONE
|
@@ -131,13 +135,22 @@ class MineStat
|
|
131
135
|
retval = json_request()
|
132
136
|
end
|
133
137
|
# Bedrock/Pocket Edition
|
134
|
-
unless retval == Retval::CONNFAIL
|
138
|
+
unless retval == Retval::SUCCESS || retval == Retval::CONNFAIL
|
135
139
|
retval = bedrock_request()
|
136
140
|
end
|
137
141
|
end
|
142
|
+
set_connection_status(retval)
|
138
143
|
@online = false unless retval == Retval::SUCCESS
|
139
144
|
end
|
140
145
|
|
146
|
+
# Sets connection status
|
147
|
+
def set_connection_status(retval)
|
148
|
+
@connection_status = "Success" if retval == Retval::SUCCESS
|
149
|
+
@connection_status = "Fail" if retval == Retval::CONNFAIL
|
150
|
+
@connection_status = "Timeout" if retval == Retval::TIMEOUT
|
151
|
+
@connection_status = "Unknown" if retval == Retval::UNKNOWN
|
152
|
+
end
|
153
|
+
|
141
154
|
# Strips message of the day formatting characters
|
142
155
|
def strip_motd()
|
143
156
|
unless @motd['text'] == nil
|
@@ -428,6 +441,11 @@ class MineStat
|
|
428
441
|
strip_motd
|
429
442
|
@current_players = json_data['players']['online'].to_i
|
430
443
|
@max_players = json_data['players']['max'].to_i
|
444
|
+
@favicon_b64 = json_data['favicon']
|
445
|
+
if !@favicon_b64.nil? && !@favicon_b64.empty?
|
446
|
+
@favicon_b64 = favicon_b64.split("base64,")[1]
|
447
|
+
@favicon = Base64.decode64(favicon_b64)
|
448
|
+
end
|
431
449
|
if !@version.empty? && !@motd.empty? && !@current_players.nil? && !@max_players.nil?
|
432
450
|
@online = true
|
433
451
|
else
|
@@ -569,12 +587,21 @@ class MineStat
|
|
569
587
|
# servers with a version greater than or equal to 1.7
|
570
588
|
attr_reader :json_data
|
571
589
|
|
590
|
+
# Returns the base64-encoded favicon from JSON 1.7 queries
|
591
|
+
attr_reader :favicon_b64
|
592
|
+
|
593
|
+
# Returns the decoded favicon from JSON 1.7 queries
|
594
|
+
attr_reader :favicon
|
595
|
+
|
572
596
|
# Returns the ping time to the server in ms
|
573
597
|
attr_reader :latency
|
574
598
|
|
575
599
|
# Returns the protocol version
|
576
600
|
attr_reader :request_type
|
577
601
|
|
602
|
+
# Returns the connection status
|
603
|
+
attr_reader :connection_status
|
604
|
+
|
578
605
|
# Returns whether or not all ping protocols should be attempted
|
579
606
|
attr_reader :try_all
|
580
607
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minestat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lloyd Dilley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: MineStat polls Minecraft server data such as version, motd, current players,
|
14
14
|
and max players.
|
@@ -38,8 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
|
-
|
42
|
-
rubygems_version: 2.5.2.1
|
41
|
+
rubygems_version: 3.2.5
|
43
42
|
signing_key:
|
44
43
|
specification_version: 4
|
45
44
|
summary: Minecraft server status checker
|