Initial project setup with Hytale plugin template
Add a minimal, ready-to-use Hytale plugin template including Gradle build scripts, GitHub Actions CI workflow, example plugin class, configuration and manifest files, and supporting documentation. This setup provides modern build tooling, automated server testing, and best practices for plugin development.
This commit is contained in:
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
72
.github/workflows/build.yml
vendored
Normal file
72
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
name: Build Plugin
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Java 25
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '25'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Cache Gradle Dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.gradle
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
|
||||
- name: Grant Execute Permission for Gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew shadowJar
|
||||
|
||||
- name: Run Tests
|
||||
run: ./gradlew test
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: plugin-jar
|
||||
path: build/libs/*.jar
|
||||
|
||||
release:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Java 25
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '25'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Grant Execute Permission for Gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew shadowJar
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: build/libs/*.jar
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
57
.gitignore
vendored
Normal file
57
.gitignore
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
# Gradle
|
||||
.gradle/
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
.kotlin/
|
||||
|
||||
# Server testing directory
|
||||
run/
|
||||
|
||||
# IntelliJ IDEA
|
||||
.idea/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
# Eclipse
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
# NetBeans
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
# VS Code
|
||||
.vscode/
|
||||
|
||||
# Mac OS
|
||||
.DS_Store
|
||||
|
||||
# Windows
|
||||
Thumbs.db
|
||||
desktop.ini
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Hytale Modding Community
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
350
README.md
Normal file
350
README.md
Normal file
@@ -0,0 +1,350 @@
|
||||
# Hytale Plugin Template
|
||||
|
||||
A minimal, ready-to-use template for creating Hytale plugins with modern build tools and automated testing.
|
||||
|
||||
> **✨ Builds immediately without any changes!** Clone and run `./gradlew shadowJar` to get a working plugin JAR.
|
||||
|
||||
## Features
|
||||
|
||||
✅ **Modern Build System** - Gradle with Kotlin DSL
|
||||
✅ **Automated Testing** - Custom Gradle plugin for one-command server testing
|
||||
✅ **Java 25** - Latest Java features
|
||||
✅ **ShadowJar** - Automatic dependency bundling
|
||||
✅ **CI/CD Ready** - GitHub Actions workflow included
|
||||
✅ **Minimal Structure** - Only essential files, write your own code
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- **Java 25 JDK** - [Download here](https://www.oracle.com/java/technologies/downloads/)
|
||||
- **IntelliJ IDEA** - [Download here](https://www.jetbrains.com/idea/download/) (Community Edition is fine)
|
||||
- **Git** - [Download here](https://git-scm.com/)
|
||||
|
||||
### 1. Clone or Download
|
||||
|
||||
```bash
|
||||
git clone https://github.com/yourusername/hytale-plugin-template.git
|
||||
cd hytale-plugin-template
|
||||
```
|
||||
|
||||
**The template builds immediately without any changes!**
|
||||
You can customize it later when you're ready to develop your plugin.
|
||||
|
||||
### 2. Build Immediately (No Changes Needed!)
|
||||
|
||||
The template works out-of-the-box:
|
||||
|
||||
```bash
|
||||
# Windows
|
||||
gradlew.bat shadowJar
|
||||
|
||||
# Linux/Mac
|
||||
./gradlew shadowJar
|
||||
```
|
||||
|
||||
Your plugin JAR will be in: `build/libs/TemplatePlugin-1.0.0.jar`
|
||||
|
||||
### 3. Customize Your Plugin (Optional)
|
||||
|
||||
When ready to customize, edit these files:
|
||||
|
||||
**`settings.gradle.kts`:**
|
||||
```kotlin
|
||||
rootProject.name = "your-plugin-name"
|
||||
```
|
||||
|
||||
**`gradle.properties`:**
|
||||
```properties
|
||||
pluginGroup=com.yourname
|
||||
pluginVersion=1.0.0
|
||||
pluginDescription=Your plugin description
|
||||
```
|
||||
|
||||
**`src/main/resources/manifest.json`:**
|
||||
```json
|
||||
{
|
||||
"Group": "YourName",
|
||||
"Name": "YourPluginName",
|
||||
"Main": "com.yourname.yourplugin.YourPlugin"
|
||||
}
|
||||
```
|
||||
|
||||
**Rename the main plugin class:**
|
||||
- Rename `src/main/java/com/example/templateplugin/TemplatePlugin.java`
|
||||
- Update package name to match your `pluginGroup`
|
||||
|
||||
### 4. Build Your Plugin
|
||||
|
||||
```bash
|
||||
# Windows
|
||||
gradlew.bat shadowJar
|
||||
|
||||
# Linux/Mac
|
||||
./gradlew shadowJar
|
||||
```
|
||||
|
||||
Your plugin JAR will be in: `build/libs/YourPluginName-1.0.0.jar`
|
||||
|
||||
### 5. Implement Your Plugin
|
||||
|
||||
Write your plugin code in `src/main/java/`:
|
||||
- Commands
|
||||
- Event listeners
|
||||
- Services
|
||||
- Storage
|
||||
- Utilities
|
||||
|
||||
See our [documentation](../Documentation/) for examples and patterns.
|
||||
|
||||
### 6. Test Your Plugin (Automated!)
|
||||
|
||||
```bash
|
||||
# Windows
|
||||
gradlew.bat runServer
|
||||
|
||||
# Linux/Mac
|
||||
./gradlew runServer
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Download the Hytale server (cached for future runs)
|
||||
2. Build your plugin
|
||||
3. Copy it to the server's plugins folder
|
||||
4. Start the server with interactive console
|
||||
|
||||
---
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
TemplatePlugin/
|
||||
├── .github/workflows/
|
||||
│ └── build.yml # CI/CD workflow
|
||||
├── buildSrc/
|
||||
│ ├── build.gradle.kts # Custom plugin configuration
|
||||
│ └── src/main/kotlin/
|
||||
│ └── RunHytalePlugin.kt # Automated server testing
|
||||
├── src/main/
|
||||
│ ├── java/com/example/templateplugin/
|
||||
│ │ └── TemplatePlugin.java # Minimal main class (example)
|
||||
│ └── resources/
|
||||
│ └── manifest.json # Plugin metadata
|
||||
├── .gitignore # Git ignore rules
|
||||
├── build.gradle.kts # Build configuration
|
||||
├── gradle.properties # Project properties
|
||||
├── settings.gradle.kts # Project settings
|
||||
├── LICENSE # MIT License
|
||||
└── README.md # This file
|
||||
```
|
||||
|
||||
**Note:** This is a minimal template. Create your own folder structure:
|
||||
- `commands/` - For command implementations
|
||||
- `listeners/` - For event listeners
|
||||
- `services/` - For business logic
|
||||
- `storage/` - For data persistence
|
||||
- `utils/` - For utility classes
|
||||
- `config/` - For configuration management
|
||||
|
||||
---
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Building
|
||||
|
||||
```bash
|
||||
# Compile only
|
||||
./gradlew compileJava
|
||||
|
||||
# Build plugin JAR
|
||||
./gradlew shadowJar
|
||||
|
||||
# Clean and rebuild
|
||||
./gradlew clean shadowJar
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Run server with your plugin
|
||||
./gradlew runServer
|
||||
|
||||
# Run unit tests
|
||||
./gradlew test
|
||||
|
||||
# Clean test server
|
||||
rm -rf run/
|
||||
```
|
||||
|
||||
### Debugging
|
||||
|
||||
```bash
|
||||
# Run server in debug mode
|
||||
./gradlew runServer -Pdebug
|
||||
|
||||
# Then connect your IDE debugger to localhost:5005
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Customization
|
||||
|
||||
### Adding Dependencies
|
||||
|
||||
Edit `build.gradle.kts`:
|
||||
|
||||
```kotlin
|
||||
dependencies {
|
||||
// Hytale API (provided by server)
|
||||
compileOnly(files("libs/hytale-server.jar"))
|
||||
|
||||
// Your dependencies (will be bundled)
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
|
||||
// Test dependencies
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
|
||||
}
|
||||
```
|
||||
|
||||
### Configuring Server Testing
|
||||
|
||||
Edit `build.gradle.kts`:
|
||||
|
||||
```kotlin
|
||||
runHytale {
|
||||
jarUrl = "https://example.com/hytale-server.jar" // Update when available
|
||||
}
|
||||
```
|
||||
|
||||
### Implementing Your Plugin
|
||||
|
||||
**Recommended folder structure:**
|
||||
```
|
||||
src/main/java/com/yourname/yourplugin/
|
||||
├── YourPlugin.java # Main class
|
||||
├── commands/ # Commands
|
||||
├── listeners/ # Event listeners
|
||||
├── services/ # Business logic
|
||||
├── storage/ # Data persistence
|
||||
├── config/ # Configuration
|
||||
└── utils/ # Utilities
|
||||
```
|
||||
|
||||
**See our documentation for examples:**
|
||||
- [Getting Started with Plugins](../Documentation/07-getting-started-with-plugins.md)
|
||||
- [Advanced Plugin Patterns](../Documentation/12-advanced-plugin-patterns.md)
|
||||
- [Common Plugin Features](../Documentation/14-common-plugin-features.md)
|
||||
|
||||
---
|
||||
|
||||
## CI/CD
|
||||
|
||||
This template includes a GitHub Actions workflow that:
|
||||
|
||||
1. ✅ Builds your plugin on every push
|
||||
2. ✅ Runs tests
|
||||
3. ✅ Uploads artifacts
|
||||
4. ✅ Creates releases (when you tag)
|
||||
|
||||
### Creating a Release
|
||||
|
||||
```bash
|
||||
git tag v1.0.0
|
||||
git push origin v1.0.0
|
||||
```
|
||||
|
||||
GitHub Actions will automatically build and create a release with your plugin JAR.
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### ✅ DO:
|
||||
|
||||
- Use the Service-Storage pattern for data management
|
||||
- Write unit tests for your business logic
|
||||
- Use structured logging (not `System.out.println`)
|
||||
- Handle errors gracefully
|
||||
- Document your public API
|
||||
- Version your releases semantically (1.0.0, 1.1.0, etc.)
|
||||
|
||||
### ❌ DON'T:
|
||||
|
||||
- Hardcode configuration values
|
||||
- Block the main thread with heavy operations
|
||||
- Ignore exceptions
|
||||
- Use deprecated APIs
|
||||
- Commit sensitive data (API keys, passwords)
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Build Fails
|
||||
|
||||
```bash
|
||||
# Clean and rebuild
|
||||
./gradlew clean build --refresh-dependencies
|
||||
```
|
||||
|
||||
### Server Won't Start
|
||||
|
||||
1. Check that `jarUrl` in `build.gradle.kts` is correct
|
||||
2. Verify Java 25 is installed: `java -version`
|
||||
3. Check logs in `run/logs/`
|
||||
|
||||
### Plugin Not Loading
|
||||
|
||||
1. Verify `manifest.json` has correct `Main` class
|
||||
2. Check server logs for errors
|
||||
3. Ensure all dependencies are bundled in JAR
|
||||
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
For detailed guides on plugin development, see:
|
||||
|
||||
- [Hytale Modding Documentation](https://github.com/yourusername/hytale-modding/tree/main/Documentation)
|
||||
- [Getting Started with Plugins](../Documentation/07-getting-started-with-plugins.md)
|
||||
- [Advanced Plugin Patterns](../Documentation/12-advanced-plugin-patterns.md)
|
||||
- [Common Plugin Features](../Documentation/14-common-plugin-features.md)
|
||||
|
||||
---
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please:
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a feature branch
|
||||
3. Make your changes
|
||||
4. Submit a pull request
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
This template is released under the MIT License. You are free to use it for any purpose.
|
||||
|
||||
---
|
||||
|
||||
## Support
|
||||
|
||||
- **Issues:** [GitHub Issues](https://github.com/yourusername/hytale-plugin-template/issues)
|
||||
- **Documentation:** [Hytale Modding Docs](https://github.com/yourusername/hytale-modding)
|
||||
- **Community:** Join the Hytale modding community
|
||||
|
||||
---
|
||||
|
||||
## Credits
|
||||
|
||||
Created by the Hytale modding community.
|
||||
|
||||
Based on best practices from production Hytale plugins.
|
||||
|
||||
---
|
||||
|
||||
**Happy Modding! 🎮**
|
||||
87
build.gradle.kts
Normal file
87
build.gradle.kts
Normal file
@@ -0,0 +1,87 @@
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("com.gradleup.shadow") version "9.3.1"
|
||||
id("run-hytale")
|
||||
}
|
||||
|
||||
group = findProperty("pluginGroup") as String? ?: "com.example"
|
||||
version = findProperty("pluginVersion") as String? ?: "1.0.0"
|
||||
description = findProperty("pluginDescription") as String? ?: "A Hytale plugin template"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Hytale Server API (provided by server at runtime)
|
||||
compileOnly(files("libs/hytale-server.jar"))
|
||||
|
||||
// Common dependencies (will be bundled in JAR)
|
||||
implementation("com.google.code.gson:gson:2.10.1")
|
||||
implementation("org.jetbrains:annotations:24.1.0")
|
||||
|
||||
// Test dependencies
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
// Configure server testing
|
||||
runHytale {
|
||||
// TODO: Update this URL when Hytale server is available
|
||||
jarUrl = "https://example.com/hytale-server.jar"
|
||||
}
|
||||
|
||||
tasks {
|
||||
// Configure Java compilation
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release = 25
|
||||
}
|
||||
|
||||
// Configure resource processing
|
||||
processResources {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
|
||||
// Replace placeholders in manifest.json
|
||||
val props = mapOf(
|
||||
"group" to project.group,
|
||||
"version" to project.version,
|
||||
"description" to project.description
|
||||
)
|
||||
inputs.properties(props)
|
||||
|
||||
filesMatching("manifest.json") {
|
||||
expand(props)
|
||||
}
|
||||
}
|
||||
|
||||
// Configure ShadowJar (bundle dependencies)
|
||||
shadowJar {
|
||||
archiveBaseName.set(rootProject.name)
|
||||
archiveClassifier.set("")
|
||||
|
||||
// Relocate dependencies to avoid conflicts
|
||||
relocate("com.google.gson", "com.yourplugin.libs.gson")
|
||||
|
||||
// Minimize JAR size (removes unused classes)
|
||||
minimize()
|
||||
}
|
||||
|
||||
// Configure tests
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
// Make build depend on shadowJar
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
// Configure Java toolchain
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(25))
|
||||
}
|
||||
}
|
||||
17
buildSrc/build.gradle.kts
Normal file
17
buildSrc/build.gradle.kts
Normal file
@@ -0,0 +1,17 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
`java-gradle-plugin`
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("runHytale") {
|
||||
id = "run-hytale"
|
||||
implementationClass = "RunHytalePlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
166
buildSrc/src/main/kotlin/RunHytalePlugin.kt
Normal file
166
buildSrc/src/main/kotlin/RunHytalePlugin.kt
Normal file
@@ -0,0 +1,166 @@
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import java.security.MessageDigest
|
||||
|
||||
/**
|
||||
* Custom Gradle plugin for automated Hytale server testing.
|
||||
*
|
||||
* Usage:
|
||||
* runHytale {
|
||||
* jarUrl = "https://example.com/hytale-server.jar"
|
||||
* }
|
||||
*
|
||||
* ./gradlew runServer
|
||||
*/
|
||||
open class RunHytalePlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
// Create extension for configuration
|
||||
val extension = project.extensions.create("runHytale", RunHytaleExtension::class.java)
|
||||
|
||||
// Register the runServer task
|
||||
val runTask: TaskProvider<RunServerTask> = project.tasks.register(
|
||||
"runServer",
|
||||
RunServerTask::class.java
|
||||
) {
|
||||
jarUrl.set(extension.jarUrl)
|
||||
group = "hytale"
|
||||
description = "Downloads and runs the Hytale server with your plugin"
|
||||
}
|
||||
|
||||
// Make runServer depend on shadowJar (build plugin first)
|
||||
project.tasks.findByName("shadowJar")?.let {
|
||||
runTask.configure {
|
||||
dependsOn(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension for configuring the RunHytale plugin.
|
||||
*/
|
||||
open class RunHytaleExtension {
|
||||
var jarUrl: String = "https://example.com/hytale-server.jar"
|
||||
}
|
||||
|
||||
/**
|
||||
* Task that downloads, sets up, and runs a Hytale server with the plugin.
|
||||
*/
|
||||
open class RunServerTask : DefaultTask() {
|
||||
|
||||
@Input
|
||||
val jarUrl = project.objects.property(String::class.java)
|
||||
|
||||
@TaskAction
|
||||
fun run() {
|
||||
// Create directories
|
||||
val runDir = File(project.projectDir, "run").apply { mkdirs() }
|
||||
val pluginsDir = File(runDir, "plugins").apply { mkdirs() }
|
||||
val jarFile = File(runDir, "server.jar")
|
||||
|
||||
// Cache directory for downloaded server JARs
|
||||
val cacheDir = File(
|
||||
project.layout.buildDirectory.asFile.get(),
|
||||
"hytale-cache"
|
||||
).apply { mkdirs() }
|
||||
|
||||
// Compute hash of URL for caching
|
||||
val urlHash = MessageDigest.getInstance("SHA-256")
|
||||
.digest(jarUrl.get().toByteArray())
|
||||
.joinToString("") { "%02x".format(it) }
|
||||
val cachedJar = File(cacheDir, "$urlHash.jar")
|
||||
|
||||
// Download server JAR if not cached
|
||||
if (!cachedJar.exists()) {
|
||||
println("Downloading Hytale server from ${jarUrl.get()}")
|
||||
try {
|
||||
URI.create(jarUrl.get()).toURL().openStream().use { input ->
|
||||
cachedJar.outputStream().use { output ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
}
|
||||
println("Server JAR downloaded and cached")
|
||||
} catch (e: Exception) {
|
||||
println("ERROR: Failed to download server JAR")
|
||||
println("Make sure the jarUrl in build.gradle.kts is correct")
|
||||
println("Error: ${e.message}")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
println("Using cached server JAR")
|
||||
}
|
||||
|
||||
// Copy server JAR to run directory
|
||||
cachedJar.copyTo(jarFile, overwrite = true)
|
||||
|
||||
// Copy plugin JAR to plugins folder
|
||||
project.tasks.findByName("shadowJar")?.outputs?.files?.firstOrNull()?.let { shadowJar ->
|
||||
val targetFile = File(pluginsDir, shadowJar.name)
|
||||
shadowJar.copyTo(targetFile, overwrite = true)
|
||||
println("Plugin copied to: ${targetFile.absolutePath}")
|
||||
} ?: run {
|
||||
println("WARNING: Could not find shadowJar output")
|
||||
}
|
||||
|
||||
println("Starting Hytale server...")
|
||||
println("Press Ctrl+C to stop the server")
|
||||
|
||||
// Check if debug mode is enabled
|
||||
val debugMode = project.hasProperty("debug")
|
||||
val javaArgs = mutableListOf<String>()
|
||||
|
||||
if (debugMode) {
|
||||
javaArgs.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005")
|
||||
println("Debug mode enabled. Connect debugger to port 5005")
|
||||
}
|
||||
|
||||
javaArgs.addAll(listOf("-jar", jarFile.name))
|
||||
|
||||
// Start the server process
|
||||
val process = ProcessBuilder("java", *javaArgs.toTypedArray())
|
||||
.directory(runDir)
|
||||
.start()
|
||||
|
||||
// Handle graceful shutdown
|
||||
project.gradle.buildFinished {
|
||||
if (process.isAlive) {
|
||||
println("\nStopping server...")
|
||||
process.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
// Forward stdout to console
|
||||
Thread {
|
||||
process.inputStream.bufferedReader().useLines { lines ->
|
||||
lines.forEach { println(it) }
|
||||
}
|
||||
}.start()
|
||||
|
||||
// Forward stderr to console
|
||||
Thread {
|
||||
process.errorStream.bufferedReader().useLines { lines ->
|
||||
lines.forEach { System.err.println(it) }
|
||||
}
|
||||
}.start()
|
||||
|
||||
// Forward stdin to server (for commands)
|
||||
Thread {
|
||||
System.`in`.bufferedReader().useLines { lines ->
|
||||
lines.forEach {
|
||||
process.outputStream.write((it + "\n").toByteArray())
|
||||
process.outputStream.flush()
|
||||
}
|
||||
}
|
||||
}.start()
|
||||
|
||||
// Wait for server to exit
|
||||
val exitCode = process.waitFor()
|
||||
println("Server exited with code $exitCode")
|
||||
}
|
||||
}
|
||||
10
gradle.properties
Normal file
10
gradle.properties
Normal file
@@ -0,0 +1,10 @@
|
||||
# Project Information
|
||||
pluginGroup=com.example
|
||||
pluginVersion=1.0.0
|
||||
pluginDescription=A Hytale plugin template with best practices
|
||||
|
||||
# Gradle Configuration
|
||||
org.gradle.parallel=true
|
||||
org.gradle.caching=true
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
244
gradlew
vendored
Normal file
244
gradlew
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
92
gradlew.bat
vendored
Normal file
92
gradlew.bat
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
1
settings.gradle.kts
Normal file
1
settings.gradle.kts
Normal file
@@ -0,0 +1 @@
|
||||
rootProject.name = "TemplatePlugin"
|
||||
54
src/main/java/com/example/templateplugin/TemplatePlugin.java
Normal file
54
src/main/java/com/example/templateplugin/TemplatePlugin.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.example.templateplugin;
|
||||
|
||||
/**
|
||||
* Main plugin class.
|
||||
*
|
||||
* TODO: Implement your plugin logic here.
|
||||
*
|
||||
* @author YourName
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class TemplatePlugin {
|
||||
|
||||
private static TemplatePlugin instance;
|
||||
|
||||
/**
|
||||
* Constructor - Called when plugin is loaded.
|
||||
*/
|
||||
public TemplatePlugin() {
|
||||
instance = this;
|
||||
System.out.println("[TemplatePlugin] Plugin loaded!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when plugin is enabled.
|
||||
*/
|
||||
public void onEnable() {
|
||||
System.out.println("[TemplatePlugin] Plugin enabled!");
|
||||
|
||||
// TODO: Initialize your plugin here
|
||||
// - Load configuration
|
||||
// - Register event listeners
|
||||
// - Register commands
|
||||
// - Start services
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when plugin is disabled.
|
||||
*/
|
||||
public void onDisable() {
|
||||
System.out.println("[TemplatePlugin] Plugin disabled!");
|
||||
|
||||
// TODO: Cleanup your plugin here
|
||||
// - Save data
|
||||
// - Stop services
|
||||
// - Close connections
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin instance.
|
||||
*/
|
||||
public static TemplatePlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
5
src/main/resources/config.json
Normal file
5
src/main/resources/config.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"pluginName": "TemplatePlugin",
|
||||
"version": "1.0.0",
|
||||
"debugMode": false
|
||||
}
|
||||
19
src/main/resources/manifest.json
Normal file
19
src/main/resources/manifest.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Group": "TemplatePlugin",
|
||||
"Name": "TemplatePlugin",
|
||||
"Version": "1.0.0",
|
||||
"Description": "A Hytale plugin template",
|
||||
"Authors": [
|
||||
{
|
||||
"Name": "YourName",
|
||||
"Email": "your.email@example.com",
|
||||
"Url": "https://your-website.com"
|
||||
}
|
||||
],
|
||||
"Website": "https://github.com/yourusername/hytale-plugin-template",
|
||||
"Main": "com.example.templateplugin.TemplatePlugin",
|
||||
"ServerVersion": "*",
|
||||
"Dependencies": {},
|
||||
"OptionalDependencies": {},
|
||||
"DisabledByDefault": false
|
||||
}
|
||||
Reference in New Issue
Block a user