minecraft 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/minecraft +6 -0
- data/lib/minecraft.rb +6 -0
- data/lib/minecraft/data.rb +250 -0
- data/lib/minecraft/extensions.rb +72 -0
- data/lib/minecraft/server.rb +22 -0
- data/lib/minecraft/version.rb +3 -0
- data/minecraft.gemspec +19 -0
- metadata +66 -0
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/minecraft
ADDED
data/lib/minecraft.rb
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
module Minecraft
|
2
|
+
module Data
|
3
|
+
KITS = {
|
4
|
+
:diamond => [276, 277, 278, 279, 293],
|
5
|
+
:garmour => [314, 315, 316, 317],
|
6
|
+
:armour => [310, 311, 312, 313],
|
7
|
+
:ranged => [261, [262, 640]],
|
8
|
+
:nether => [261, [262, 320], [348, 128], 278, 276],
|
9
|
+
:portal => [[49, 10], 259]
|
10
|
+
}
|
11
|
+
|
12
|
+
DATA_VALUE_HASH = {
|
13
|
+
"glass" => "20",
|
14
|
+
"purple wool" => "35",
|
15
|
+
"obsidian" => "49",
|
16
|
+
"redstone ore" => "73",
|
17
|
+
"stone" => "1",
|
18
|
+
"lapis lazuli ore" => "21",
|
19
|
+
"blue wool" => "35",
|
20
|
+
"torch" => "50",
|
21
|
+
"glowing redstone ore" => "74",
|
22
|
+
"grass" => "2",
|
23
|
+
"lapis lazuli block" => "22",
|
24
|
+
"brown wool" => "35",
|
25
|
+
"fire" => "51",
|
26
|
+
"dirt" => "3",
|
27
|
+
"dispenser" => "23",
|
28
|
+
"dark green wool" => "35",
|
29
|
+
"monster spawner" => "52",
|
30
|
+
"cobblestone" => "4",
|
31
|
+
"sandstone" => "24",
|
32
|
+
"red wool" => "35",
|
33
|
+
"wooden stairs" => "53",
|
34
|
+
"stone button" => "77",
|
35
|
+
"wooden plank" => "5",
|
36
|
+
"note block" => "25",
|
37
|
+
"black wool" => "35",
|
38
|
+
"chest" => "54",
|
39
|
+
"snow" => "78",
|
40
|
+
"sapling" => "6",
|
41
|
+
"bed" => "355",
|
42
|
+
"yellow flower" => "37",
|
43
|
+
"redstone wire" => "55",
|
44
|
+
"ice" => "79",
|
45
|
+
"spruce sapling" => "6",
|
46
|
+
"powered rail" => "27",
|
47
|
+
"red rose" => "38",
|
48
|
+
"diamond ore" => "56",
|
49
|
+
"snow block" => "80",
|
50
|
+
"birch sapling" => "6",
|
51
|
+
"detector rail" => "28",
|
52
|
+
"brown mushroom" => "39",
|
53
|
+
"diamond block" => "57",
|
54
|
+
"cactus" => "81",
|
55
|
+
"bedrock" => "7",
|
56
|
+
"sticky piston" => "29",
|
57
|
+
"red mushroom" => "40",
|
58
|
+
"crafting table" => "58",
|
59
|
+
"clay block" => "82",
|
60
|
+
"water" => "8",
|
61
|
+
"cobweb" => "30",
|
62
|
+
"gold block" => "41",
|
63
|
+
"crops " => "59",
|
64
|
+
"sugar cane" => "338",
|
65
|
+
"stationary water" => "9",
|
66
|
+
"tall grass" => "31",
|
67
|
+
"iron block" => "42",
|
68
|
+
"farmland " => "60",
|
69
|
+
"jukebox" => "84",
|
70
|
+
"lava" => "10",
|
71
|
+
"dead shrubs" => "32",
|
72
|
+
"double stone slab" => "43",
|
73
|
+
"furnace " => "61",
|
74
|
+
"fence" => "85",
|
75
|
+
"stationary lava " => "11",
|
76
|
+
"piston" => "33",
|
77
|
+
"double sandstone slab" => "43",
|
78
|
+
"burning furnace" => "62",
|
79
|
+
"pumpkin" => "86",
|
80
|
+
"sand" => "12",
|
81
|
+
"white wool" => "35",
|
82
|
+
"double wooden slab" => "43",
|
83
|
+
"sign post" => "63",
|
84
|
+
"netherrack" => "87",
|
85
|
+
"gravel" => "13",
|
86
|
+
"orange wool" => "35",
|
87
|
+
"double cobblestone slab" => "43",
|
88
|
+
"wooden door" => "324",
|
89
|
+
"soul sand" => "88",
|
90
|
+
"gold ore" => "14",
|
91
|
+
"magenta wool" => "35",
|
92
|
+
"stone slab" => "44",
|
93
|
+
"ladder" => "65",
|
94
|
+
"glowstone" => "89",
|
95
|
+
"glowstone block" => "89",
|
96
|
+
"iron ore" => "15",
|
97
|
+
"light blue wool" => "35",
|
98
|
+
"sandstone slab" => "44",
|
99
|
+
"rails" => "66",
|
100
|
+
"portal" => "90",
|
101
|
+
"coal ore" => "16",
|
102
|
+
"yellow wool" => "35",
|
103
|
+
"wooden slab" => "44",
|
104
|
+
"cobblestone stairs" => "67",
|
105
|
+
"jack-o-lantern" => "91",
|
106
|
+
"jack o lantern" => "91",
|
107
|
+
"oak wood" => "17",
|
108
|
+
"light green wool" => "35",
|
109
|
+
"cobblestone slab" => "44",
|
110
|
+
"wall sign" => "68",
|
111
|
+
"cake block" => "92",
|
112
|
+
"pine wood" => "17",
|
113
|
+
"pink wool" => "35",
|
114
|
+
"brick block" => "45",
|
115
|
+
"lever" => "69",
|
116
|
+
"birch wood" => "17",
|
117
|
+
"gray wool" => "35",
|
118
|
+
"tnt" => "46",
|
119
|
+
"stone pressure plate" => "70",
|
120
|
+
"leaves" => "18",
|
121
|
+
"light gray wool" => "35",
|
122
|
+
"bookshelf" => "47",
|
123
|
+
"iron door" => "330",
|
124
|
+
"locked chest" => "95",
|
125
|
+
"sponge" => "19",
|
126
|
+
"cyan wool" => "35",
|
127
|
+
"moss stone" => "48",
|
128
|
+
"wooden pressure plate" => "72",
|
129
|
+
"trapdoor" => "96",
|
130
|
+
"iron shovel" => "256",
|
131
|
+
"stick" => "280",
|
132
|
+
"chainmail boots" => "305",
|
133
|
+
"lapis lazuli" => "351",
|
134
|
+
"iron pickaxe" => "257",
|
135
|
+
"bowl" => "281",
|
136
|
+
"iron helmet" => "306",
|
137
|
+
"redstone" => "331",
|
138
|
+
"purple dye" => "351",
|
139
|
+
"iron axe" => "258",
|
140
|
+
"mushroom soup" => "282",
|
141
|
+
"iron chestplate" => "307",
|
142
|
+
"snowball" => "332",
|
143
|
+
"cyan dye" => "351",
|
144
|
+
"flint and steel" => "259",
|
145
|
+
"gold sword" => "283",
|
146
|
+
"iron leggings" => "308",
|
147
|
+
"boat" => "333",
|
148
|
+
"light gray dye" => "351",
|
149
|
+
"apple" => "260",
|
150
|
+
"gold shovel" => "284",
|
151
|
+
"iron boots" => "309",
|
152
|
+
"leather" => "334",
|
153
|
+
"gray dye" => "351",
|
154
|
+
"bow" => "261",
|
155
|
+
"gold pickaxe" => "285",
|
156
|
+
"diamond helmet" => "310",
|
157
|
+
"milk" => "335",
|
158
|
+
"pink dye" => "351",
|
159
|
+
"arrow" => "262",
|
160
|
+
"gold axe" => "286",
|
161
|
+
"diamond chestplate" => "311",
|
162
|
+
"clay brick" => "336",
|
163
|
+
"lime dye" => "351",
|
164
|
+
"coal" => "263",
|
165
|
+
"string" => "287",
|
166
|
+
"diamond leggings" => "312",
|
167
|
+
"clay balls" => "337",
|
168
|
+
"dandelion yellow" => "351",
|
169
|
+
"charcoal" => "263",
|
170
|
+
"feather" => "288",
|
171
|
+
"diamond boots" => "313",
|
172
|
+
"light blue dye" => "351",
|
173
|
+
"diamond" => "264",
|
174
|
+
"gunpowder" => "289",
|
175
|
+
"gold helmet" => "314",
|
176
|
+
"paper" => "339",
|
177
|
+
"magenta dye" => "351",
|
178
|
+
"iron ingot" => "265",
|
179
|
+
"wooden hoe" => "290",
|
180
|
+
"gold chestplate" => "315",
|
181
|
+
"book" => "340",
|
182
|
+
"orange dye" => "351",
|
183
|
+
"gold ingot" => "266",
|
184
|
+
"stone hoe" => "291",
|
185
|
+
"gold leggings" => "316",
|
186
|
+
"slimeball" => "341",
|
187
|
+
"bone meal" => "351",
|
188
|
+
"iron sword" => "267",
|
189
|
+
"iron hoe" => "292",
|
190
|
+
"gold boots" => "317",
|
191
|
+
"storage minecart" => "342",
|
192
|
+
"bone" => "352",
|
193
|
+
"wooden sword" => "268",
|
194
|
+
"diamond hoe" => "293",
|
195
|
+
"flint" => "318",
|
196
|
+
"powered minecart" => "343",
|
197
|
+
"sugar" => "353",
|
198
|
+
"wooden shovel" => "269",
|
199
|
+
"gold hoe" => "294",
|
200
|
+
"raw porkchop" => "319",
|
201
|
+
"egg" => "344",
|
202
|
+
"cake" => "354",
|
203
|
+
"wooden pickaxe" => "270",
|
204
|
+
"seeds" => "295",
|
205
|
+
"cooked porkchop" => "320",
|
206
|
+
"compass" => "345",
|
207
|
+
"wooden axe" => "271",
|
208
|
+
"wheat" => "296",
|
209
|
+
"paintings" => "321",
|
210
|
+
"fishing rod" => "346",
|
211
|
+
"redstone repeater" => "356",
|
212
|
+
"stone sword" => "272",
|
213
|
+
"bread" => "297",
|
214
|
+
"golden apple" => "322",
|
215
|
+
"clock" => "347",
|
216
|
+
"cookie" => "357",
|
217
|
+
"stone shovel" => "273",
|
218
|
+
"leather helmet" => "298",
|
219
|
+
"sign" => "323",
|
220
|
+
"glowstone dust" => "348",
|
221
|
+
"map" => "358",
|
222
|
+
"stone pickaxe" => "274",
|
223
|
+
"leather chestplate" => "299",
|
224
|
+
"raw fish" => "349",
|
225
|
+
"shears" => "359",
|
226
|
+
"stone axe" => "275",
|
227
|
+
"leather leggings" => "300",
|
228
|
+
"bucket" => "325",
|
229
|
+
"cooked fish" => "350",
|
230
|
+
"gold music disc" => "2256",
|
231
|
+
"diamond sword" => "276",
|
232
|
+
"leather boots" => "301",
|
233
|
+
"water bucket" => "326",
|
234
|
+
"ink sac" => "351",
|
235
|
+
"green music disc" => "2257",
|
236
|
+
"diamond shovel" => "277",
|
237
|
+
"chainmail helmet" => "302",
|
238
|
+
"lava bucket" => "327",
|
239
|
+
"rose red" => "351",
|
240
|
+
"diamond pickaxe" => "278",
|
241
|
+
"chainmail chestplate" => "303",
|
242
|
+
"minecart" => "328",
|
243
|
+
"cactus green" => "351",
|
244
|
+
"diamond axe" => "279",
|
245
|
+
"chainmail leggings" => "304",
|
246
|
+
"saddle" => "329",
|
247
|
+
"cocoa beans" => "351"
|
248
|
+
}
|
249
|
+
end
|
250
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Minecraft
|
2
|
+
class Extensions
|
3
|
+
include Data
|
4
|
+
|
5
|
+
def process(line)
|
6
|
+
puts line
|
7
|
+
return info_command(line) if line.index "INFO"
|
8
|
+
end
|
9
|
+
|
10
|
+
def info_command(line)
|
11
|
+
line.gsub! /^.*?\[INFO\]\s+/, ''
|
12
|
+
match_data = line.match /^\<(.*?)\>\s+!(.*?)$/
|
13
|
+
return if match_data.nil?
|
14
|
+
|
15
|
+
user = match_data[1]
|
16
|
+
args = match_data[2].split(" ")
|
17
|
+
return send(args.slice!(0), user, *args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing(sym, *args)
|
21
|
+
if DATA_VALUE_HASH.has_key? sym.downcase
|
22
|
+
give(args.first, sym, args.last)
|
23
|
+
else
|
24
|
+
puts "Invalid command given."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def give(user, *args)
|
29
|
+
if args.length == 1
|
30
|
+
quantity = 1
|
31
|
+
item = args.first
|
32
|
+
else
|
33
|
+
quantity = args.last.to_i || 1
|
34
|
+
item = args[0..-2].join(" ")
|
35
|
+
end
|
36
|
+
item = (item.to_i.to_s == item) ? item.to_i : DATA_VALUE_HASH[item.downcase]
|
37
|
+
|
38
|
+
return quantify(user, item, quantity)
|
39
|
+
end
|
40
|
+
|
41
|
+
def kit(user, group)
|
42
|
+
ret = ""
|
43
|
+
KITS[group.to_sym].each do |item|
|
44
|
+
if item.is_a? Array
|
45
|
+
ret += quantify(user, item.first, item.last)
|
46
|
+
else
|
47
|
+
ret += "give #{user} #{item} 1\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
return ret.chop
|
51
|
+
end
|
52
|
+
|
53
|
+
def tp(user, target)
|
54
|
+
"tp #{user} #{target}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def nom(user)
|
58
|
+
"give #{user} 322 1"
|
59
|
+
end
|
60
|
+
|
61
|
+
def quantify(user, item, quantity)
|
62
|
+
return "give #{user} #{item} #{quantity}" if quantity <= 64
|
63
|
+
|
64
|
+
quantity = 2560 if quantity > 2560
|
65
|
+
full_quantity = (quantity / 64.0).floor
|
66
|
+
sub_quantity = quantity % 64
|
67
|
+
ret = "give #{user} #{item} 64\n" * full_quantity
|
68
|
+
ret += "give #{user} #{item} #{sub_quantity}"
|
69
|
+
return ret
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
module Minecraft
|
4
|
+
class Server
|
5
|
+
attr_accessor :sin
|
6
|
+
|
7
|
+
def initialize(command)
|
8
|
+
@extensions = Extensions.new
|
9
|
+
@sin, @sout, @serr = Open3.popen3(command)
|
10
|
+
threads = []
|
11
|
+
threads << Thread.new { loop { process(@sout.gets) } }
|
12
|
+
threads << Thread.new { loop { process(@serr.gets) } }
|
13
|
+
threads << Thread.new { loop { @sin.puts gets } }
|
14
|
+
threads.each(&:join)
|
15
|
+
end
|
16
|
+
|
17
|
+
def process(line)
|
18
|
+
result = @extensions.process(line)
|
19
|
+
@sin.puts(result) unless result.nil?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/minecraft.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
require "minecraft/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "minecraft"
|
8
|
+
s.version = Minecraft::VERSION
|
9
|
+
s.authors = ["Andrew Horsman"]
|
10
|
+
s.email = ["self@andrewhorsman.net"]
|
11
|
+
s.summary = "Minecraft server wrapper and deployment."
|
12
|
+
s.description = "A server console wrapper and other Minecraft deployment tools."
|
13
|
+
|
14
|
+
s.homepage = "http://github.com/basicxman/minecraft"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minecraft
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrew Horsman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-08-13 00:00:00 -04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: A server console wrapper and other Minecraft deployment tools.
|
18
|
+
email:
|
19
|
+
- self@andrewhorsman.net
|
20
|
+
executables:
|
21
|
+
- minecraft
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files: []
|
25
|
+
|
26
|
+
files:
|
27
|
+
- .gitignore
|
28
|
+
- Gemfile
|
29
|
+
- Rakefile
|
30
|
+
- bin/minecraft
|
31
|
+
- lib/minecraft.rb
|
32
|
+
- lib/minecraft/data.rb
|
33
|
+
- lib/minecraft/extensions.rb
|
34
|
+
- lib/minecraft/server.rb
|
35
|
+
- lib/minecraft/version.rb
|
36
|
+
- minecraft.gemspec
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://github.com/basicxman/minecraft
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.5.0
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: Minecraft server wrapper and deployment.
|
65
|
+
test_files: []
|
66
|
+
|