Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
RappyTV authored Jul 25, 2023
0 parents commit f2d147e
Show file tree
Hide file tree
Showing 18 changed files with 1,719 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 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
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
26 changes: 26 additions & 0 deletions api/build.gradle.kts
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
}
93 changes: 93 additions & 0 deletions build.gradle.kts
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
}
}
26 changes: 26 additions & 0 deletions core/build.gradle.kts
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
}
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");
}
}
10 changes: 10 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,10 @@
{
"example": {
"settings": {
"name": "ExampleAddon",
"enabled": {
"name": "Enabled"
}
}
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx4096m
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.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit f2d147e

Please sign in to comment.