Skip to content

Commit ceb1a1f

Browse files
authored
Merge pull request from MinimineLP
multi-line-support, beautified code, comments and improvements
2 parents ecd344d + 0cd4b31 commit ceb1a1f

38 files changed

+810
-320
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ lib/modals/cam.mcscript
77
# Core Modals.md
88
# *.html
99
# README-DE.md
10+
*.bat

bin/add.js

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,89 @@
1-
var http = require('https');
2-
var fs = require('fs');
1+
const http = require('https');
2+
const fs = require('fs');
33

4+
// Add Pack (downloading pack from mediafire)
45
exports.addPack = function(name){
6+
57
let patt = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/)
8+
69
if(patt.test(name)){
10+
711
download(name, "external")
12+
813
} else http.get("https://download1350.mediafire.com/q7aa9e774jug/oyrbdi6fbpqo1bl/mcscri%27%2B%27pt+packages.json", (res) => {
14+
915
res.setEncoding('utf8');
10-
res.on('data', function (chunk) {
11-
let packs = JSON.parse(chunk)
12-
let obj = packs.find(obj => obj.name === name.toLowerCase())
13-
if(obj && obj.url){
14-
console.log(obj.url.slice(0, 17))
15-
if(obj.url.slice(0, 17) == "https://github.com" || obj.url.slice(0, 16) == "http://github.com") downloadFromRedirectLink(obj.url, obj.name)
16-
else download(obj.url, obj.name)
17-
} else {
18-
let packStr = ""
19-
packs.forEach((e, i) => {
20-
packStr += e.name
21-
if(i != packs.length - 1) packStr += ", "
22-
})
23-
console.log("\x1b[31m","Your pack was not found! Please use one of these: ","\x1b[0m")
24-
console.log("\x1b[36m",packStr,"\x1b[0m")
25-
}
16+
res.on('data', function (chunk) {
17+
18+
let packs = JSON.parse(chunk)
19+
let obj = packs.find(obj => obj.name === name.toLowerCase())
20+
21+
if(obj && obj.url){
22+
console.log(obj.url.slice(0, 17))
23+
if(obj.url.slice(0, 17) == "https://github.com" || obj.url.slice(0, 16) == "http://github.com") downloadFromRedirectLink(obj.url, obj.name)
24+
25+
else download(obj.url, obj.name)
26+
27+
} else {
28+
29+
let packStr = ""
30+
packs.forEach((e, i) => {
31+
32+
packStr += e.name
33+
if(i != packs.length - 1) packStr += ", "
34+
35+
})
36+
37+
console.log("\x1b[31m","Your pack was not found! Please use one of these: ","\x1b[0m")
38+
console.log("\x1b[36m",packStr,"\x1b[0m")
39+
40+
}
2641
});
2742

2843
}).on('error', function(e) {
44+
2945
console.log("\x1b[31m","Got error: " + e.message,"\x1b[0m");
46+
3047
});
3148
}
49+
50+
// Download File From url
3251
var download = function (url, name){
52+
3353
console.log("\x1b[36m","Downloading "+name+".zip ...","\x1b[0m")
54+
3455
let file = fs.createWriteStream(name + '.zip');
3556
let request = http.get(url, function(response) {
57+
3658
response.pipe(file)
3759
response.on('end', () => {
3860
console.log("\x1b[32m","Download of "+name+".zip finished!","\x1b[0m")
3961
});
62+
4063
}).on('error', function(e) {
64+
4165
console.log("\x1b[31m","Got error: " + e.message,"\x1b[0m");
66+
4267
});
4368
}
69+
70+
// Download File From Redirected-Url (in this programm mostly github.com)
4471
function downloadFromRedirectLink(url, file) {
72+
4573
http.get(url, function(res) {
46-
if(res.statusCode != 302){
74+
75+
if(res.statusCode != 302){ // No redirect
76+
4777
console.log("error: no redirect found");
4878
return;
79+
4980
}
81+
5082
download(res.headers.location,file);
83+
5184
}).on('error', function(e) {
85+
5286
console.log("\x1b[31m", "Got error: " + e.message,"\x1b[0m");
87+
5388
});
5489
}

bin/modal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env node
2-
var lib= require('../lib/index.js');
2+
const lib = require('../lib/index.js');
33
lib.genModals(process.argv[2] || './')

bin/test-module.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
#!/usr/bin/env node
22

3-
var lib= require('../lib/index.js');
4-
var addPack = require('./add.js');
5-
var gen_new = require('../lib/gen_new.js');
6-
// lib.compile(process.argv[2] || './')
3+
const lib = require('../lib/index.js');
4+
const addPack = require('./add.js');
5+
const gen_new = require('../lib/gen_new.js');
6+
const consoletheme = require('../lib/consoletheme.js');
7+
78
switch(process.argv[2]){
89
case 'compile':
9-
lib.compile(process.argv[3] || './');
10-
break
11-
case 'watch': lib.watch(process.argv[3] || './');
12-
break
13-
case 'modal': lib.genModals(process.argv[3] || './');
14-
break
10+
lib.compile(process.argv[3] || './');
11+
break;
12+
case 'watch':
13+
lib.watch(process.argv[3] || './');
14+
break;
15+
case 'modal':
16+
lib.genModals(process.argv[3] || './');
17+
break;
1518
case 'new':
16-
if(process.argv[3]) gen_new.new(process.argv[3])
17-
else console.log("\x1b[31m","You have to enter a datapack id!","\x1b[0m")
18-
break
19+
if(process.argv[3]) gen_new.new(process.argv[3]);
20+
else console.log(consoletheme.FgRed,"You have to enter a datapack id!",consoletheme.Reset);
21+
break;
1922
case 'add':
20-
addPack.addPack(process.argv[3] || "")
21-
break
22-
default: console.log("\x1b[31m","Please select a sub command","\x1b[0m")
23+
addPack.addPack(process.argv[3] || "");
24+
break;
25+
default:
26+
console.log(consoletheme.FgRed,"Please select a sub command",consoletheme.Reset);
27+
break;
2328
}

bin/watch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env node
2-
var lib= require('../lib/index.js');
2+
const lib = require('../lib/index.js');
33
lib.watch(process.argv[2] || './')

examples/functions/basic_loop.mcfunction

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#######
2-
# Compiled from /examples/functions/basic Loop.mcscript
3-
# to .//examples/functions/basic_loop.mcfunction
2+
# Compiled from examples/functions/basic Loop.mcscript
3+
# to examples/functions/basic_loop.mcfunction
44
#
55
# Generated by Minecraft Script for 1.13
66
######

examples/functions/basic_modal.mcfunction

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#######
2-
# Compiled from /examples/functions/basic Modal.mcscript
3-
# to .//examples/functions/basic_modal.mcfunction
2+
# Compiled from examples/functions/basic Modal.mcscript
3+
# to examples/functions/basic_modal.mcfunction
44
#
55
# Generated by Minecraft Script for 1.13
66
######

examples/functions/boolean.mcfunction

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#######
2-
# Compiled from /examples/functions/boolean.mcscript
3-
# to .//examples/functions/boolean.mcfunction
2+
# Compiled from examples/functions/boolean.mcscript
3+
# to examples/functions/boolean.mcfunction
44
#
55
# Generated by Minecraft Script for 1.13
66
######
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#######
2+
# Compiled from examples/functions/comments.mcscript
3+
# to examples/functions/comments.mcfunction
4+
#
5+
# Generated by Minecraft Script for 1.13
6+
######
7+
#file ./comments
8+
# this file is contentless, it is just a demonstration for comments
9+
# single line transfare comment. This comment will be transfared to the compiled result function

examples/functions/consts.mcfunction

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#######
2-
# Compiled from /examples/functions/consts.mcscript
3-
# to .//examples/functions/consts.mcfunction
2+
# Compiled from examples/functions/consts.mcscript
3+
# to examples/functions/consts.mcfunction
44
#
55
# Generated by Minecraft Script for 1.13
66
######

0 commit comments

Comments
 (0)