mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-19 15:20:55 +00:00
Download configs from online
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
+53
-18
@@ -5,9 +5,12 @@ import java.nio.channels.Channels
|
|||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.nio.file.StandardCopyOption
|
import java.nio.file.StandardCopyOption
|
||||||
|
//import java.util.zip.ZipFile
|
||||||
|
import java.util.zip.ZipInputStream
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
|
maven
|
||||||
id("com.github.johnrengelman.shadow").version("6.1.0")
|
id("com.github.johnrengelman.shadow").version("6.1.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,6 +22,7 @@ repositories {
|
|||||||
maven { url = uri("http://maven.enginehub.org/repo/") }
|
maven { url = uri("http://maven.enginehub.org/repo/") }
|
||||||
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
|
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
|
||||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||||
|
// maven { url = uri("https://maven.pkg.github.com/solonovamax/Gaea") }
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
@@ -26,14 +30,16 @@ java {
|
|||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
|
|
||||||
val versionObj = Version("0", "0", "1", "dev.2")
|
val versionObj = Version("1", "3", "0", true)
|
||||||
version = versionObj
|
version = versionObj
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT")
|
// compileOnly("org.polydev.gaea:gaea:1.14.2-github-actions+9d59b49")
|
||||||
compileOnly("org.jetbrains:annotations:20.1.0") // more recent.
|
|
||||||
implementation("commons-io:commons-io:2.4")
|
|
||||||
compileOnly(name = "Gaea-1.14.2", group = "")
|
compileOnly(name = "Gaea-1.14.2", group = "")
|
||||||
|
|
||||||
|
compileOnly("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT")
|
||||||
|
compileOnly("org.jetbrains:annotations:20.1.0")
|
||||||
|
implementation("commons-io:commons-io:2.4")
|
||||||
implementation("org.apache.commons:commons-imaging:1.0-alpha2")
|
implementation("org.apache.commons:commons-imaging:1.0-alpha2")
|
||||||
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT")
|
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT")
|
||||||
implementation("org.bstats:bstats-bukkit:1.7")
|
implementation("org.bstats:bstats-bukkit:1.7")
|
||||||
@@ -45,22 +51,21 @@ dependencies {
|
|||||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
|
||||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
|
||||||
|
|
||||||
testImplementation(name = "Gaea-1.14.2", group = "")
|
testImplementation(name = "Gaea-1.14.0", group = "")
|
||||||
testImplementation("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val compileJava: JavaCompile by tasks
|
val compileJava: JavaCompile by tasks
|
||||||
compileJava.apply {
|
compileJava.apply {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
doFirst {
|
doFirst {
|
||||||
options.compilerArgs = mutableListOf("-Xlint:all", "-Xlint:-processing")
|
options.compilerArgs = mutableListOf("-Xlint:all")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
|
|
||||||
maxHeapSize = "1G"
|
maxHeapSize = "4G"
|
||||||
ignoreFailures = false
|
ignoreFailures = false
|
||||||
failFast = true
|
failFast = true
|
||||||
maxParallelForks = 12
|
maxParallelForks = 12
|
||||||
@@ -87,8 +92,8 @@ val setupServer = tasks.create("setupServer") {
|
|||||||
gitClone("https://github.com/PolyhedralDev/WorldGenTestServer")
|
gitClone("https://github.com/PolyhedralDev/WorldGenTestServer")
|
||||||
// Copying plugins
|
// Copying plugins
|
||||||
Files.move(Paths.get("WorldGenTestServer/plugins"),
|
Files.move(Paths.get("WorldGenTestServer/plugins"),
|
||||||
Paths.get("$testDir/plugins"),
|
Paths.get("$testDir/plugins"),
|
||||||
StandardCopyOption.REPLACE_EXISTING)
|
StandardCopyOption.REPLACE_EXISTING)
|
||||||
// Copying config
|
// Copying config
|
||||||
val serverText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/server.properties").readText()
|
val serverText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/server.properties").readText()
|
||||||
file("${testDir}/server.properties").writeText(serverText)
|
file("${testDir}/server.properties").writeText(serverText)
|
||||||
@@ -102,6 +107,22 @@ val setupServer = tasks.create("setupServer") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
|
||||||
|
doFirst {
|
||||||
|
// Downloading latest paper jar.
|
||||||
|
// if (file("${buildDir}/resources/main/packs/default").exists() && file("${buildDir}/resources/main/packs/nether").exists())
|
||||||
|
// return@doFirst
|
||||||
|
// else
|
||||||
|
file("${buildDir}/resources/main/packs/").deleteRecursively()
|
||||||
|
|
||||||
|
val defaultPackUrl = URL("https://github.com/PolyhedralDev/TerraDefaultConfig/releases/download/latest/default.zip")
|
||||||
|
downloadAndUnzipPack(defaultPackUrl)
|
||||||
|
val netherPackUrl = URL("https://github.com/PolyhedralDev/TerraDefaultConfig/releases/download/latest/nether.zip")
|
||||||
|
downloadAndUnzipPack(netherPackUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tasks.processResources.get().dependsOn(downloadDefaultPacks)
|
||||||
|
|
||||||
val testWithPaper = task<JavaExec>(name = "testWithPaper") {
|
val testWithPaper = task<JavaExec>(name = "testWithPaper") {
|
||||||
standardInput = System.`in`
|
standardInput = System.`in`
|
||||||
dependsOn(tasks.shadowJar)
|
dependsOn(tasks.shadowJar)
|
||||||
@@ -121,7 +142,7 @@ val testWithPaper = task<JavaExec>(name = "testWithPaper") {
|
|||||||
"-XX:InitiatingHeapOccupancyPercent=15", "-XX:G1MixedGCLiveThresholdPercent=90",
|
"-XX:InitiatingHeapOccupancyPercent=15", "-XX:G1MixedGCLiveThresholdPercent=90",
|
||||||
"-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem",
|
"-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem",
|
||||||
"-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs",
|
"-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs",
|
||||||
"-Daikars.new.flags=true", "-DIReallyKnowWhatIAmDoingISwear")
|
"-Daikars.new.flags=true")
|
||||||
maxHeapSize = "2G"
|
maxHeapSize = "2G"
|
||||||
args = listOf("nogui")
|
args = listOf("nogui")
|
||||||
workingDir = file("${testDir}/")
|
workingDir = file("${testDir}/")
|
||||||
@@ -132,10 +153,10 @@ tasks.named<ShadowJar>("shadowJar") {
|
|||||||
archiveClassifier.set("")
|
archiveClassifier.set("")
|
||||||
archiveBaseName.set("Terra")
|
archiveBaseName.set("Terra")
|
||||||
setVersion(project.version)
|
setVersion(project.version)
|
||||||
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
|
relocate("org.apache.commons", "lib.commons")
|
||||||
relocate("org.bstats.bukkit", "com.dfsek.terra.lib.bstats")
|
relocate("org.bstats.bukkit", "lib.bstats")
|
||||||
relocate("parsii", "com.dfsek.terra.lib.parsii")
|
relocate("parsii", "lib.parsii")
|
||||||
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib")
|
relocate("io.papermc.lib", "lib.paperlib")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.build {
|
tasks.build {
|
||||||
@@ -151,13 +172,13 @@ tasks.build {
|
|||||||
* Version class that does version stuff.
|
* Version class that does version stuff.
|
||||||
*/
|
*/
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
class Version(val major: String, val minor: String, val revision: String, val preReleaseData: String? = null) {
|
class Version(val major: String, val minor: String, val revision: String, val preRelease: Boolean = false) {
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return if (preReleaseData.isNullOrBlank())
|
return if (!preRelease)
|
||||||
"$major.$minor.$revision"
|
"$major.$minor.$revision"
|
||||||
else //Only use git hash if it's a prerelease.
|
else //Only use git hash if it's a prerelease.
|
||||||
"$major.$minor.$revision-$preReleaseData+${getGitHash()}"
|
"$major.$minor.$revision-BETA+${getGitHash()}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,3 +198,17 @@ fun gitClone(name: String) {
|
|||||||
standardOutput = stdout
|
standardOutput = stdout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun downloadAndUnzipPack(packUrl: URL) {
|
||||||
|
ZipInputStream(packUrl.openStream()).use { zip ->
|
||||||
|
while (true) {
|
||||||
|
val entry = zip.nextEntry ?: break
|
||||||
|
if (entry.isDirectory)
|
||||||
|
file("${buildDir}/resources/main/packs/${entry.name}").mkdirs()
|
||||||
|
else
|
||||||
|
file("${buildDir}/resources/main/packs/${entry.name}").outputStream().use { output ->
|
||||||
|
output.write(zip.readBytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.polydev.gaea.util.JarUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -25,8 +26,6 @@ import java.util.jar.JarFile;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static org.polydev.gaea.util.JarUtil.copyResourcesToDirectory;
|
|
||||||
|
|
||||||
public final class ConfigUtil {
|
public final class ConfigUtil {
|
||||||
public static boolean debug;
|
public static boolean debug;
|
||||||
public static long dataSave; // Period of population data saving, in ticks.
|
public static long dataSave; // Period of population data saving, in ticks.
|
||||||
@@ -47,7 +46,7 @@ public final class ConfigUtil {
|
|||||||
|
|
||||||
if(config.getBoolean("dump-default", true)) {
|
if(config.getBoolean("dump-default", true)) {
|
||||||
try(JarFile jar = new JarFile(new File(Terra.class.getProtectionDomain().getCodeSource().getLocation().toURI()))) {
|
try(JarFile jar = new JarFile(new File(Terra.class.getProtectionDomain().getCodeSource().getLocation().toURI()))) {
|
||||||
copyResourcesToDirectory(jar, "default-config", new File(main.getDataFolder(), "packs" + File.separator + "default").toString());
|
JarUtil.copyResourcesToDirectory(jar, "packs", new File(main.getDataFolder(), "packs").toString());
|
||||||
} catch(IOException | URISyntaxException e) {
|
} catch(IOException | URISyntaxException e) {
|
||||||
Debug.error("Failed to dump default config files!");
|
Debug.error("Failed to dump default config files!");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user