MClib
This library provides a Ruby API to vanilla minecraft by watching the log file and parsing the lines out into native objects and registering callbacks on server events such as login, chat, warnings and more.
Supported Versions
Installation
Add this line to your application's Gemfile:
gem 'mclib'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mclib
Usage
require 'mclib'
# set your minecraft directory, we'll use this to find the log and json files
MCLib::set_mc_dir '/Users/Caleb/Documents/minecraft/'
watcher = MCLib::Watcher.new
watcher.on :all do |event|
puts 'This will always get called'
end
watcher.on :login do |user|
puts "#{user.username} logged in from #{user.ip} at coordinates #{user.coordinates}"
end
watcher.on :chat do |username, text|
puts "User #{username} said #{text}"
end
watcher.on :warning do |warning|
puts "Warning: #{warning}"
end
watcher.start
You can also fetch the whitelist, ops, banned ips, and players as a hash using the MCLib module
MCLib::ops
MCLib::whitelist
MCLib::banned_ips
MCLib::banned_players
Contributing
- Fork it ( https://github.com/C0deMaver1ck/mclib/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request