mojang 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/errors.rb +1 -1
- data/lib/mojang.rb +7 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2955c17e484341fe800541d53d9464796b9699954956cc3c834040022d541e62
|
4
|
+
data.tar.gz: 59d3d6cf56987bef1c0ee6fd1b85cfed18bb93c3fdabf7a1a7ef71378b8d0aae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 066bf06261ee40c316bb1cd77b92cf52ce737eb285900fdf57ea34c9d3f47babe8d8c297e671543f0767d335484ce56281bb2fe20f9717eb0c61f8a89142adee
|
7
|
+
data.tar.gz: 4253a83f9ceae4f18b8dc5fe1bf4ec77df0b41e622d165f295e010061907bc11dffd262ba68e827ad61f3f869ad143d80bcdcb05baa6fea4dfc6bc74b1278b85
|
data/lib/errors.rb
CHANGED
data/lib/mojang.rb
CHANGED
@@ -26,8 +26,9 @@ module Mojang
|
|
26
26
|
# @param username [String] The username.
|
27
27
|
# @param date [Date] The date to get the ID at.
|
28
28
|
# @return [String] The username's user ID.
|
29
|
+
# @raise [Mojang::Errors::MojangError]
|
30
|
+
# @raise [Mojang::Errors::NoSuchUserError]
|
29
31
|
def userid(username, date = nil)
|
30
|
-
self.profile(username, date, 'id')
|
31
32
|
profile_str = "https://api.mojang.com/users/profiles/minecraft/#{username}"
|
32
33
|
# If the provided date (or 0, if not provided) does not return anything, try without any date provided at all.
|
33
34
|
# This is necessary because for users with name history's *have* you have to provide some date (and 0 is valid),
|
@@ -35,7 +36,7 @@ module Mojang
|
|
35
36
|
# If it is *still* empty after both tries, then error.
|
36
37
|
response = Curl.get(profile_str, { at: date.to_i }).body_str
|
37
38
|
response = Curl.get(profile_str).body_str if response.empty?
|
38
|
-
fail NoSuchUserError.new(
|
39
|
+
fail Mojang::Errors::NoSuchUserError.new(username) if response.empty?
|
39
40
|
json = Oj.load(response)
|
40
41
|
if json.key?('error')
|
41
42
|
fail Mojang::Errors::MojangError.new(json['error'], json['errorMessage'])
|
@@ -48,9 +49,13 @@ module Mojang
|
|
48
49
|
# @param uuid [String] The user's ID (see #{userid}).
|
49
50
|
# @return [Hash<Symbol/Time, String>] A hash of all the names. Key is either :original, or the Time object of when
|
50
51
|
# the name was changed. Value is always the name at that point in time.
|
52
|
+
# @raise [Mojang::Errors::MojangError]
|
51
53
|
def name_history(uuid)
|
52
54
|
response = Curl.get("https://api.mojang.com/user/profiles/#{uuid}/names").body_str
|
53
55
|
json = Oj.load(response)
|
56
|
+
if json.key?('error')
|
57
|
+
fail Mojang::Errors::MojangError.new(json['error'], json['errorMessage'])
|
58
|
+
end
|
54
59
|
ret = {}
|
55
60
|
json.each do |hash|
|
56
61
|
if hash.key?('changedToAt')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Foster
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curb
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
33
|
+
version: '3.11'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
40
|
+
version: '3.11'
|
41
41
|
description: A Ruby library accessing the Mojang and Minecraft web APIs
|
42
42
|
email: elifosterwy@gmail.com
|
43
43
|
executables: []
|
@@ -52,7 +52,7 @@ licenses:
|
|
52
52
|
- MIT
|
53
53
|
metadata:
|
54
54
|
issue_tracker: https://github.com/elifoster/mojang-rb/issues
|
55
|
-
post_install_message:
|
55
|
+
post_install_message:
|
56
56
|
rdoc_options: []
|
57
57
|
require_paths:
|
58
58
|
- lib
|
@@ -67,8 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
|
-
rubygems_version: 3.
|
71
|
-
signing_key:
|
70
|
+
rubygems_version: 3.2.3
|
71
|
+
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: Mojang and Minecraft web APIs in Ruby
|
74
74
|
test_files: []
|