Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 43 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ plugins {
}

import org.gradle.internal.os.OperatingSystem
import groovy.json.JsonOutput

version = plugin_version

ext {
if (project.hasProperty('hytale_home')) {
Expand Down Expand Up @@ -57,25 +60,38 @@ 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')
// Generate the manifest.json file with the latest properties defined in the
// build.properties file.
tasks.register('generatePluginManifest') {
group = "hytale"
description = "Generates the manifest.json dynamically in the build directory."
def outputDir = file("${project.layout.buildDirectory.get().asFile}/resources/main")
def manifestFile = file("${outputDir}/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))
if (!outputDir.exists()) outputDir.mkdirs()
def manifestData = [
Group: project.findProperty('plugin_group'),
Name: project.findProperty('plugin_name'),
Version: project.findProperty('plugin_version'),
Description: project.findProperty('plugin_description'),
Authors: project.findProperty('plugin_authors')?.split(',')?.collect { [Name: it.trim()] } ?: [],
Website: project.findProperty('plugin_url'),
ServerVersion: project.findProperty('server_version') ?: "*",
Dependencies: new groovy.json.JsonSlurper().parseText(project.findProperty('plugin_dependencies') ?: "{}"),
OptionalDependencies: new groovy.json.JsonSlurper().parseText(project.findProperty('plugin_optional_dependencies') ?: "{}"),
DisabledByDefault: project.findProperty('disabled_by_default')?.toBoolean() ?: false,
Main: project.findProperty('plugin_main_class'),
IncludesAssetPack: project.findProperty('includes_pack')?.toBoolean() ?: false
]

manifestFile.text = JsonOutput.prettyPrint(JsonOutput.toJson(manifestData))
logger.lifecycle("Hytale Manifest generated at: ${manifestFile.path}")
}
}

// Makes sure the plugin manifest is up to date.
tasks.named('processResources') {
dependsOn 'updatePluginManifest'
finalizedBy 'generatePluginManifest'
}

def createServerRunArguments(String srcDir) {
Expand Down Expand Up @@ -129,3 +145,17 @@ tasks.register('generateVSCodeLaunch') {
launchFile.text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(launchConfig))
}
}

// Runs the Hytale server directly from the terminal, automatically compiling
// your code and injecting the generated manifest from the build directory.
task runHytale(type: JavaExec) {
group = "hytale"
description = "Run the Hytale server directly from Gradle with current settings."
mainClass = 'com.hypixel.hytale.Main'
classpath = sourceSets.main.runtimeClasspath
workingDir = serverRunDir
standardInput = System.in
def buildResourcesDir = file("${project.layout.buildDirectory.get().asFile}/resources/main")
args = createServerRunArguments(buildResourcesDir.absolutePath).split(' ').collect { it.replace('"', '') }
dependsOn classes, processResources
}
54 changes: 47 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# The current version of your project. Please use semantic versioning!
version=0.0.2

# The group ID used for maven publishing. Usually the same as your package name
# but not the same as your plugin group!
maven_group=org.example
################### Environment Properties ###################

# The version of Java used by your plugin. The game is built on Java 21 but
# actually runs on Java 25.
java_version=25

# Specifies the required Hytale server version for this plugin.
# Use "*" to allow any version or a specific version string like "1.0.0".
server_version=*

# Determines if your plugin should also be loaded as an asset pack. If your
# pack contains assets, or you intend to use the in-game asset editor, you
# want this to be true.
includes_pack=true

# If true, the plugin will be installed but not activated until the user
# manually enables it in the game's plugin manager.
disabled_by_default=false

# The release channel your plugin should be built and ran against. This is
# usually release or pre-release. You can verify your settings in the
# official launcher.
Expand All @@ -29,4 +32,41 @@ load_user_mods=false
# manually. You may also want to use a custom path if you are building in
# a non-standard environment like a build server. The home path should
# the folder that contains the install and UserData folder.
# hytale_home=./test-file
# hytale_home=./test-file

####################### Maven Properties ######################

# The group ID used for maven publishing. Usually the same as your package name
# but not the same as your plugin group!
maven_group=org.example

###################### Plugin Properties ######################

# The group ID used for Hytale publishing.
plugin_group=Example

# The display name of your plugin.
plugin_name=ExamplePlugin

# The main class of your plugin, used as the entry point.
plugin_main_class=org.example.plugin.ExamplePlugin

# The current version of your project. Please use semantic versioning!
plugin_version=0.0.2

# A comma-separated list of the people or teams who created the plugin.
plugin_authors=YourNameHere, OtherNameHere

# A short summary of what your plugin does, which will be visible to users.
plugin_description=An example plugin for HyTale!

# The official website or repository URL for the plugin project.
plugin_url=example.com

# A JSON object defining other plugins required for this one to function.
# Example: {"hytale.essentials": "1.0.0"}
plugin_dependencies={}

# A JSON object defining plugins that add extra features if present,
# but are not strictly required for the plugin to run.
plugin_optional_dependencies={}
22 changes: 0 additions & 22 deletions src/main/resources/manifest.json

This file was deleted.