Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RappyTV authored Oct 3, 2024
0 parents commit cec6575
Show file tree
Hide file tree
Showing 19 changed files with 1,637 additions and 0 deletions.
1,043 changes: 1,043 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .github/workflows/build.yml
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 21
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '21'
- 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
78 changes: 78 additions & 0 deletions .gitignore
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
10 changes: 10 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtension.ReferenceType

dependencies {
labyProcessor()
labyApi("api")
}

labyModAnnotationProcessor {
referenceType = ReferenceType.INTERFACE
}
41 changes: 41 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
id("net.labymod.labygradle")
id("net.labymod.labygradle.addon")
}

val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";")

group = "org.example"
version = providers.environmentVariable("VERSION").getOrElse("1.0.0")

labyMod {
defaultPackageName = "org.example" //change this to your main package name (used by all modules)

minecraft {
registerVersion(versions.toTypedArray()) {
runs {
getByName("client") {
// When the property is set to true, you can log in with a Minecraft account
// devLogin = true
}
}
}
}

addonInfo {
namespace = "example"
displayName = "ExampleAddon"
author = "Example Author"
description = "Example Description"
minecraftVersion = "*"
version = rootProject.version.toString()
}
}

subprojects {
plugins.apply("net.labymod.labygradle")
plugins.apply("net.labymod.labygradle.addon")

group = rootProject.group
version = rootProject.version
}
13 changes: 13 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtension.ReferenceType

dependencies {
labyProcessor()
api(project(":api"))

// An example of how to add an external dependency that is used by the addon.
// addonMavenDependency("org.jeasy:easy-random:5.0.0")
}

labyModAnnotationProcessor {
referenceType = ReferenceType.DEFAULT
}
25 changes: 25 additions & 0 deletions core/src/main/java/org/example/core/ExampleAddon.java
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 core/src/main/java/org/example/core/ExampleConfiguration.java
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;
}
}
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;
}
}
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;
}
}
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");
}
}
9 changes: 9 additions & 0 deletions core/src/main/resources/assets/example/i18n/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"example": {
"settings": {
"enabled": {
"name": "Enabled"
}
}
}
}
1 change: 1 addition & 0 deletions game-runner/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lg_versioned_module=true
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.gradle.jvmargs=-Xmx4096m
net.labymod.minecraft-versions=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;1.20.2;1.20.4;1.20.5;1.20.6;1.21;1.21.1
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
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.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit cec6575

Please sign in to comment.