generated from LabyMod/addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f2d147e
Showing
18 changed files
with
1,719 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: LabyAddon Build | ||
|
||
on: | ||
push: | ||
branches: [ "master", "main" ] | ||
pull_request: | ||
branches: [ "master", "main" ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'corretto' | ||
java-version: '17' | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
- name: Build with Gradle | ||
run: ./gradlew build --full-stacktrace | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Artifacts | ||
path: build/libs/*-release.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Java template | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
### JetBrains template | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
/.idea/ | ||
run/** | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
### Gradle template | ||
.gradle | ||
/**/build/ | ||
|
||
# Ignore Gradle GUI config | ||
gradle-app.setting | ||
|
||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) | ||
!gradle-wrapper.jar | ||
|
||
# Cache of project | ||
.gradletasknamecache | ||
|
||
docs/generated/ | ||
|
||
# Project | ||
run/ | ||
|
||
# LabyGradle | Addon Plugin | ||
build-data.txt | ||
.assetsroot | ||
|
||
# Don't ignore libraries | ||
!libs/*.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version = "0.1.0" | ||
|
||
plugins { | ||
id("java-library") | ||
} | ||
|
||
dependencies { | ||
labyApi("api") | ||
|
||
// If you want to use external libraries, you can do that here. | ||
// The dependencies that are specified here are loaded into your project but will also | ||
// automatically be downloaded by labymod, but only if the repository is public. | ||
// If it is private, you have to add and compile the dependency manually. | ||
// You have to specify the repository, there are getters for maven central and sonatype, every | ||
// other repository has to be specified with their url. Example: | ||
// maven(mavenCentral(), "org.apache.httpcomponents:httpclient:4.5.13") | ||
} | ||
|
||
labyModProcessor { | ||
referenceType = net.labymod.gradle.core.processor.ReferenceType.INTERFACE | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
plugins { | ||
id("java-library") | ||
id("net.labymod.gradle") | ||
id("net.labymod.gradle.addon") | ||
} | ||
|
||
group = "org.example" | ||
version = "1.0.0" | ||
|
||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17)) | ||
|
||
labyMod { | ||
defaultPackageName = "org.example" //change this to your main package name (used by all modules) | ||
addonInfo { | ||
namespace = "example" | ||
displayName = "ExampleAddon" | ||
author = "Example Author" | ||
description = "Example Description" | ||
minecraftVersion = "*" | ||
version = System.getenv().getOrDefault("VERSION", "0.0.1") | ||
} | ||
|
||
minecraft { | ||
registerVersions( | ||
"1.8.9", | ||
"1.12.2", | ||
"1.16.5", | ||
"1.17.1", | ||
"1.18.2", | ||
"1.19.2", | ||
"1.19.3", | ||
"1.19.4", | ||
"1.20.1" | ||
) { version, provider -> | ||
configureRun(provider, version) | ||
} | ||
|
||
subprojects.forEach { | ||
if (it.name != "game-runner") { | ||
filter(it.name) | ||
} | ||
} | ||
} | ||
|
||
addonDev { | ||
productionRelease() | ||
} | ||
} | ||
|
||
subprojects { | ||
plugins.apply("java-library") | ||
plugins.apply("net.labymod.gradle") | ||
plugins.apply("net.labymod.gradle.addon") | ||
|
||
repositories { | ||
maven("https://libraries.minecraft.net/") | ||
maven("https://repo.spongepowered.org/repository/maven-public/") | ||
} | ||
} | ||
|
||
fun configureRun(provider: net.labymod.gradle.core.minecraft.provider.VersionProvider, gameVersion: String) { | ||
provider.runConfiguration { | ||
mainClass = "net.minecraft.launchwrapper.Launch" | ||
jvmArgs("-Dnet.labymod.running-version=${gameVersion}") | ||
jvmArgs("-Dmixin.debug=true") | ||
jvmArgs("-Dnet.labymod.debugging.all=true") | ||
jvmArgs("-Dmixin.env.disableRefMap=true") | ||
|
||
args("--tweakClass", "net.labymod.core.loader.vanilla.launchwrapper.LabyModLaunchWrapperTweaker") | ||
args("--labymod-dev-environment", "true") | ||
args("--addon-dev-environment", "true") | ||
} | ||
|
||
provider.javaVersion = when (gameVersion) { | ||
else -> { | ||
JavaVersion.VERSION_17 | ||
} | ||
} | ||
|
||
provider.mixin { | ||
val mixinMinVersion = when (gameVersion) { | ||
"1.8.9", "1.12.2", "1.16.5" -> { | ||
"0.6.6" | ||
} | ||
|
||
else -> { | ||
"0.8.2" | ||
} | ||
} | ||
|
||
minVersion = mixinMinVersion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version = "0.1.0" | ||
|
||
plugins { | ||
id("java-library") | ||
} | ||
|
||
dependencies { | ||
api(project(":api")) | ||
|
||
// If you want to use external libraries, you can do that here. | ||
// The dependencies that are specified here are loaded into your project but will also | ||
// automatically be downloaded by labymod, but only if the repository is public. | ||
// If it is private, you have to add and compile the dependency manually. | ||
// You have to specify the repository, there are getters for maven central and sonatype, every | ||
// other repository has to be specified with their url. Example: | ||
// maven(mavenCentral(), "org.apache.httpcomponents:httpclient:4.5.13") | ||
} | ||
|
||
labyModProcessor { | ||
referenceType = net.labymod.gradle.core.processor.ReferenceType.DEFAULT | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.example.core; | ||
|
||
import net.labymod.api.addon.LabyAddon; | ||
import net.labymod.api.models.addon.annotation.AddonMain; | ||
import org.example.core.commands.ExamplePingCommand; | ||
import org.example.core.listener.ExampleGameTickListener; | ||
|
||
@AddonMain | ||
public class ExampleAddon extends LabyAddon<ExampleConfiguration> { | ||
|
||
@Override | ||
protected void enable() { | ||
this.registerSettingCategory(); | ||
|
||
this.registerListener(new ExampleGameTickListener(this)); | ||
this.registerCommand(new ExamplePingCommand()); | ||
|
||
this.logger().info("Enabled the Addon"); | ||
} | ||
|
||
@Override | ||
protected Class<ExampleConfiguration> configurationClass() { | ||
return ExampleConfiguration.class; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
core/src/main/java/org/example/core/ExampleConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.example.core; | ||
|
||
import net.labymod.api.addon.AddonConfig; | ||
import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; | ||
import net.labymod.api.configuration.loader.annotation.ConfigName; | ||
import net.labymod.api.configuration.loader.property.ConfigProperty; | ||
|
||
@ConfigName("settings") | ||
public class ExampleConfiguration extends AddonConfig { | ||
|
||
@SwitchSetting | ||
private final ConfigProperty<Boolean> enabled = new ConfigProperty<>(true); | ||
|
||
@Override | ||
public ConfigProperty<Boolean> enabled() { | ||
return this.enabled; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
core/src/main/java/org/example/core/commands/ExamplePingCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.example.core.commands; | ||
|
||
import net.labymod.api.client.chat.command.Command; | ||
import net.labymod.api.client.component.Component; | ||
import net.labymod.api.client.component.format.NamedTextColor; | ||
|
||
public class ExamplePingCommand extends Command { | ||
|
||
public ExamplePingCommand() { | ||
super("ping", "pong"); | ||
|
||
this.withSubCommand(new ExamplePingSubCommand()); | ||
} | ||
|
||
@Override | ||
public boolean execute(String prefix, String[] arguments) { | ||
if (prefix.equalsIgnoreCase("ping")) { | ||
this.displayMessage(Component.text("Ping!", NamedTextColor.AQUA)); | ||
return false; | ||
} | ||
|
||
this.displayMessage(Component.text("Pong!", NamedTextColor.GOLD)); | ||
return true; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
core/src/main/java/org/example/core/commands/ExamplePingSubCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.example.core.commands; | ||
|
||
import net.labymod.api.client.chat.command.SubCommand; | ||
import net.labymod.api.client.component.Component; | ||
import net.labymod.api.client.component.format.NamedTextColor; | ||
|
||
public class ExamplePingSubCommand extends SubCommand { | ||
|
||
protected ExamplePingSubCommand() { | ||
super("pong"); | ||
} | ||
|
||
@Override | ||
public boolean execute(String prefix, String[] arguments) { | ||
this.displayMessage(Component.text("Ping Pong!", NamedTextColor.GRAY)); | ||
return true; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
core/src/main/java/org/example/core/listener/ExampleGameTickListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.example.core.listener; | ||
|
||
import net.labymod.api.event.Phase; | ||
import net.labymod.api.event.Subscribe; | ||
import net.labymod.api.event.client.lifecycle.GameTickEvent; | ||
import org.example.core.ExampleAddon; | ||
|
||
public class ExampleGameTickListener { | ||
|
||
private final ExampleAddon addon; | ||
|
||
public ExampleGameTickListener(ExampleAddon addon) { | ||
this.addon = addon; | ||
} | ||
|
||
@Subscribe | ||
public void onGameTick(GameTickEvent event) { | ||
if (event.phase() != Phase.PRE) { | ||
return; | ||
} | ||
|
||
this.addon.logger().info(this.addon.configuration().enabled().get() ? "enabled" : "disabled"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"example": { | ||
"settings": { | ||
"name": "ExampleAddon", | ||
"enabled": { | ||
"name": "Enabled" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.gradle.jvmargs=-Xmx4096m |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.