generated from FabricMC/fabric-example-mod
-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathresources.gradle
33 lines (30 loc) · 1.62 KB
/
resources.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.nio.file.Files
import java.nio.file.Path
// Codename
List<String> possibleNames = new ArrayList<>()
new XmlParser().parse("https://knowyourmeme.com/memes.rss").channel.item.each { item ->
possibleNames.add(item.title.text())
}
project.ext.codename = possibleNames.get(new Random(project.mod_version.hashCode()).nextInt(possibleNames.size()))
System.out.println("Chose codename \"" + project.ext.codename + "\" from " + possibleNames.size() + " choices")
// im not really sure why this was commented out, but the game refused to launch without downloading it because somebody made beemovie.txt loadbearing
// having that file be mandatory is really funny so im not changing it. uncommenting this means future contributors dont have to download it manually
// beemovie.txt
def beePath = "${project.projectDir}/src/main/resources/assets/gwwhit/beemovie.txt";
if ( !(new File(beePath).exists()) ) {
System.out.println("Bee movie script required, not found. Downloading...");
def reader = new BufferedReader(new InputStreamReader(new URL("http://www.script-o-rama.com/movie_scripts/a1/bee-movie-script-transcript-seinfeld.html").openStream()))
String s = null;
String compound = "";
while ((s = reader.readLine()) != null)
compound += "\n" + s;
def beequotes = compound.split("<pre>")[1].split("</pre>")[0].split("\n\n {2}\n")
beequotes[0] = beequotes[0].replace(" \n \n", "")
compound = "";
for (String a : beequotes) {
compound += "[PARAGRAPH]" + a;
}
Files.writeString(Path.of(beePath), compound)
} else {
System.out.println("According to all known laws of aviation...");
}