diff --git a/.gitignore b/.gitignore index 2bba6ed84..7eb8d5819 100644 --- a/.gitignore +++ b/.gitignore @@ -130,4 +130,7 @@ fabric.properties build /target/ -.idea/sonarlint/** \ No newline at end of file +.idea/sonarlint/** +.idea/codeStyles/** +.idea/**.xml +.idea/modules/**.iml \ No newline at end of file diff --git a/README.md b/README.md index 45f42c6ea..ef1598182 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,13 @@ Terra is a data-driven world generator based on [Gaea](https://github.com/Polyhe [Spigot page](https://www.spigotmc.org/resources/85151/)! ## Building and running Terra -To run Terra on a test server, clone this repo, package with Maven, then run `test.sh`. The script will clone a test -server skeleton (found [here](https://github.com/PolyhedralDev/WorldGenTestServer)) and set everything up to run. +To build, simply run `./gradlew build` on Linux/MacOS, or `gradlew.bat build` on Windows. +This will produce a jar in `build/libs` called `Terra-[CURRENT VERSION].jar`. +You can put this right into your plugins dir, along with the correct Gaea version. + +If you would like to test it with a default server config, just run `./gradlew testWithPaper` or `gradlew.bat testWithPaper`. +This will download a default server config from [here](https://github.com/PolyhedralDev/WorldGenTestServer) +and install the server in the `target/server` directory, along with all the needed plugins. **Note: You will need to adjust the `NAME` variable in test.sh if you are not using the default Terra config (you may also change the value after server installation, in `bukkit.yml` of the test server)** @@ -12,6 +17,7 @@ also change the value after server installation, in `bukkit.yml` of the test ser ## Contributing Contributions are welcome! If you want to see a feature in Terra, please, open an issue, or implement it yourself and submit a PR! +Join the discord [here](https://discord.gg/PXUEbbF) if you would like to talk more about the project! ## Beta Terra is still in beta! While it is stable, it is not feature-complete. There is a lot to be added! \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 8e8cbec36..c5c92c94e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,10 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import java.io.ByteArrayOutputStream - -buildDir = file("target") +import java.net.URL +import java.nio.channels.Channels +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption plugins { java @@ -12,41 +15,29 @@ repositories { flatDir { dirs("lib") } - maven { - url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") - } - maven { - url = uri("http://maven.enginehub.org/repo/") - } - maven { - url = uri("https://repo.codemc.org/repository/maven-public") - } - maven { - url = uri("https://papermc.io/repo/repository/maven-public/") - } -} - -base { - libsDirName = "prod" + maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") } + maven { url = uri("http://maven.enginehub.org/repo/") } + maven { url = uri("https://repo.codemc.org/repository/maven-public") } + maven { url = uri("https://papermc.io/repo/repository/maven-public/") } } java { - sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } -val versionObj = Version("0", "0", "1", "dev.1") +val versionObj = Version("0", "0", "1", "dev.2") version = versionObj dependencies { - implementation("org.jetbrains:annotations:20.1.0") // more recent. + compileOnly("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT") + compileOnly("org.jetbrains:annotations:20.1.0") // more recent. implementation("commons-io:commons-io:2.4") implementation(name = "Gaea-1.13.0", group = "") implementation("org.apache.commons:commons-imaging:1.0-alpha2") - implementation("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("com.googlecode.json-simple:json-simple:1.1") + compileOnly("com.googlecode.json-simple:json-simple:1.1") implementation(name = "parsii-1.2", group = "") implementation("io.papermc:paperlib:1.0.5") @@ -57,33 +48,87 @@ dependencies { tasks.test { useJUnitPlatform() - + maxHeapSize = "1G" ignoreFailures = false failFast = true maxParallelForks = 12 } +val testDir = "target/server/" + +val setupServer = tasks.create("setupServer") { + dependsOn(tasks.shadowJar) + doFirst { + // clean + file("${testDir}/").deleteRecursively() + file("${testDir}/plugins").mkdirs() + + // Downloading latest paper jar. + val paperUrl = URL("https://papermc.io/api/v1/paper/1.16.3/latest/download") + val paperReadableByteChannel = Channels.newChannel(paperUrl.openStream()) + val paperFile = file("${testDir}/paper.jar") + val paperFileOutputStream = paperFile.outputStream() + val paperFileChannel = paperFileOutputStream.channel + paperFileChannel.transferFrom(paperReadableByteChannel, 0, Long.MAX_VALUE) + + // Cloning test setup. + gitClone("https://github.com/PolyhedralDev/WorldGenTestServer") + // Copying plugins + Files.move(Paths.get("WorldGenTestServer/plugins"), + Paths.get("$testDir/plugins"), + StandardCopyOption.REPLACE_EXISTING) + // Copying config + val serverText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/server.properties").readText() + file("${testDir}/server.properties").writeText(serverText) + val bukkitText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/bukkit.yml").readText() + file("${testDir}/bukkit.yml").writeText(bukkitText.replace("\${world}", "world").replace("\${gen}", "Terra:DEFAULT")) + + File("${testDir}/eula.txt").writeText("eula=true") + + // Copy Terra into dir + copy { + from("${buildDir}/libs/Terra-${versionObj}.jar") + into("${testDir}/plugins/") + } + + // clean up + file("WorldGenTestServer").deleteRecursively() + } +} + +val testWithPaper = task(name = "testWithPaper") { + dependsOn(setupServer) + main = "io.papermc.paperclip.Paperclip" + jvmArgs = listOf("-XX:+UseG1GC", "-XX:+ParallelRefProcEnabled", "-XX:MaxGCPauseMillis=200", + "-XX:+UnlockExperimentalVMOptions", "-XX:+DisableExplicitGC", "-XX:+AlwaysPreTouch", + "-XX:G1NewSizePercent=30", "-XX:G1MaxNewSizePercent=40", "-XX:G1HeapRegionSize=8M", + "-XX:G1ReservePercent=20", "-XX:G1HeapWastePercent=5", "-XX:G1MixedGCCountTarget=4", + "-XX:InitiatingHeapOccupancyPercent=15", "-XX:G1MixedGCLiveThresholdPercent=90", + "-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem", + "-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs", + "-Daikars.new.flags=true") + maxHeapSize = "2G" + workingDir = file("${testDir}/") + classpath = files("${testDir}/paper.jar") +} + tasks.named("shadowJar") { archiveClassifier.set("") archiveBaseName.set("Terra") setVersion(project.version) - dependencies { - include(dependency("commons-io:commons-io")) - include(dependency("org.apache.commons:commons-imaging")) - include(dependency("org.bstats:bstats-bukkit")) - include(dependency(":parsii-1.2")) - include(dependency("io.papermc:paperlib")) - } - relocate("org.apache.commons", "com.dfsek.terra.lib.commons") - relocate("org.bstats.bukkit", "com.dfsek.terra.lib.bstats") - relocate("parsii", "com.dfsek.terra.lib.parsii") - relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib") + relocate("org.apache.commons", "lib.commons") + relocate("org.bstats.bukkit", "lib.bstats") + relocate("parsii", "lib.parsii") + relocate("io.papermc.lib", "lib.paperlib") } tasks.build { dependsOn(tasks.test) - dependsOn("shadowJar") + dependsOn(tasks.shadowJar) +// dependsOn(testWithPaper) + tasks.shadowJar.get().mustRunAfter(tasks.test) +// testWithPaper.mustRunAfter(tasks.shadowJar) } @@ -108,3 +153,11 @@ fun getGitHash(): String { } return stdout.toString().trim() } + +fun gitClone(name: String) { + val stdout = ByteArrayOutputStream() + exec { + commandLine = mutableListOf("git", "clone", name) + standardOutput = stdout + } +} diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 806ee36fb..000000000 --- a/pom.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - 4.0.0 - - com.dfsek - Terra - 1.0-SNAPSHOT - - - - - org.apache.maven.plugins - maven-install-plugin - 2.4 - - - initialize - - install-file - - - com.scireum - parsii - 1.2 - jar - ${basedir}/lib/parsii-1.2.jar - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - 8 - 8 - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - - org.apache.commons - com.dfsek.terra.lib.commons - - - org.bstats.bukkit - com.dfsek.terra.lib.bstats - - - parsii - com.dfsek.terra.lib.parsii - - - io.papermc.lib - com.dfsek.terra.lib.paperlib - - - - - - package - - shade - - - target/prod/${project.artifactId}.jar - - - - - - - - - - spigotmc-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - enginehub-maven - http://maven.enginehub.org/repo/ - - - CodeMC - https://repo.codemc.org/repository/maven-public - - - papermc - https://papermc.io/repo/repository/maven-public/ - - - - - - org.spigotmc - spigot-api - 1.16.2-R0.1-SNAPSHOT - provided - - - org.jetbrains - annotations - 16.0.1 - provided - - - commons-io - commons-io - 2.4 - - - org.polydev - gaea - 1.12.2 - system - ${basedir}/lib/Gaea-1.12.2.jar - - - org.apache.commons - commons-imaging - 1.0-alpha2 - - - com.sk89q.worldedit - worldedit-bukkit - 7.2.0-SNAPSHOT - provided - - - org.junit.jupiter - junit-jupiter - RELEASE - test - - - org.bstats - bstats-bukkit - 1.7 - compile - - - com.googlecode.json-simple - json-simple - 1.1 - provided - - - com.scireum - parsii - 1.2 - - - io.papermc - paperlib - 1.0.5 - compile - - - - \ No newline at end of file diff --git a/test.sh b/test.sh deleted file mode 100755 index 05a6a213b..000000000 --- a/test.sh +++ /dev/null @@ -1,47 +0,0 @@ -DIRECTORY=./target -PROJECT=Terra -NAME="Terra:DEFAULT" -WORLD=world -REPO=https://github.com/PolyhedralDev/WorldGenTestServer - - -color() { - if [ $2 ]; then - echo -e "\e[$1;$2m" - else - echo -e "\e[$1m" - fi -} -colorend() { - echo -e "\e[m" -} - -if [ ! -d "$DIRECTORY/server" ]; then - echo "$DIRECTORY/server not found. Cloning now." - git clone $REPO $DIRECTORY/server -fi -sed -i "s/\${gen}/$NAME/g" $DIRECTORY/server/bukkit.yml -sed -i "s/\${world}/$WORLD/g" $DIRECTORY/server/bukkit.yml -cp $DIRECTORY/prod/$PROJECT.jar $DIRECTORY/server/plugins/$PROJECT.jar -cd $DIRECTORY/server || exit -if ! test -f "paperclip.jar"; then - echo "Paper not found. Downloading now." - wget https://papermc.io/api/v1/paper/1.16.3/latest/download -O paperclip.jar -fi -if [ -z "$(grep true eula.txt 2>/dev/null)" ]; then - echo - echo "$(color 32) It appears you have not agreed to Mojangs EULA yet! Press $(color 1 33)y$(colorend) $(color 32)to confirm agreement to" - read -p " Mojangs EULA, found at:$(color 1 32) https://account.mojang.com/documents/minecraft_eula $(colorend) " -n 1 -r - echo "" - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo "$(color 1 31)Aborted$(colorend)" - exit; - fi - echo "eula=true" > eula.txt -fi - -java -Xms5G -Xmx5G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC \ --XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 \ --XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 \ --XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true \ --jar paperclip.jar nogui \ No newline at end of file