Skip to content

Commit 2f8cc6d

Browse files
committed
add addon template
0 parents  commit 2f8cc6d

22 files changed

+2080
-0
lines changed

.editorconfig

+1,043
Large diffs are not rendered by default.

.github/workflows/build.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name : LabyAddon Build
2+
3+
on :
4+
push :
5+
branches : [ "master", "main" ]
6+
pull_request :
7+
branches : [ "master", "main" ]
8+
workflow_dispatch :
9+
10+
env :
11+
PUBLIC_RELEASE_BUILD : true
12+
PUBLIC_RELEASE_BUILD_TOKEN : ${{ secrets.PUBLIC_RELEASE_BUILD_TOKEN }}
13+
14+
jobs :
15+
build :
16+
runs-on : ubuntu-latest
17+
steps :
18+
- uses : actions/checkout@v3
19+
- name : Set up JDK 17
20+
uses : actions/setup-java@v3
21+
with :
22+
distribution : 'corretto'
23+
java-version : '17'
24+
- name : Grant execute permission for gradlew
25+
run : chmod +x gradlew
26+
- name : Build with Gradle
27+
run : ./gradlew build --full-stacktrace
28+
- name : Create Release Jar
29+
run : ./gradlew createReleaseJar --full-stacktrace
30+
- name : Upload Artifact
31+
uses : actions/upload-artifact@v3
32+
with :
33+
name : Artifacts
34+
path : build/libs/release-*

.gitignore

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Java template
3+
# Compiled class file
4+
*.class
5+
6+
# Log file
7+
*.log
8+
9+
# BlueJ files
10+
*.ctxt
11+
12+
# Mobile Tools for Java (J2ME)
13+
.mtj.tmp/
14+
15+
# Package Files #
16+
*.jar
17+
*.war
18+
*.nar
19+
*.ear
20+
*.zip
21+
*.tar.gz
22+
*.rar
23+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
24+
hs_err_pid*
25+
26+
### JetBrains template
27+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
28+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
29+
30+
# User-specific stuff
31+
.idea/**/workspace.xml
32+
.idea/**/tasks.xml
33+
.idea/**/usage.statistics.xml
34+
.idea/**/dictionaries
35+
.idea/**/shelf
36+
.idea/**/misc.xml
37+
.idea/**/discord.xml
38+
.idea/**/encodings.xml
39+
.idea/codeStyles/
40+
.idea/sonarlint/
41+
42+
# Generated files
43+
.idea/**/contentModel.xml
44+
.idea/**/jarRepositories.xml
45+
.idea/**/uiDesigner.xml
46+
.idea/**/inspectionProfiles
47+
.idea/**/.name
48+
.idea/**/vcs.xml
49+
.idea/**/compiler.xml
50+
.idea/**/libraries-with-intellij-classes.xml
51+
run/**
52+
53+
# Sensitive or high-churn files
54+
.idea/**/dataSources/
55+
.idea/**/dataSources.ids
56+
.idea/**/dataSources.local.xml
57+
.idea/**/sqlDataSources.xml
58+
.idea/**/dynamic.xml
59+
.idea/**/dbnavigator.xml
60+
.idea/kotlinScripting.xml
61+
62+
# Gradle
63+
.idea/**/gradle.xml
64+
.idea/**/libraries
65+
66+
# Gradle and Maven with auto-import
67+
# When using Gradle or Maven with auto-import, you should exclude module files,
68+
# since they will be recreated, and may cause churn. Uncomment if using
69+
# auto-import.
70+
# .idea/artifacts
71+
# .idea/compiler.xml
72+
.idea/modules.xml
73+
.idea/*.iml
74+
# .idea/modules
75+
# *.iml
76+
# *.ipr
77+
78+
# CMake
79+
cmake-build-*/
80+
81+
# Mongo Explorer plugin
82+
.idea/**/mongoSettings.xml
83+
84+
# File-based project format
85+
*.iws
86+
87+
# IntelliJ
88+
out/
89+
90+
# mpeltonen/sbt-idea plugin
91+
.idea_modules/
92+
93+
# JIRA plugin
94+
atlassian-ide-plugin.xml
95+
96+
# Cursive Clojure plugin
97+
.idea/replstate.xml
98+
99+
# Crashlytics plugin (for Android Studio and IntelliJ)
100+
com_crashlytics_export_strings.xml
101+
crashlytics.properties
102+
crashlytics-build.properties
103+
fabric.properties
104+
105+
# Editor-based Rest Client
106+
.idea/httpRequests
107+
108+
# Android studio 3.1+ serialized cache file
109+
.idea/caches/build_file_checksums.ser
110+
111+
### Gradle template
112+
.gradle
113+
/**/build/
114+
115+
# Ignore Gradle GUI config
116+
gradle-app.setting
117+
118+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
119+
!gradle-wrapper.jar
120+
121+
# Cache of project
122+
.gradletasknamecache
123+
124+
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
125+
# gradle/wrapper/gradle-wrapper.properties
126+
127+
.idea/modules/
128+
129+
.idea/intellij-javadocs-4.0.1.xml
130+
docs/generated/
131+
132+
# Project
133+
run/
134+
135+
# LabyGradle | Addon Plugin
136+
build-data.txt

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/build.gradle.kts

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version = "0.1.0"
2+
3+
plugins {
4+
id("java-library")
5+
}
6+
7+
repositories {
8+
mavenLocal()
9+
}
10+
11+
dependencies {
12+
labyProcessor()
13+
labyApi("api")
14+
}
15+
16+
java {
17+
sourceCompatibility = JavaVersion.VERSION_1_8
18+
targetCompatibility = JavaVersion.VERSION_1_8
19+
}
20+
21+
tasks.compileJava {
22+
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
23+
targetCompatibility = JavaVersion.VERSION_1_8.toString()
24+
}

build.gradle.kts

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
buildscript {
2+
repositories {
3+
var bearerToken = System.getenv("LABYMOD_BEARER_TOKEN")
4+
5+
if (bearerToken == null && project.hasProperty("net.labymod.distributor.bearer-token")) {
6+
bearerToken = project.property("net.labymod.distributor.bearer-token").toString()
7+
}
8+
9+
maven("https://dist.labymod.net/api/v1/maven/release/") {
10+
name = "LabyMod Distributor"
11+
12+
authentication {
13+
create<HttpHeaderAuthentication>("header")
14+
}
15+
16+
credentials(HttpHeaderCredentials::class) {
17+
name = "Authorization"
18+
value = "Bearer $bearerToken"
19+
}
20+
}
21+
22+
23+
maven("https://repo.spongepowered.org/repository/maven-public") {
24+
name = "SpongePowered Repository"
25+
}
26+
27+
mavenLocal()
28+
}
29+
30+
dependencies {
31+
classpath("net.labymod.gradle", "addon", "0.2.42")
32+
}
33+
}
34+
35+
plugins {
36+
id("java-library")
37+
}
38+
39+
group = "org.example"
40+
version = "1.0.0"
41+
42+
plugins.apply("net.labymod.gradle.addon")
43+
44+
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
45+
46+
subprojects {
47+
plugins.apply("java-library")
48+
plugins.apply("net.labymod.gradle.addon")
49+
50+
repositories {
51+
maven("https://libraries.minecraft.net/")
52+
maven("https://repo.spongepowered.org/repository/maven-public/")
53+
mavenLocal()
54+
}
55+
56+
tasks.compileJava {
57+
options.encoding = "UTF-8"
58+
}
59+
}
60+
61+
addon {
62+
addonInfo {
63+
namespace("example")
64+
displayName("Example Addon")
65+
author("Example Author")
66+
description("An Example Description!")
67+
version(System.getenv().getOrDefault("VERSION", "0.0.0"))
68+
69+
//you can add maven dependencies here. the dependencies will then be downloaded by labymod.
70+
//mavenDependencies().add(MavenDependency("https://repo.maven.apache.org/maven2/", "com.google.guava:guava:31.1-jre"))
71+
}
72+
73+
dev {
74+
releaseChannel = "improvement-addon-api"
75+
commitReference = "unknown"
76+
}
77+
78+
internalRelease()
79+
}

core/build.gradle.kts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version = "0.1.0"
2+
3+
plugins {
4+
id("java-library")
5+
}
6+
7+
repositories {
8+
mavenLocal()
9+
}
10+
11+
dependencies {
12+
labyProcessor()
13+
api(project(":api"))
14+
}
15+
16+
addon {
17+
internalRelease()
18+
}
19+
20+
java {
21+
sourceCompatibility = JavaVersion.VERSION_1_8
22+
targetCompatibility = JavaVersion.VERSION_1_8
23+
}
24+
25+
tasks.compileJava {
26+
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
27+
targetCompatibility = JavaVersion.VERSION_1_8.toString()
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.example.core;
2+
3+
import com.google.inject.Singleton;
4+
import net.labymod.api.addon.LabyAddon;
5+
import net.labymod.api.models.addon.annotation.AddonListener;
6+
import org.example.core.commands.ExamplePingCommand;
7+
import org.example.core.listener.ExampleGameTickListener;
8+
9+
@Singleton
10+
@AddonListener
11+
public class ExampleAddon extends LabyAddon<ExampleConfiguration> {
12+
13+
@Override
14+
protected void enable() {
15+
this.registerSettingCategory();
16+
17+
this.registerListener(ExampleGameTickListener.class);
18+
this.registerCommand(ExamplePingCommand.class);
19+
20+
this.logger().info("Enabled the Addon");
21+
}
22+
23+
@Override
24+
protected Class<ExampleConfiguration> configurationClass() {
25+
return ExampleConfiguration.class;
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.example.core;
2+
3+
import net.labymod.api.addon.AddonConfig;
4+
import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting;
5+
import net.labymod.api.configuration.loader.annotation.ConfigName;
6+
import net.labymod.api.configuration.loader.property.ConfigProperty;
7+
8+
@SuppressWarnings("FieldMayBeFinal")
9+
@ConfigName("settings")
10+
public class ExampleConfiguration extends AddonConfig {
11+
12+
@SwitchSetting
13+
private final ConfigProperty<Boolean> enabled = new ConfigProperty<>(true);
14+
15+
@Override
16+
public ConfigProperty<Boolean> enabled() {
17+
return this.enabled;
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.example.core.commands;
2+
3+
import com.google.inject.Inject;
4+
import net.kyori.adventure.text.Component;
5+
import net.kyori.adventure.text.format.NamedTextColor;
6+
import net.labymod.api.client.chat.command.Command;
7+
8+
public class ExamplePingCommand extends Command {
9+
10+
@Inject
11+
private ExamplePingCommand() {
12+
super("ping", "pong");
13+
}
14+
15+
@Override
16+
public boolean execute(String prefix, String[] arguments) {
17+
if (prefix.equalsIgnoreCase("ping")) {
18+
this.displayMessage(Component.text("Ping!", NamedTextColor.AQUA));
19+
return false;
20+
}
21+
22+
this.displayMessage(Component.text("Pong!", NamedTextColor.GOLD));
23+
return true;
24+
}
25+
}

0 commit comments

Comments
 (0)