minestat 2.2.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +8 -0
  3. data/ChangeLog.md +55 -0
  4. data/License.txt +674 -0
  5. data/ReadMe.md +60 -0
  6. data/example.rb +18 -0
  7. data/lib/minestat.rb +425 -171
  8. metadata +16 -8
data/ReadMe.md ADDED
@@ -0,0 +1,60 @@
1
+ MineStat
2
+ ========
3
+
4
+ ### About
5
+
6
+ MineStat is a Minecraft server status checker.
7
+
8
+ You can use these classes/modules in a monitoring script to poll multiple Minecraft servers, include similar functionality in a Discord bot, or to let
9
+ visitors see the status of your server from their browser. MineStat has been ported to multiple languages for use with ASP.NET, FastCGI, mod_perl,
10
+ mod_php, mod_python, Node.js, Rails, Tomcat, and more.
11
+
12
+ ### Installation
13
+
14
+ To install the gem: `gem install minestat`
15
+
16
+ ### Example
17
+
18
+ ```ruby
19
+ require 'minestat'
20
+
21
+ ms = MineStat.new("minecraft.frag.land", 25565)
22
+ puts "Minecraft server status of #{ms.address} on port #{ms.port}:"
23
+ if ms.online
24
+ puts "Server is online running version #{ms.version} with #{ms.current_players} out of #{ms.max_players} players."
25
+ puts "Game mode: #{ms.mode}" if ms.mode
26
+ puts "Message of the day: #{ms.motd}"
27
+ puts "Message of the day without formatting: #{ms.stripped_motd}"
28
+ puts "Latency: #{ms.latency}ms"
29
+ puts "Connected using protocol: #{ms.request_type}"
30
+ else
31
+ puts "Server is offline!"
32
+ end
33
+ ```
34
+
35
+ ### Constructor Arguments
36
+
37
+ To simply connect to an address:
38
+ ```ruby
39
+ ms = MineStat.new("minecraft.frag.land")
40
+ ```
41
+ Connect to an address on a certain TCP or UDP port:
42
+ ```ruby
43
+ ms = MineStat.new("minecraft.frag.land", 25567)
44
+ ```
45
+ Same as above example and additionally includes a timeout in seconds:
46
+ ```ruby
47
+ ms = MineStat.new("minecraft.frag.land", 25567, 3)
48
+ ```
49
+ Same as above example and additionally includes an explicit protocol to use:
50
+ ```ruby
51
+ ms = MineStat.new("minecraft.frag.land", 25567, 3, MineStat::Request::QUERY)
52
+ ```
53
+ Connect to a Bedrock server and enable debug mode:
54
+ ```ruby
55
+ ms = MineStat.new("minecraft.frag.land", 19132, 3, MineStat::Request::BEDROCK, true)
56
+ ```
57
+
58
+ ### Support
59
+ * Discord: https://discord.frag.land
60
+ * GitHub: https://github.com/FragLand/minestat
data/example.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'minestat'
2
+
3
+ # Below is an example using the MineStat class.
4
+ # If server is offline, other instance members will be nil.
5
+ ms = MineStat.new("minecraft.frag.land")
6
+ # Bedrock/Pocket Edition explicit query example with debug enabled
7
+ #ms = MineStat.new("minecraft.frag.land", 19132, 5, MineStat::Request::BEDROCK, true)
8
+ puts "Minecraft server status of #{ms.address} on port #{ms.port}:"
9
+ if ms.online
10
+ puts "Server is online running version #{ms.version} with #{ms.current_players} out of #{ms.max_players} players."
11
+ puts "Game mode: #{ms.mode}" if ms.mode
12
+ puts "Message of the day: #{ms.motd}"
13
+ puts "Message of the day without formatting: #{ms.stripped_motd}"
14
+ puts "Latency: #{ms.latency}ms"
15
+ puts "Connected using protocol: #{ms.request_type}"
16
+ else
17
+ puts "Server is offline!"
18
+ end