Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit c84f18b

Browse files
committed
Buildscripts for 1.14.4 and 1.15.2 added.
1 parent c7d639f commit c84f18b

File tree

2 files changed

+135
-1
lines changed

2 files changed

+135
-1
lines changed

build.ps1 renamed to build-1.14.4.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ function DownloadLocalization {
3737
$moduleVersion = "1.14.4"
3838
}
3939
}
40-
40+
else {
41+
$moduleVersion = "1.15.2"
42+
}
43+
4144
$link
4245
if ($module -eq "essentials") {
4346
$link = "$urlBase/ProjectEssentials/raw/MC-$mcVersion/src/main/resources/assets/projectessentials/lang"

build-1.15.2.ps1

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
[string] $updated = "02-12-2020"
2+
[string] $version = "1.0.0"
3+
[string] $mcVersion = "1.15.2"
4+
[string] $downloadDir = "temp"
5+
[string] $outDir = "out"
6+
[string] $urlBase = "https://github.com/ProjectEssentials"
7+
[array] $modules = ("core", "cooldown", "permissions", "essentials", "chat", "spawn", "home", "warps", "backup")
8+
[array] $localizations = ("en_us", "ru_ru", "de_de")
9+
10+
Write-Output "Project Essentials resource-pack builder $version updated $updated."
11+
Write-Output "Building resource pack is starting ..."
12+
13+
if ($modules.Count -eq 0) {
14+
Write-Warning "Modules whose resources should be bundled in resource-pack are not specified, by default all modules will be used."
15+
$modules = ("core", "cooldown", "permissions", "essentials", "chat", "spawn", "home", "warps", "backup")
16+
}
17+
18+
function PurgeTempFiles {
19+
if (Test-Path -Path $downloadDir -PathType Container) {
20+
Remove-Item "$downloadDir\*" -Recurse -Force
21+
}
22+
}
23+
24+
function DownloadLocalization {
25+
param (
26+
[string] $module
27+
)
28+
29+
Write-Output "Starting proccessing resources for $module of version $mcVersion"
30+
31+
$moduleVersion
32+
if ($mcVersion -eq "1.14.4") {
33+
if ($module -eq "permissions") {
34+
$moduleVersion = "1.14.X"
35+
}
36+
else {
37+
$moduleVersion = "1.14.4"
38+
}
39+
}
40+
else {
41+
$moduleVersion = "1.15.2"
42+
}
43+
44+
$link
45+
if ($module -eq "essentials") {
46+
$link = "$urlBase/ProjectEssentials/raw/MC-$mcVersion/src/main/resources/assets/projectessentials/lang"
47+
}
48+
else {
49+
$link = "$urlBase/ProjectEssentials-$module/raw/MC-$moduleVersion/src/main/resources/assets/projectessentials$module/lang"
50+
}
51+
52+
[array] $downloaded -join ', '
53+
54+
ForEach ($localization in $localizations) {
55+
try {
56+
if ($module -eq "essentials") {
57+
[system.io.directory]::CreateDirectory("$downloadDir\assets\projectessentials\lang")
58+
}
59+
else {
60+
[system.io.directory]::CreateDirectory("$downloadDir\assets\projectessentials$module\lang")
61+
}
62+
63+
if ($module -eq "essentials") {
64+
(New-Object System.Net.WebClient).DownloadFile("$link/$localization.json", "$downloadDir\assets\projectessentials\lang\$localization.json")
65+
}
66+
else {
67+
(New-Object System.Net.WebClient).DownloadFile("$link/$localization.json", "$downloadDir\assets\projectessentials$module\lang\$localization.json")
68+
}
69+
70+
$downloaded += $localization
71+
}
72+
catch {
73+
Write-Warning "$localization not found in $module, will be skiped."
74+
}
75+
finally {
76+
Write-Output "Downloaded: $downloaded localizations for module $module"
77+
$downloaded = ("")
78+
}
79+
}
80+
}
81+
82+
83+
function Pack {
84+
param (
85+
[string] $module
86+
)
87+
88+
Write-Output "Packing resource-pack for $module ..."
89+
90+
[system.io.directory]::CreateDirectory($outDir)
91+
92+
$source
93+
if ($module -eq "essentials") {
94+
$source = "$downloadDir\assets\projectessentials"
95+
}
96+
else {
97+
$source = "$downloadDir\assets\projectessentials$module"
98+
}
99+
100+
$destination = "$outDir\ProjectEssentials-Localization-$mcVersion-$module.zip"
101+
102+
If (Test-path $destination) { Remove-item $destination }
103+
104+
Compress-Archive -Path $source -DestinationPath "$destination"
105+
Compress-Archive -Path "pack\$mcVersion\pack.mcmeta" -Update -DestinationPath "$destination"
106+
}
107+
108+
function PackAll {
109+
Write-Output "Packing generic resource-pack ..."
110+
111+
$source = "$downloadDir\assets"
112+
$destination = "$outDir\ProjectEssentials-Localization-$mcVersion-all.zip"
113+
114+
If (Test-path $destination) { Remove-item $destination }
115+
116+
Compress-Archive -Path $source -DestinationPath "$destination"
117+
Compress-Archive -Path "pack\$mcVersion\pack.mcmeta" -Update -DestinationPath "$destination"
118+
}
119+
120+
121+
PurgeTempFiles
122+
ForEach ($module in $modules) {
123+
DownloadLocalization($module)
124+
Pack($module)
125+
}
126+
127+
PackAll
128+
129+
Write-Output "Resource-packs generated! Done!"
130+
131+
Pause

0 commit comments

Comments
 (0)