Skip to content

Commit 33f1cda

Browse files
authored
Initial commit
0 parents  commit 33f1cda

File tree

18 files changed

+1703
-0
lines changed

18 files changed

+1703
-0
lines changed

.editorconfig

Lines changed: 1043 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/build.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up JDK 21
16+
uses: actions/setup-java@v3
17+
with:
18+
distribution: 'corretto'
19+
java-version: '21'
20+
- name: Grant execute permission for gradlew
21+
run: chmod +x gradlew
22+
- name: Build with Gradle
23+
run: ./gradlew build --full-stacktrace
24+
- name: Upload Artifact
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: Artifacts
28+
path: build/libs/*-release.jar

.gitignore

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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/
32+
run/**
33+
34+
# CMake
35+
cmake-build-*/
36+
37+
# File-based project format
38+
*.iws
39+
40+
# IntelliJ
41+
out/
42+
43+
# mpeltonen/sbt-idea plugin
44+
.idea_modules/
45+
46+
# JIRA plugin
47+
atlassian-ide-plugin.xml
48+
49+
# Crashlytics plugin (for Android Studio and IntelliJ)
50+
com_crashlytics_export_strings.xml
51+
crashlytics.properties
52+
crashlytics-build.properties
53+
fabric.properties
54+
55+
### Gradle template
56+
.gradle
57+
/**/build/
58+
59+
# Ignore Gradle GUI config
60+
gradle-app.setting
61+
62+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
63+
!gradle-wrapper.jar
64+
65+
# Cache of project
66+
.gradletasknamecache
67+
68+
docs/generated/
69+
70+
# Project
71+
run/
72+
73+
# LabyGradle | Addon Plugin
74+
build-data.txt
75+
.assetsroot
76+
77+
# Don't ignore libraries
78+
!libs/*.jar

api/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version = "0.1.0"
2+
3+
plugins {
4+
id("java-library")
5+
}
6+
7+
dependencies {
8+
labyApi("api")
9+
}
10+
11+
labyModProcessor {
12+
referenceType = net.labymod.gradle.core.processor.ReferenceType.INTERFACE
13+
}
14+
15+
java {
16+
sourceCompatibility = JavaVersion.VERSION_21
17+
targetCompatibility = JavaVersion.VERSION_21
18+
}

build.gradle.kts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
plugins {
2+
id("java-library")
3+
id("net.labymod.gradle")
4+
id("net.labymod.gradle.addon")
5+
}
6+
7+
group = "org.example"
8+
version = "1.0.0"
9+
10+
labyMod {
11+
defaultPackageName = "org.example" //change this to your main package name (used by all modules)
12+
addonInfo {
13+
namespace = "example"
14+
displayName = "ExampleAddon"
15+
author = "Example Author"
16+
description = "Example Description"
17+
minecraftVersion = "*"
18+
version = System.getenv().getOrDefault("VERSION", "0.0.1")
19+
}
20+
21+
minecraft {
22+
registerVersions(
23+
"1.8.9",
24+
"1.12.2",
25+
"1.16.5",
26+
"1.17.1",
27+
"1.18.2",
28+
"1.19.2",
29+
"1.19.3",
30+
"1.19.4",
31+
"1.20.1",
32+
"1.20.2",
33+
"1.20.4"
34+
) { version, provider ->
35+
configureRun(provider, version)
36+
}
37+
38+
subprojects.forEach {
39+
if (it.name != "game-runner") {
40+
filter(it.name)
41+
}
42+
}
43+
}
44+
45+
addonDev {
46+
productionRelease()
47+
}
48+
}
49+
50+
subprojects {
51+
plugins.apply("java-library")
52+
plugins.apply("net.labymod.gradle")
53+
plugins.apply("net.labymod.gradle.addon")
54+
55+
repositories {
56+
maven("https://libraries.minecraft.net/")
57+
maven("https://repo.spongepowered.org/repository/maven-public/")
58+
}
59+
}
60+
61+
fun configureRun(provider: net.labymod.gradle.core.minecraft.provider.VersionProvider, gameVersion: String) {
62+
provider.runConfiguration {
63+
mainClass = "net.minecraft.launchwrapper.Launch"
64+
jvmArgs("-Dnet.labymod.running-version=${gameVersion}")
65+
jvmArgs("-Dmixin.debug=true")
66+
jvmArgs("-Dnet.labymod.debugging.all=true")
67+
jvmArgs("-Dmixin.env.disableRefMap=true")
68+
69+
args("--tweakClass", "net.labymod.core.loader.vanilla.launchwrapper.LabyModLaunchWrapperTweaker")
70+
args("--labymod-dev-environment", "true")
71+
args("--addon-dev-environment", "true")
72+
}
73+
74+
provider.javaVersion = when (gameVersion) {
75+
else -> {
76+
JavaVersion.VERSION_21
77+
}
78+
}
79+
80+
provider.mixin {
81+
val mixinMinVersion = when (gameVersion) {
82+
"1.8.9", "1.12.2", "1.16.5" -> {
83+
"0.6.6"
84+
}
85+
86+
else -> {
87+
"0.8.2"
88+
}
89+
}
90+
91+
minVersion = mixinMinVersion
92+
}
93+
}

core/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version = "0.1.0"
2+
3+
plugins {
4+
id("java-library")
5+
}
6+
7+
dependencies {
8+
api(project(":api"))
9+
}
10+
11+
labyModProcessor {
12+
referenceType = net.labymod.gradle.core.processor.ReferenceType.DEFAULT
13+
}
14+
15+
java {
16+
sourceCompatibility = JavaVersion.VERSION_21
17+
targetCompatibility = JavaVersion.VERSION_21
18+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.example.core;
2+
3+
import net.labymod.api.addon.LabyAddon;
4+
import net.labymod.api.models.addon.annotation.AddonMain;
5+
import org.example.core.commands.ExamplePingCommand;
6+
import org.example.core.listener.ExampleGameTickListener;
7+
8+
@AddonMain
9+
public class ExampleAddon extends LabyAddon<ExampleConfiguration> {
10+
11+
@Override
12+
protected void enable() {
13+
this.registerSettingCategory();
14+
15+
this.registerListener(new ExampleGameTickListener(this));
16+
this.registerCommand(new ExamplePingCommand());
17+
18+
this.logger().info("Enabled the Addon");
19+
}
20+
21+
@Override
22+
protected Class<ExampleConfiguration> configurationClass() {
23+
return ExampleConfiguration.class;
24+
}
25+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
@ConfigName("settings")
9+
public class ExampleConfiguration extends AddonConfig {
10+
11+
@SwitchSetting
12+
private final ConfigProperty<Boolean> enabled = new ConfigProperty<>(true);
13+
14+
@Override
15+
public ConfigProperty<Boolean> enabled() {
16+
return this.enabled;
17+
}
18+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.example.core.commands;
2+
3+
import net.labymod.api.client.chat.command.Command;
4+
import net.labymod.api.client.component.Component;
5+
import net.labymod.api.client.component.format.NamedTextColor;
6+
7+
public class ExamplePingCommand extends Command {
8+
9+
public ExamplePingCommand() {
10+
super("ping", "pong");
11+
12+
this.withSubCommand(new ExamplePingSubCommand());
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+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.example.core.commands;
2+
3+
import net.labymod.api.client.chat.command.SubCommand;
4+
import net.labymod.api.client.component.Component;
5+
import net.labymod.api.client.component.format.NamedTextColor;
6+
7+
public class ExamplePingSubCommand extends SubCommand {
8+
9+
protected ExamplePingSubCommand() {
10+
super("pong");
11+
}
12+
13+
@Override
14+
public boolean execute(String prefix, String[] arguments) {
15+
this.displayMessage(Component.text("Ping Pong!", NamedTextColor.GRAY));
16+
return true;
17+
}
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.example.core.listener;
2+
3+
import net.labymod.api.event.Phase;
4+
import net.labymod.api.event.Subscribe;
5+
import net.labymod.api.event.client.lifecycle.GameTickEvent;
6+
import org.example.core.ExampleAddon;
7+
8+
public class ExampleGameTickListener {
9+
10+
private final ExampleAddon addon;
11+
12+
public ExampleGameTickListener(ExampleAddon addon) {
13+
this.addon = addon;
14+
}
15+
16+
@Subscribe
17+
public void onGameTick(GameTickEvent event) {
18+
if (event.phase() != Phase.PRE) {
19+
return;
20+
}
21+
22+
this.addon.logger().info(this.addon.configuration().enabled().get() ? "enabled" : "disabled");
23+
}
24+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"example": {
3+
"settings": {
4+
"name": "ExampleAddon",
5+
"enabled": {
6+
"name": "Enabled"
7+
}
8+
}
9+
}
10+
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.jvmargs=-Xmx4096m

gradle/wrapper/gradle-wrapper.jar

57.8 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)