forked from marggx/ModelCreator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
117 lines (101 loc) · 4.12 KB
/
build.gradle
File metadata and controls
117 lines (101 loc) · 4.12 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
plugins {
id 'java'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.4.1'
}
repositories {
mavenCentral()
maven {
name = "hytale-release"
url = uri("https://maven.hytale.com/release")
}
}
ext {
def os = System.getProperty("os.name").toLowerCase()
if (os.contains("win")) {
hytaleHome = "${System.getProperty("user.home")}/AppData/Roaming/Hytale"
} else if (os.contains("mac")) {
hytaleHome = "${System.getProperty("user.home")}/Library/Application Support/Hytale"
} else {
hytaleHome = "${System.getProperty("user.home")}/.var/app/com.hypixel.HytaleLauncher/data/Hytale"
}
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
// withSourcesJar()
// withJavadocJar()
}
jar {
processResources.exclude("manifest.template.json")
}
// 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("com.hypixel.hytale:Server:2026.03.26-89796e57b")
}
// 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 version = new Date().format("yyyy.MM.dd")
def dirty = 'git status -s'.execute().text != ''
if (dirty) version += "-dev"
def hash = 'git rev-parse --verify HEAD'.execute().text.trim().substring(0, 9)
if (hash != "") version += "+${hash}"
def dependencies = configurations
.matching { c -> c.isCanBeResolved() }
.collect { c -> c.getIncoming().getResolutionResult().getAllDependencies() }
.flatten()
.unique()
.collect { ResolvedDependencyResult result -> result.getSelected().getModuleVersion() }
.unique()
def hytaleDependency = dependencies.find { dep -> dep.group == "com.hypixel.hytale" && dep.name == "Server" }
def manifestTemplateFile = file('src/main/resources/manifest.template.json')
def manifestFile = file('src/main/resources/manifest.json')
doLast {
if (!manifestTemplateFile.exists()) {
throw new GradleException("Could not find manifest.template.json at ${manifestTemplateFile.path}!")
}
def manifestJson = new JsonSlurper().parseText(manifestTemplateFile.text)
manifestJson.Version = version
manifestJson.IncludesAssetPack = includes_pack.toBoolean()
if (hytaleDependency != null) {
manifestJson.ServerVersion = hytaleDependency.version
}
manifestFile.text = JsonOutput.prettyPrint(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'
def assetsZip = file("$hytaleHome/install/$patchline/package/game/latest/Assets.zip").absolutePath
programParameters = "--allow-op --assets=\"${assetsZip}\" --disable-sentry"
if (includes_pack.toBoolean()) {
def localMods = file("$projectDir/src/main").absolutePath
programParameters += " --mods=\"${localMods}\""
}
if (load_user_mods.toBoolean()) {
def userMods = file("$hytaleHome/UserData/Mods").absolutePath
programParameters += " --mods=\"${userMods}\""
}
workingDirectory = serverRunDir.absolutePath
}
}