Files
TieredRepairKits/build.gradle

79 lines
2.9 KiB
Groovy

plugins {
id 'java'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.3'
}
ext {
def os = System.getProperty("os.name").toLowerCase()
def userHome = System.getProperty("user.home")
if (os.contains("win")) {
hytaleHome = "${userHome}/AppData/Roaming/Hytale"
} else if (os.contains("mac")) {
hytaleHome = "${userHome}/Library/Application Support/Hytale"
} else {
def localHytaleHome = "${userHome}/.local/share/Hytale"
def flatpakHytaleHome = "${userHome}/.var/app/com.hypixel.HytaleLauncher/data/Hytale"
hytaleHome = file(localHytaleHome).exists() ? localHytaleHome : flatpakHytaleHome
}
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
}
// Quiet warnings about missing Javadocs.
javadoc {
options.addStringOption('Xdoclint:-missing', '-quiet')
}
// Adds the Hytale server as a build dependency, allowing you to reference and
// compile against their code. This requires you to have Hytale installed using
// the official launcher for now.
dependencies {
implementation(files("$hytaleHome/install/$patchline/package/game/latest/Server/HytaleServer.jar"))
}
// Create the working directory to run the server if it does not already exist.
def serverRunDir = file("$projectDir/run")
if (!serverRunDir.exists()) {
serverRunDir.mkdirs()
}
// Updates the manifest.json file with the latest properties defined in the
// build.properties file. Currently we update the version and if packs are
// included with the plugin.
tasks.register('updatePluginManifest') {
def manifestFile = file('src/main/resources/manifest.json')
doLast {
if (!manifestFile.exists()) {
throw new GradleException("Could not find manifest.json at ${manifestFile.path}!")
}
def manifestJson = new groovy.json.JsonSlurper().parseText(manifestFile.text)
manifestJson.Version = version
manifestJson.IncludesAssetPack = includes_pack.toBoolean()
manifestFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(manifestJson))
}
}
// Makes sure the plugin manifest is up to date.
tasks.named('processResources') {
dependsOn 'updatePluginManifest'
}
// Creates a run configuration in IDEA that will run the Hytale server with
// your plugin and the default assets.
idea.project.settings.runConfigurations {
'HytaleServer'(org.jetbrains.gradle.ext.Application) {
mainClass = 'com.hypixel.hytale.Main'
moduleName = project.idea.module.name + '.main'
programParameters = "--allow-op --disable-sentry --assets=$hytaleHome/install/$patchline/package/game/latest/Assets.zip"
if (includes_pack.toBoolean()) {
programParameters += " --mods=${sourceSets.main.java.srcDirs.first().parentFile.absolutePath}"
}
if (load_user_mods.toBoolean()) {
programParameters += " --mods=$hytaleHome/UserData/Mods"
}
workingDirectory = serverRunDir.absolutePath
}
}