minecraft_rtoolkit 0.0.1
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 +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +62 -0
- data/Rakefile +9 -0
- data/lib/minecraft_rtoolkit/api.rb +51 -0
- data/lib/minecraft_rtoolkit/connection.rb +61 -0
- data/lib/minecraft_rtoolkit/version.rb +5 -0
- data/lib/minecraft_rtoolkit.rb +11 -0
- data/minecraft_rtoolkit.gemspec +23 -0
- data/spec/lib/minecraft_rtoolkit/connection_spec.rb +16 -0
- data/spec/lib/minecraft_rtoolkit_spec.rb +13 -0
- data/spec/spec_helper.rb +10 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1ccbda8073c9ba06517392d949e1720c6c071b91
|
4
|
+
data.tar.gz: 5c8ffc781eb895b0dc1ecbfb5f38c363734e363f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5cd756d699050a42cb4a90a9bcc1dc7251f750e03a1c71355112286f786321b1ac2e96bdb2ac78a075066820ced394acf74244e056e6526a661e060d74f9b203
|
7
|
+
data.tar.gz: de13cf505840a4f3012b16d8ad440a43ceae3d5132c0cbf13ce1955404920fb2e76985f77040104cc791ad591750ab631f86e663494ce4718ebb6fb3a32e972f
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Patrick Neff
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# MinecraftRtoolkit
|
2
|
+
|
3
|
+
A Simple API Wrapper for [Remote Toolkit](https://forums.bukkit.org/threads/admn-remotetoolkit-r10-a15-restarts-crash-detection-auto-saves-remote-console-1-7-2.674)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'minecraft_rtoolkit'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install minecraft_rtoolkit
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'minecraft_rtoolkit'
|
23
|
+
|
24
|
+
api = Minecraft::RToolkit.new(host: '127.0.0.1', port: 25561, user: 'admin', password: 'password')
|
25
|
+
|
26
|
+
#Hold server
|
27
|
+
api.stop
|
28
|
+
|
29
|
+
#Unhold server
|
30
|
+
api.start
|
31
|
+
|
32
|
+
#Restart server
|
33
|
+
api.restart
|
34
|
+
|
35
|
+
#Force restart server
|
36
|
+
api.force_restart
|
37
|
+
|
38
|
+
#Force stop server
|
39
|
+
api.force_stop
|
40
|
+
|
41
|
+
#Disable scheduled restarts
|
42
|
+
api.disable_restarts
|
43
|
+
|
44
|
+
#Enable scheduled restarts
|
45
|
+
api.enable_restarts
|
46
|
+
|
47
|
+
#Reschedule restart
|
48
|
+
api.reschedule_restart('1h 30m')
|
49
|
+
|
50
|
+
#Get RToolkit version
|
51
|
+
api.version
|
52
|
+
```
|
53
|
+
|
54
|
+
For more information visit the [RToolkit Wiki](http://drdanick.com/wiki/index.php?title=Legacy_Release_10_documentation#In-game_commands) and [Forum Post](https://forums.bukkit.org/threads/admn-remotetoolkit-r10-a15-restarts-crash-detection-auto-saves-remote-console-1-7-2.674)
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
1. Fork it ( https://github.com/[my-github-username]/minecraft_rtoolkit/fork )
|
59
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
62
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module Minecraft
|
2
|
+
module RToolkit
|
3
|
+
class API
|
4
|
+
def initialize(options={})
|
5
|
+
raise 'No username given' if options[:user].nil?
|
6
|
+
raise 'No password given' if options[:password].nil?
|
7
|
+
user = options[:user]
|
8
|
+
password = options[:password]
|
9
|
+
host = options[:host].nil? ? '127.0.0.1' : options[:host]
|
10
|
+
port = options[:port].nil? ? 25561 : options[:port]
|
11
|
+
@conn = Minecraft::RToolkit::Connection.new(user: user, password: password, host: host, port: port)
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
@conn.send 'unhold'
|
16
|
+
end
|
17
|
+
|
18
|
+
def stop
|
19
|
+
@conn.send 'hold'
|
20
|
+
end
|
21
|
+
|
22
|
+
def restart
|
23
|
+
@conn.send 'restart'
|
24
|
+
end
|
25
|
+
|
26
|
+
def enbale_restarts
|
27
|
+
@conn.send 'enbale'
|
28
|
+
end
|
29
|
+
|
30
|
+
def disable_restarts
|
31
|
+
@conn.send 'disable'
|
32
|
+
end
|
33
|
+
|
34
|
+
def force_stop
|
35
|
+
@conn.send 'forcestop'
|
36
|
+
end
|
37
|
+
|
38
|
+
def force_restart
|
39
|
+
@conn.send 'forcerestart'
|
40
|
+
end
|
41
|
+
|
42
|
+
def version
|
43
|
+
@conn.send 'version'
|
44
|
+
end
|
45
|
+
|
46
|
+
def reschedule_restart(time)
|
47
|
+
@conn.send "reschedule:#{time}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Minecraft
|
2
|
+
module RToolkit
|
3
|
+
class Connection
|
4
|
+
def initialize(options={})
|
5
|
+
@user = options[:user]
|
6
|
+
@password = options[:password]
|
7
|
+
@host = options[:host]
|
8
|
+
@port = options[:port]
|
9
|
+
@connection = nil
|
10
|
+
|
11
|
+
#define destructor
|
12
|
+
ObjectSpace.define_finalizer(self, method(:close))
|
13
|
+
end
|
14
|
+
|
15
|
+
def make_request(action)
|
16
|
+
"#{action.upcase}:#{@user}:#{@password}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def open
|
20
|
+
if @connection.nil?
|
21
|
+
@connection = UDPSocket.new()
|
22
|
+
@connection.connect(@host, @port)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def send(action)
|
27
|
+
open if @connection.nil?
|
28
|
+
unless @connection.nil?
|
29
|
+
begin
|
30
|
+
@connection.send(make_request(action), 0)
|
31
|
+
recieve
|
32
|
+
rescue
|
33
|
+
raise SocketError
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def recieve
|
39
|
+
unless @connection.nil?
|
40
|
+
begin
|
41
|
+
response = @connection.recvfrom(32)
|
42
|
+
case response[0]
|
43
|
+
when 'response:success' then true
|
44
|
+
when /^response:.*/ then false
|
45
|
+
else
|
46
|
+
response [0]
|
47
|
+
end
|
48
|
+
rescue
|
49
|
+
raise SocketError
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def close
|
55
|
+
unless @connection.nil?
|
56
|
+
@connection.close
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'minecraft_rtoolkit/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "minecraft_rtoolkit"
|
8
|
+
spec.version = Minecraft::RToolkit::VERSION
|
9
|
+
spec.authors = ["Patrick Neff"]
|
10
|
+
spec.email = ["odie86@gmail.com"]
|
11
|
+
spec.summary = %q{A simple API wrapper for RToolkit}
|
12
|
+
spec.description = %q{A simple API wrapper for RToolkit (https://forums.bukkit.org/threads/admn-remotetoolkit-r10-a15-restarts-crash-detection-auto-saves-remote-console-1-7-2.674/)}
|
13
|
+
spec.homepage = "https://github.com/masterodie/minecraft_rtoolkit"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", ">= 10.0.0"
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../../spec_helper.rb'
|
2
|
+
|
3
|
+
describe Minecraft::RToolkit::Connection do
|
4
|
+
before do
|
5
|
+
@user = 'admin'
|
6
|
+
@password = 'password'
|
7
|
+
@conn = Minecraft::RToolkit::Connection.new(host: '10.10.0.10', port: 25561, user: @user, password: @password)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'make_request' do
|
11
|
+
it 'should return request string' do
|
12
|
+
str = 'start'
|
13
|
+
@conn.make_request(str).must_equal("#{str.upcase}:#{@user}:#{@password}")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative '../spec_helper.rb'
|
2
|
+
|
3
|
+
describe Minecraft::RToolkit do
|
4
|
+
describe 'shortcut' do
|
5
|
+
before do
|
6
|
+
@api = Minecraft::RToolkit.new(host: '10.10.0.10', port: 25561, user: 'admin', password: 'password')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should work' do
|
10
|
+
@api.must_be_instance_of Minecraft::RToolkit::API
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minecraft_rtoolkit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Patrick Neff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 10.0.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 10.0.0
|
41
|
+
description: A simple API wrapper for RToolkit (https://forums.bukkit.org/threads/admn-remotetoolkit-r10-a15-restarts-crash-detection-auto-saves-remote-console-1-7-2.674/)
|
42
|
+
email:
|
43
|
+
- odie86@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/minecraft_rtoolkit.rb
|
54
|
+
- lib/minecraft_rtoolkit/api.rb
|
55
|
+
- lib/minecraft_rtoolkit/connection.rb
|
56
|
+
- lib/minecraft_rtoolkit/version.rb
|
57
|
+
- minecraft_rtoolkit.gemspec
|
58
|
+
- spec/lib/minecraft_rtoolkit/connection_spec.rb
|
59
|
+
- spec/lib/minecraft_rtoolkit_spec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
homepage: https://github.com/masterodie/minecraft_rtoolkit
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.2.2
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: A simple API wrapper for RToolkit
|
85
|
+
test_files:
|
86
|
+
- spec/lib/minecraft_rtoolkit/connection_spec.rb
|
87
|
+
- spec/lib/minecraft_rtoolkit_spec.rb
|
88
|
+
- spec/spec_helper.rb
|