Redlist 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/redlist.rb +44 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 89ba9d36afee0f87c753cd487128d4d6bcf4fd99
|
4
|
+
data.tar.gz: 6f021c980564980531804aadb39d9add64b2f389
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f90169aa9ccaa5491dd82a604703cae6ca86c6fbe5b3eb9d1ea22a0ec7ccb5f278340544eeeceb4c9f0e12982a337dc0908a06a5587f009743ad4396f43311da
|
7
|
+
data.tar.gz: 9e416ae46d8b6515752fd0eb910565a1b8c89d9fc01658ecde06d2eed87cfa4b341abcc576afe8e04e811e26a7907ecc01c79e5ad85ee744d40cf2494ae27aaa
|
data/lib/redlist.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'rest-client'
|
3
|
+
require 'rcon/rcon'
|
4
|
+
require 'minecraft-query'
|
5
|
+
module Redlist
|
6
|
+
def self.add(whitelistPath, _username, rconPassword, rconIP = '127.0.0.1', rconPort = '25575')
|
7
|
+
whitelist = JSON.parse(File.read(whitelistPath))
|
8
|
+
shouldUpdateList = true
|
9
|
+
whitelist.each do |line|
|
10
|
+
shouldUpdateList = false if line['name'] == _username
|
11
|
+
end
|
12
|
+
|
13
|
+
if shouldUpdateList == true
|
14
|
+
|
15
|
+
res = RestClient.post 'https://api.mojang.com/profiles/minecraft',
|
16
|
+
_username.to_json,
|
17
|
+
content_type: :json,
|
18
|
+
accept: :json
|
19
|
+
|
20
|
+
result = JSON.parse res
|
21
|
+
if res.code == 200 && !result[0].nil? && !result.nil?
|
22
|
+
whitelist << { 'uuid' => result[0]['id'], 'name' => result[0]['name'] }
|
23
|
+
File.open(whitelistPath, 'w') do |f|
|
24
|
+
f.write(whitelist.to_json)
|
25
|
+
end
|
26
|
+
updateList(rconPassword, rconIP, rconPort)
|
27
|
+
return 'Username added to list.'
|
28
|
+
else
|
29
|
+
return 'Unable to add user to list. Check username, or internet connection. '
|
30
|
+
end
|
31
|
+
|
32
|
+
else
|
33
|
+
updateList(rconPassword, rconIP, rconPort)
|
34
|
+
return 'Username already on list'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.updateList(_rconPassword, _rconIP, _rconPort)
|
39
|
+
rcon = RCON::Minecraft.new(_rconIP, _rconPort)
|
40
|
+
rcon.auth(_rconPassword)
|
41
|
+
output = rcon.command('whitelist reload')
|
42
|
+
output
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Redlist
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Keaton Burleson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A gem which adds a Minecraft player to a whitelist, useful for automated
|
14
|
+
applications.
|
15
|
+
email:
|
16
|
+
- keaton.burleson@me.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/redlist.rb
|
22
|
+
homepage: https://github.com/128keaton/Redlist
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.5.1
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: A gem which adds a Minecraft player to a whitelist.
|
46
|
+
test_files: []
|