@@ -7,20 +7,59 @@ module.exports=(type)->
77 server = http .createServer ()
88 io = require (" socket.io" )(server)
99 express = require ' express'
10+ request = require ' request'
1011 app = express ();
1112 mineflayer = require ' mineflayer'
1213 Chunk = require (" prismarine-chunk" )(config .realServer .version )
1314 vec3 = require " vec3"
1415 Convert = require ' ansi-to-html'
1516 convert = new Convert ()
1617
17- opn (" http://#{ config .host } :#{ config[' express-port' ]} " )
18+ # opn("http://#{config.host}:#{config['express-port']}")
1819
1920 # początkowe zmienne
2021 sf = {}
2122 port = config[" express-port" ]
2223 socketInfo = {}
2324
25+ getItem = (name ,callback )->
26+ mozl = [
27+ " materials"
28+ " armor_recipes"
29+ " basic_recipes"
30+ " block_recipes"
31+ " mobs"
32+ " decoration_recipes"
33+ " dye_recipes"
34+ " firework_recipes"
35+ " food_recipes"
36+ " mechanism_recipes"
37+ " tool_recipes"
38+ " transportation_recipes"
39+ " weapon_recipes"
40+ ]
41+ done = 0
42+ wysl = false
43+ for i in mozl
44+ options = {
45+ method : ' GET'
46+ url : " https://www.digminecraft.com/#{ i} /images/#{ name} .png"
47+ encoding : null
48+ }
49+ ((options )->
50+ request options, (err , response , body )->
51+ done += 1
52+ if not err and response .statusCode == 200 and wysl is false
53+ wysl = true
54+ callback options .url
55+
56+ else if wysl is false and done is mozl .length
57+ callback " error"
58+ return
59+ )(options)
60+
61+
62+
2463 # Konfiguracja serwera express
2564 if type is " production"
2665 app .use express .static (__dirname + " /dist/" )
@@ -29,6 +68,9 @@ module.exports=(type)->
2968 app .use (req, res, next) ->
3069 res .set ' Cache-Control' , ' no-store'
3170 next ()
71+ app .get " /items/:item" ,(req ,res )->
72+ getItem req .params .item ,(resp )->
73+ res .send (resp)
3274 app .get " /websocket/" ,(req ,res )->
3375 res .send String (config[" websocket-port" ])
3476 app .get " /host/" ,(req ,res )->
@@ -93,7 +135,8 @@ module.exports=(type)->
93135 inv_new = JSON .stringify (bot ().inventory .slots )
94136 if inv isnt inv_new
95137 inv = inv_new
96- emit " inventory" ,bot ().inventory .slots
138+ emit [" inventory" ,bot ().inventory .slots ]
139+ return
97140 ,100
98141 socketEventMap = {
99142 " move " : (state ,toggle )->
0 commit comments