fishbans 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/block_engine.rb +42 -0
- data/lib/fishbans.rb +10 -2
- data/lib/player_skins.rb +45 -0
- metadata +25 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fdccbe25f25cc750106b8bddd7f5a160918df97
|
4
|
+
data.tar.gz: eb98194d6ad4d4a1a9528f1a00ba10696ec0e308
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7035bb24577060be3cc5b81db32a140b54caab32378247751d0e94a6ba542bd55d30d41ddf56460a8f2c3f624b6b0abc7f50cbb68cd15c5f9c8217df6ff58fe8
|
7
|
+
data.tar.gz: adb94c0aa95e11935a201ea570a3ac57271ea81c828684f48cc06cf65dadbb16bc8eb45e4cb8f6c0da3779f31bc543d11d8e4804db9e8c3c0bd7cb318371088d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
## Version 1
|
3
|
+
### Version 1.1.0
|
4
|
+
* New PlayerSkins module, including methods for getting player faces, fronts, and skins.
|
5
|
+
* New BlockEngine module, including methods for getting 3D block images, 2D monster face images, and 3D full monster images.
|
6
|
+
|
3
7
|
### Version 1.0.1
|
4
8
|
* Fix NoMethodError with get
|
5
9
|
|
data/lib/block_engine.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'chunky_png'
|
2
|
+
require_relative 'fishbans'
|
3
|
+
|
4
|
+
module Fishbans
|
5
|
+
module BlockEngine
|
6
|
+
# Gets a block image by its ID and Metadata. Unfortunately it uses the old
|
7
|
+
# block IDs rather than the new ones, so you have to memorize those
|
8
|
+
# pesky integers.
|
9
|
+
# @param id [Fixnum] The (outdated) block ID number.
|
10
|
+
# @param metadata [Fixnum] The metadata, if any, for the block.
|
11
|
+
# @param size [Fixnum] The size of the image to get.
|
12
|
+
# @return [ChunkyPNG::Image] The ChunkyPNG instance of that block image.
|
13
|
+
def get_block(id, metadata = nil, size = 42)
|
14
|
+
url = "http://blocks.fishbans.com/#{id}"
|
15
|
+
url += "-#{metadata}" unless metadata.nil?
|
16
|
+
url += "/#{size}" if size != 42
|
17
|
+
response = get(url, false)
|
18
|
+
ChunkyPNG::Image.from_blob(response.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Gets the monster image by its ID.
|
22
|
+
# @param id [Any] The string ID. It will automatically prefix it with "m" if
|
23
|
+
# that is omitted. It doesn't matter what type it is: String or Fixnum,
|
24
|
+
# because it will automatically convert it to a String.
|
25
|
+
# @param three [Boolean] Whether to get a three-dimensional monster image.
|
26
|
+
# The three-dimensional image is of the full monster, while the
|
27
|
+
# two-dimensional image is just its head.
|
28
|
+
# @param size [Fixnum] The size of the image (width) to get. For 3D images
|
29
|
+
# this will not be perfect just by nature of the API.
|
30
|
+
# @return [ChunkyPNG::Image] The ChunkyPNG instance of that monster image.
|
31
|
+
def get_monster(id, three = false, size = 42)
|
32
|
+
id = id.to_s unless id.is_a?(String)
|
33
|
+
url = 'http://blocks.fishbans.com'
|
34
|
+
url += "/#{id}" if id =~ /^m/
|
35
|
+
url += "/m#{id}" if id !~ /^m/
|
36
|
+
url += '-3d' if three
|
37
|
+
url += "/#{size}" if size != 42
|
38
|
+
response = get(url, false)
|
39
|
+
ChunkyPNG::Image.from_blob(response.body)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/fishbans.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'httpclient'
|
2
2
|
require 'json'
|
3
|
+
require_relative 'block_engine'
|
4
|
+
require_relative 'player_skins'
|
3
5
|
|
4
6
|
module Fishbans
|
7
|
+
include BlockEngine
|
8
|
+
include PlayerSkins
|
9
|
+
|
5
10
|
extend self
|
6
11
|
@client = HTTPClient.new
|
7
12
|
@services = [
|
@@ -109,13 +114,16 @@ module Fishbans
|
|
109
114
|
end
|
110
115
|
|
111
116
|
private
|
117
|
+
|
112
118
|
# Performs a basic GET request.
|
113
119
|
# @param url [String] The URL to get.
|
120
|
+
# @param do_json [Boolean] Whether to parse the JSON.
|
114
121
|
# @return [JSON/String] The parsed JSON of the response, or the error string.
|
115
|
-
def get(url)
|
122
|
+
def get(url, do_json = true)
|
116
123
|
url = URI.encode(url)
|
117
124
|
uri = URI.parse(url)
|
118
125
|
response = @client.get(uri)
|
126
|
+
return response if do_json == false
|
119
127
|
json = JSON.parse(response.body)
|
120
128
|
if json['success']
|
121
129
|
return json
|
@@ -141,6 +149,6 @@ module Fishbans
|
|
141
149
|
end
|
142
150
|
|
143
151
|
return nil if ret.empty?
|
144
|
-
|
152
|
+
ret
|
145
153
|
end
|
146
154
|
end
|
data/lib/player_skins.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'chunky_png'
|
2
|
+
require_relative 'fishbans'
|
3
|
+
|
4
|
+
module Fishbans
|
5
|
+
module PlayerSkins
|
6
|
+
# Gets the image for the front face of the player head.
|
7
|
+
# @param username [String] The username to get the head of.
|
8
|
+
# @param size [Fixnum] The width of the image to get.
|
9
|
+
# @return [ChunkyPNG::Image] The ChunkyPNG::Image instance of that head.
|
10
|
+
def get_player_head(username, size = 100)
|
11
|
+
get_player_image(username, 'helm', size)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Gets the image for the entire front of the player.
|
15
|
+
# @param username [String] See #get_player_head.
|
16
|
+
# @param size [Fixnum] See #get_player_head.
|
17
|
+
# @return [ChunkyPNG::Image] The ChunkyPNG::Image instance of that front.
|
18
|
+
def get_player_front(username, size = 100)
|
19
|
+
get_player_image(username, 'player', size)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Gets the image for the player's raw skin.
|
23
|
+
# @param username [String] See #get_player_head.
|
24
|
+
# @param size [Fixnum] See #get_player_head.
|
25
|
+
# @return [ChunkyPNG::Image] The ChunkyPNG::Image instance of that skin.
|
26
|
+
def get_player_skin(username, size = 64)
|
27
|
+
get_player_image(username, 'skin', size)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Gets the player image for the type.
|
33
|
+
# @param username [String] See #get_player_head.
|
34
|
+
# @param type [String] The type of image to get. Can be 'helm', 'player', or
|
35
|
+
# 'skin' as defined by the Fishbans Player Skins API.
|
36
|
+
# @param size [Fixnum] See #get_player_head.
|
37
|
+
# @return [ChunkyPNG::Image] The ChunkyPNG::Image instance for the params.
|
38
|
+
def get_player_image(username, type, size)
|
39
|
+
type.downcase
|
40
|
+
url = "http://i.fishbans.com/#{type}/#{username}/#{size}"
|
41
|
+
response = get(url, false)
|
42
|
+
ChunkyPNG::Image.from_blob(response.body)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,38 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fishbans
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Foster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.6.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.6.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: chunky_png
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.3.5
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.3.5
|
27
41
|
description: Accessing the Fishbans Minecraft API through HTTPClient. Has methods
|
28
|
-
for all Fishban APIs
|
42
|
+
for all Fishban APIs, including the APIs for getting block, monster, and player
|
43
|
+
images.
|
29
44
|
email: elifosterwy@gmail.com
|
30
45
|
executables: []
|
31
46
|
extensions: []
|
32
47
|
extra_rdoc_files: []
|
33
48
|
files:
|
34
49
|
- CHANGELOG.md
|
50
|
+
- lib/block_engine.rb
|
35
51
|
- lib/fishbans.rb
|
52
|
+
- lib/player_skins.rb
|
36
53
|
homepage: https://github.com/elifoster/fishbans-rb
|
37
54
|
licenses:
|
38
55
|
- CC-BY-NC-ND-4.0
|
@@ -59,3 +76,4 @@ signing_key:
|
|
59
76
|
specification_version: 4
|
60
77
|
summary: A Ruby gem for accessing the Fishbans Minecraft API.
|
61
78
|
test_files: []
|
79
|
+
has_rdoc:
|