From 6f102dae98fb8e5b9c28ce255d10e69c90f4dfa0 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Wed, 15 Apr 2026 16:36:09 +0200 Subject: [PATCH 1/3] chore: Sync with template --- .editorconfig | 2 +- .github/workflows/build.yml | 24 ++++- .gitignore | 2 + api/build.gradle.kts | 15 +-- build.gradle.kts | 91 ++++--------------- core/build.gradle.kts | 17 ++-- .../rappytv/rainbowgui/RainbowGuiAddon.java | 20 ---- .../rainbowgui/RainbowGuiConfiguration.java | 68 -------------- .../rainbowgui/core/RainbowGuiAddon.java | 20 ++++ .../core/RainbowGuiConfiguration.java | 74 +++++++++++++++ .../core/listener/GameTickListener.java | 55 +++++++++++ .../rainbowgui/listener/GameTickListener.java | 53 ----------- game-runner/gradle.properties | 1 + gradle.properties | 3 +- gradle/wrapper/gradle-wrapper.properties | 2 +- readme.md | 10 +- settings.gradle.kts | 13 ++- 17 files changed, 214 insertions(+), 256 deletions(-) delete mode 100644 core/src/main/java/com/rappytv/rainbowgui/RainbowGuiAddon.java delete mode 100644 core/src/main/java/com/rappytv/rainbowgui/RainbowGuiConfiguration.java create mode 100644 core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiAddon.java create mode 100644 core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiConfiguration.java create mode 100644 core/src/main/java/com/rappytv/rainbowgui/core/listener/GameTickListener.java delete mode 100644 core/src/main/java/com/rappytv/rainbowgui/listener/GameTickListener.java create mode 100644 game-runner/gradle.properties diff --git a/.editorconfig b/.editorconfig index 57a8a1b..80a0471 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,7 +1,7 @@ [*] charset = utf-8 end_of_line = lf -indent_size = 4 +indent_size = 2 indent_style = space insert_final_newline = false max_line_length = 100 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4636995..c3e6275 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,18 +11,32 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up JDK 21 - uses: actions/setup-java@v3 + - uses: actions/checkout@v5 + - name: Set up JDK 25 + uses: actions/setup-java@v5 with: distribution: 'corretto' - java-version: '21' + java-version: '25' + - name: Cache Gradle dependencies + uses: actions/cache@v5 + with: + path: ~/.gradle/caches + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + gradle-${{ runner.os }}- + - name: Cache Gradle wrapper + uses: actions/cache@v5 + with: + path: ~/.gradle/wrapper + key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} + restore-keys: | + gradle-wrapper-${{ runner.os }}- - 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 + uses: actions/upload-artifact@v6 with: name: Artifacts path: build/libs/*-release.jar \ No newline at end of file diff --git a/.gitignore b/.gitignore index 47d9f66..69ec47e 100644 --- a/.gitignore +++ b/.gitignore @@ -73,6 +73,8 @@ run/ # LabyGradle | Addon Plugin build-data.txt .assetsroot +resources_index.json +access_widener_index.json # Don't ignore libraries !libs/*.jar \ No newline at end of file diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 8fdb04e..2c74e5b 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -1,18 +1,11 @@ -version = "0.1.0" +import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtension.ReferenceType -plugins { - id("java-library") -} dependencies { + labyProcessor() labyApi("api") } -labyModProcessor { - referenceType = net.labymod.gradle.core.processor.ReferenceType.INTERFACE -} - -java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 +labyModAnnotationProcessor { + referenceType = ReferenceType.INTERFACE } \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index d2b421f..b5531a2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,96 +1,45 @@ plugins { - id("java-library") - id("net.labymod.gradle") - id("net.labymod.gradle.addon") + id("net.labymod.labygradle") + id("net.labymod.labygradle.addon") } +val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";") + group = "org.example" -version = System.getenv().getOrDefault("VERSION", "1.0.0") +version = providers.environmentVariable("VERSION").getOrElse("1.0.0") labyMod { defaultPackageName = "com.rappytv.rainbowgui" + addonInfo { namespace = "rainbowgui" displayName = "Rainbow GUI" author = "RappyTV" description = "Improve your widget HUD with some rainbow widgets." minecraftVersion = "*" - version = getVersion().toString() + version = rootProject.version.toString() } 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", - "1.20.2", - "1.20.4", - "1.20.5", - "1.20.6", - "1.21" - ) { version, provider -> - configureRun(provider, version) - } - - subprojects.forEach { - if (it.name != "game-runner") { - filter(it.name) + registerVersion(versions.toTypedArray()) { + runs { + getByName("client") { + devLogin = true + } } } } - - 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") + plugins.apply("net.labymod.labygradle") + plugins.apply("net.labymod.labygradle.addon") - 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_21 - } - } - - provider.mixin { - val mixinMinVersion = when (gameVersion) { - "1.8.9", "1.12.2", "1.16.5" -> { - "0.6.6" - } + group = rootProject.group + version = rootProject.version - else -> { - "0.8.2" - } - } - - minVersion = mixinMinVersion + extensions.findByType(JavaPluginExtension::class.java)?.apply { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } -} +} \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts index f96ae4a..f863d0e 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,18 +1,13 @@ -version = "0.1.0" - -plugins { - id("java-library") -} +import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtension.ReferenceType dependencies { + labyProcessor() api(project(":api")) -} -labyModProcessor { - referenceType = net.labymod.gradle.core.processor.ReferenceType.DEFAULT + // An example of how to add an external dependency that is used by the addon. + // addonMavenDependency("org.jeasy:easy-random:5.0.0") } -java { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 +labyModAnnotationProcessor { + referenceType = ReferenceType.DEFAULT } \ No newline at end of file diff --git a/core/src/main/java/com/rappytv/rainbowgui/RainbowGuiAddon.java b/core/src/main/java/com/rappytv/rainbowgui/RainbowGuiAddon.java deleted file mode 100644 index 455744d..0000000 --- a/core/src/main/java/com/rappytv/rainbowgui/RainbowGuiAddon.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.rappytv.rainbowgui; - -import com.rappytv.rainbowgui.listener.GameTickListener; -import net.labymod.api.addon.LabyAddon; -import net.labymod.api.models.addon.annotation.AddonMain; - -@AddonMain -public class RainbowGuiAddon extends LabyAddon { - - @Override - protected void enable() { - registerSettingCategory(); - registerListener(new GameTickListener(this)); - } - - @Override - protected Class configurationClass() { - return RainbowGuiConfiguration.class; - } -} diff --git a/core/src/main/java/com/rappytv/rainbowgui/RainbowGuiConfiguration.java b/core/src/main/java/com/rappytv/rainbowgui/RainbowGuiConfiguration.java deleted file mode 100644 index 1f48581..0000000 --- a/core/src/main/java/com/rappytv/rainbowgui/RainbowGuiConfiguration.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.rappytv.rainbowgui; - -import net.labymod.api.addon.AddonConfig; -import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget.SliderSetting; -import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; -import net.labymod.api.configuration.loader.property.ConfigProperty; -import net.labymod.api.configuration.settings.annotation.SettingRequires; -import net.labymod.api.configuration.settings.annotation.SettingSection; - -public class RainbowGuiConfiguration extends AddonConfig { - - @SwitchSetting - private final ConfigProperty enabled = new ConfigProperty<>(true); - - @SliderSetting(min = 2, max = 200) - private final ConfigProperty speed = new ConfigProperty<>(20); - - @SettingSection("prefix") - @SwitchSetting - private final ConfigProperty prefixEnabled = new ConfigProperty<>(true); - - @SettingRequires("prefixEnabled") - @SliderSetting(min = 0, max = 100) - private final ConfigProperty prefixDelay = new ConfigProperty<>(0L); - - @SettingSection("brackets") - @SwitchSetting - private final ConfigProperty bracketsEnabled = new ConfigProperty<>(true); - - @SettingRequires("bracketsEnabled") - @SliderSetting(min = 0, max = 100) - private final ConfigProperty bracketDelay = new ConfigProperty<>(30L); - - @SettingSection("values") - @SwitchSetting - private final ConfigProperty valuesEnabled = new ConfigProperty<>(true); - - @SettingRequires("valuesEnabled") - @SliderSetting(min = 0, max = 100) - private final ConfigProperty valueDelay = new ConfigProperty<>(60L); - - - @Override - public ConfigProperty enabled() { - return enabled; - } - public ConfigProperty speed() { - return speed; - } - public ConfigProperty prefixEnabled() { - return prefixEnabled; - } - public ConfigProperty prefixDelay() { - return prefixDelay; - } - public ConfigProperty bracketsEnabled() { - return bracketsEnabled; - } - public ConfigProperty bracketDelay() { - return bracketDelay; - } - public ConfigProperty valuesEnabled() { - return valuesEnabled; - } - public ConfigProperty valueDelay() { - return valueDelay; - } -} diff --git a/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiAddon.java b/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiAddon.java new file mode 100644 index 0000000..a8fbea7 --- /dev/null +++ b/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiAddon.java @@ -0,0 +1,20 @@ +package com.rappytv.rainbowgui.core; + +import com.rappytv.rainbowgui.core.listener.GameTickListener; +import net.labymod.api.addon.LabyAddon; +import net.labymod.api.models.addon.annotation.AddonMain; + +@AddonMain +public class RainbowGuiAddon extends LabyAddon { + + @Override + protected void enable() { + this.registerSettingCategory(); + this.registerListener(new GameTickListener(this)); + } + + @Override + protected Class configurationClass() { + return RainbowGuiConfiguration.class; + } +} diff --git a/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiConfiguration.java b/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiConfiguration.java new file mode 100644 index 0000000..25e1d44 --- /dev/null +++ b/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiConfiguration.java @@ -0,0 +1,74 @@ +package com.rappytv.rainbowgui.core; + +import net.labymod.api.addon.AddonConfig; +import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget.SliderSetting; +import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; +import net.labymod.api.configuration.loader.property.ConfigProperty; +import net.labymod.api.configuration.settings.annotation.SettingRequires; +import net.labymod.api.configuration.settings.annotation.SettingSection; + +public class RainbowGuiConfiguration extends AddonConfig { + + @SwitchSetting + private final ConfigProperty enabled = new ConfigProperty<>(true); + + @SliderSetting(min = 2, max = 200) + private final ConfigProperty speed = new ConfigProperty<>(20); + + @SettingSection("prefix") + @SwitchSetting + private final ConfigProperty prefixEnabled = new ConfigProperty<>(true); + + @SettingRequires("prefixEnabled") + @SliderSetting(min = 0, max = 100) + private final ConfigProperty prefixDelay = new ConfigProperty<>(0L); + + @SettingSection("brackets") + @SwitchSetting + private final ConfigProperty bracketsEnabled = new ConfigProperty<>(true); + + @SettingRequires("bracketsEnabled") + @SliderSetting(min = 0, max = 100) + private final ConfigProperty bracketDelay = new ConfigProperty<>(30L); + + @SettingSection("values") + @SwitchSetting + private final ConfigProperty valuesEnabled = new ConfigProperty<>(true); + + @SettingRequires("valuesEnabled") + @SliderSetting(min = 0, max = 100) + private final ConfigProperty valueDelay = new ConfigProperty<>(60L); + + @Override + public ConfigProperty enabled() { + return this.enabled; + } + + public ConfigProperty speed() { + return this.speed; + } + + public ConfigProperty prefixEnabled() { + return this.prefixEnabled; + } + + public ConfigProperty prefixDelay() { + return this.prefixDelay; + } + + public ConfigProperty bracketsEnabled() { + return this.bracketsEnabled; + } + + public ConfigProperty bracketDelay() { + return this.bracketDelay; + } + + public ConfigProperty valuesEnabled() { + return this.valuesEnabled; + } + + public ConfigProperty valueDelay() { + return this.valueDelay; + } +} diff --git a/core/src/main/java/com/rappytv/rainbowgui/core/listener/GameTickListener.java b/core/src/main/java/com/rappytv/rainbowgui/core/listener/GameTickListener.java new file mode 100644 index 0000000..70501d2 --- /dev/null +++ b/core/src/main/java/com/rappytv/rainbowgui/core/listener/GameTickListener.java @@ -0,0 +1,55 @@ +package com.rappytv.rainbowgui.core.listener; + +import com.rappytv.rainbowgui.core.RainbowGuiAddon; +import net.labymod.api.Laby; +import net.labymod.api.event.Phase; +import net.labymod.api.event.Subscribe; +import net.labymod.api.event.client.lifecycle.GameTickEvent; +import net.labymod.api.util.Color; + +public class GameTickListener { + + private final RainbowGuiAddon addon; + private long rainbowTime; + + public GameTickListener(RainbowGuiAddon addon) { + this.addon = addon; + } + + @Subscribe + public void onTick(GameTickEvent event) { + if (event.phase() != Phase.POST) { + return; + } + this.rainbowTime += this.addon.configuration().speed().get(); + if (this.addon.configuration().prefixEnabled().get()) { + Laby.references().hudWidgetRegistry().globalHudWidgetConfig().labelColor().set( + this.getRainbowColor( + this.rainbowTime + this.addon.configuration().prefixDelay().get() * 10L + ) + ); + } + if (this.addon.configuration().bracketsEnabled().get()) { + Laby.references().hudWidgetRegistry().globalHudWidgetConfig().bracketColor().set( + this.getRainbowColor( + this.rainbowTime + this.addon.configuration().bracketDelay().get() * 10L + ) + ); + } + if (this.addon.configuration().valuesEnabled().get()) { + Laby.references().hudWidgetRegistry().globalHudWidgetConfig().valueColor().set( + this.getRainbowColor( + this.rainbowTime + this.addon.configuration().valueDelay().get() * 10L + ) + ); + } + } + + private Color getRainbowColor(long timeShift) { + return Color.of(java.awt.Color.HSBtoRGB( + (float) (timeShift % 1000L) / 1000.0F, + 0.8F, + 0.8F + )); + } +} diff --git a/core/src/main/java/com/rappytv/rainbowgui/listener/GameTickListener.java b/core/src/main/java/com/rappytv/rainbowgui/listener/GameTickListener.java deleted file mode 100644 index d0b70c5..0000000 --- a/core/src/main/java/com/rappytv/rainbowgui/listener/GameTickListener.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.rappytv.rainbowgui.listener; - -import com.rappytv.rainbowgui.RainbowGuiAddon; -import net.labymod.api.Laby; -import net.labymod.api.event.Phase; -import net.labymod.api.event.Subscribe; -import net.labymod.api.event.client.lifecycle.GameTickEvent; -import net.labymod.api.util.Color; - -public class GameTickListener { - - private final RainbowGuiAddon addon; - private long rainbowTime; - - public GameTickListener(RainbowGuiAddon addon) { - this.addon = addon; - } - - @Subscribe - public void onTick(GameTickEvent event) { - if(event.phase() != Phase.POST) return; - rainbowTime += addon.configuration().speed().get(); - if(addon.configuration().prefixEnabled().get()) { - Laby.references().hudWidgetRegistry().globalHudWidgetConfig().labelColor().set( - this.getRainbowColor( - this.rainbowTime + addon.configuration().prefixDelay().get() * 10L - ) - ); - } - if(addon.configuration().bracketsEnabled().get()) { - Laby.references().hudWidgetRegistry().globalHudWidgetConfig().bracketColor().set( - this.getRainbowColor( - this.rainbowTime + addon.configuration().bracketDelay().get() * 10L - ) - ); - } - if(addon.configuration().valuesEnabled().get()) { - Laby.references().hudWidgetRegistry().globalHudWidgetConfig().valueColor().set( - this.getRainbowColor( - this.rainbowTime + addon.configuration().valueDelay().get() * 10L - ) - ); - } - } - - private Color getRainbowColor(long timeShift) { - return Color.of(java.awt.Color.HSBtoRGB( - (float)(timeShift % 1000L) / 1000.0F, - 0.8F, - 0.8F - )); - } -} diff --git a/game-runner/gradle.properties b/game-runner/gradle.properties new file mode 100644 index 0000000..982be3f --- /dev/null +++ b/game-runner/gradle.properties @@ -0,0 +1 @@ +lg_versioned_module=true \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 609a9ce..ba9e341 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1,2 @@ -org.gradle.jvmargs=-Xmx4096m \ No newline at end of file +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.4;1.20.1;1.20.4;1.20.6;1.21;1.21.1;1.21.3;1.21.4;1.21.5;1.21.8;1.21.10;1.21.11 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 48c0a02..ac57dd1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/readme.md b/readme.md index c93f443..97f376b 100644 --- a/readme.md +++ b/readme.md @@ -1,13 +1,9 @@ # **Rainbow GUI** -![Downloads](https://labybadges-delta.vercel.app/api/downloads/rainbowgui/formatted)
### Installation 1. Press `Win` + `R` 2. Paste this into the window that popped up: `%appdata%/.minecraft/LabyMod-neo/addons` and press enter -3. It should open your Labymod addon directory; Paste the [RainbowGUI.jar](https://github.com/RappyLabyAddons/RainbowGUI/releases/latest/download/RainbowGUI.jar) in there. -4. Launch your Labymod client. +3. It should open your LabyMod addon directory; Paste the [RainbowGUI.jar](https://github.com/RappyLabyAddons/RainbowGUI/releases/latest/download/RainbowGUI.jar) in there. +4. Launch your LabyMod client. -If you have any problems with the addon/have update ideas, feel free to -- Open an Issue [here](https://github.com/RappyLabyAddons/RainbowGUI/issues/new/choose) - or -- Open a ticket on my [Discord Server](https://rappytv.com/server) in [this](https://discord.com/channels/815912035124248587/840285653946204181) channel \ No newline at end of file +ℹ️ If you have any problems with the addon/have update ideas, feel free to open an Issue [here](https://github.com/RappyLabyAddons/RainbowGUI/issues/new)! \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 0a4ff51..d6166fc 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,25 +1,24 @@ rootProject.name = "rainbowgui" pluginManagement { - val labyGradlePluginVersion = "0.4.6" - plugins { - id("net.labymod.gradle") version (labyGradlePluginVersion) - } + val labyGradlePluginVersion = "0.6.2" buildscript { repositories { maven("https://dist.labymod.net/api/v1/maven/release/") - maven("https://repo.spongepowered.org/repository/maven-public") + maven("https://maven.neoforged.net/releases/") + maven("https://maven.fabricmc.net/") + gradlePluginPortal() mavenCentral() } dependencies { - classpath("net.labymod.gradle", "addon", labyGradlePluginVersion) + classpath("net.labymod.gradle", "common", labyGradlePluginVersion) } } } -plugins.apply("net.labymod.gradle") +plugins.apply("net.labymod.labygradle.settings") include(":api") include(":core") From 697cbb6d74affe091f5a08539cd91b8be71ee34d Mon Sep 17 00:00:00 2001 From: RappyTV Date: Wed, 15 Apr 2026 18:44:41 +0200 Subject: [PATCH 2/3] fix: Save previous colors and restore on disable --- .../rainbowgui/core/RainbowGuiAddon.java | 21 ++++ .../core/RainbowGuiConfiguration.java | 100 ++++++++++++++++-- .../core/listener/GameTickListener.java | 4 +- .../assets/rainbowgui/i18n/en_us.json | 4 +- 4 files changed, 115 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiAddon.java b/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiAddon.java index a8fbea7..4bcdd07 100644 --- a/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiAddon.java +++ b/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiAddon.java @@ -2,11 +2,15 @@ import com.rappytv.rainbowgui.core.listener.GameTickListener; import net.labymod.api.addon.LabyAddon; +import net.labymod.api.configuration.settings.Setting; +import net.labymod.api.configuration.settings.SettingHandler; import net.labymod.api.models.addon.annotation.AddonMain; @AddonMain public class RainbowGuiAddon extends LabyAddon { + private static int settingsInitialized = 0; + @Override protected void enable() { this.registerSettingCategory(); @@ -17,4 +21,21 @@ protected void enable() { protected Class configurationClass() { return RainbowGuiConfiguration.class; } + + public static boolean areSettingsInitialized() { + return settingsInitialized >= 3; + } + + public static class SettingCountHandler implements SettingHandler { + + @Override + public void created(Setting setting) { + + } + + @Override + public void initialized(Setting setting) { + settingsInitialized++; + } + } } diff --git a/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiConfiguration.java b/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiConfiguration.java index 25e1d44..16a8147 100644 --- a/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiConfiguration.java +++ b/core/src/main/java/com/rappytv/rainbowgui/core/RainbowGuiConfiguration.java @@ -1,31 +1,43 @@ package com.rappytv.rainbowgui.core; +import com.rappytv.rainbowgui.core.RainbowGuiAddon.SettingCountHandler; +import net.labymod.api.Laby; import net.labymod.api.addon.AddonConfig; import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget.SliderSetting; import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting; +import net.labymod.api.configuration.loader.annotation.Exclude; import net.labymod.api.configuration.loader.property.ConfigProperty; import net.labymod.api.configuration.settings.annotation.SettingRequires; import net.labymod.api.configuration.settings.annotation.SettingSection; +import net.labymod.api.util.Color; public class RainbowGuiConfiguration extends AddonConfig { @SwitchSetting - private final ConfigProperty enabled = new ConfigProperty<>(true); + private final ConfigProperty enabled = new ConfigProperty<>(true).addChangeListener(value -> { + this.onLabelToggle(value); + this.onBracketToggle(value); + this.onValueToggle(value); + }); @SliderSetting(min = 2, max = 200) private final ConfigProperty speed = new ConfigProperty<>(20); @SettingSection("prefix") @SwitchSetting - private final ConfigProperty prefixEnabled = new ConfigProperty<>(true); + private final ConfigProperty labelEnabled = new ConfigProperty<>(false) + .withHandler(new SettingCountHandler()) + .addChangeListener(this::onLabelToggle); - @SettingRequires("prefixEnabled") + @SettingRequires("labelEnabled") @SliderSetting(min = 0, max = 100) - private final ConfigProperty prefixDelay = new ConfigProperty<>(0L); + private final ConfigProperty labelDelay = new ConfigProperty<>(0L); @SettingSection("brackets") @SwitchSetting - private final ConfigProperty bracketsEnabled = new ConfigProperty<>(true); + private final ConfigProperty bracketsEnabled = new ConfigProperty<>(false) + .withHandler(new SettingCountHandler()) + .addChangeListener(this::onBracketToggle); @SettingRequires("bracketsEnabled") @SliderSetting(min = 0, max = 100) @@ -33,12 +45,23 @@ public class RainbowGuiConfiguration extends AddonConfig { @SettingSection("values") @SwitchSetting - private final ConfigProperty valuesEnabled = new ConfigProperty<>(true); + private final ConfigProperty valuesEnabled = new ConfigProperty<>(false) + .withHandler(new SettingCountHandler()) + .addChangeListener(this::onValueToggle); @SettingRequires("valuesEnabled") @SliderSetting(min = 0, max = 100) private final ConfigProperty valueDelay = new ConfigProperty<>(60L); + @Exclude + private Color previousLabelColor = Color.BLACK; + + @Exclude + private Color previousBracketColor = Color.BLACK; + + @Exclude + private Color previousValueColor = Color.BLACK; + @Override public ConfigProperty enabled() { return this.enabled; @@ -48,12 +71,12 @@ public ConfigProperty speed() { return this.speed; } - public ConfigProperty prefixEnabled() { - return this.prefixEnabled; + public ConfigProperty labelEnabled() { + return this.labelEnabled; } - public ConfigProperty prefixDelay() { - return this.prefixDelay; + public ConfigProperty labelDelay() { + return this.labelDelay; } public ConfigProperty bracketsEnabled() { @@ -71,4 +94,61 @@ public ConfigProperty valuesEnabled() { public ConfigProperty valueDelay() { return this.valueDelay; } + + private void onLabelToggle(boolean value) { + if(!RainbowGuiAddon.areSettingsInitialized()) { + return; + } + if(value) { + this.previousLabelColor = Laby.references() + .hudWidgetRegistry() + .globalHudWidgetConfig() + .labelColor() + .get(); + } else { + Laby.references() + .hudWidgetRegistry() + .globalHudWidgetConfig() + .labelColor() + .set(this.previousLabelColor); + } + } + + private void onBracketToggle(boolean value) { + if(!RainbowGuiAddon.areSettingsInitialized()) { + return; + } + if(value) { + this.previousBracketColor = Laby.references() + .hudWidgetRegistry() + .globalHudWidgetConfig() + .bracketColor() + .get(); + } else { + Laby.references() + .hudWidgetRegistry() + .globalHudWidgetConfig() + .bracketColor() + .set(this.previousBracketColor); + } + } + + private void onValueToggle(boolean value) { + if(!RainbowGuiAddon.areSettingsInitialized()) { + return; + } + if(value) { + this.previousValueColor = Laby.references() + .hudWidgetRegistry() + .globalHudWidgetConfig() + .valueColor() + .get(); + } else { + Laby.references() + .hudWidgetRegistry() + .globalHudWidgetConfig() + .valueColor() + .set(this.previousValueColor); + } + } } diff --git a/core/src/main/java/com/rappytv/rainbowgui/core/listener/GameTickListener.java b/core/src/main/java/com/rappytv/rainbowgui/core/listener/GameTickListener.java index 70501d2..d38384b 100644 --- a/core/src/main/java/com/rappytv/rainbowgui/core/listener/GameTickListener.java +++ b/core/src/main/java/com/rappytv/rainbowgui/core/listener/GameTickListener.java @@ -22,10 +22,10 @@ public void onTick(GameTickEvent event) { return; } this.rainbowTime += this.addon.configuration().speed().get(); - if (this.addon.configuration().prefixEnabled().get()) { + if (this.addon.configuration().labelEnabled().get()) { Laby.references().hudWidgetRegistry().globalHudWidgetConfig().labelColor().set( this.getRainbowColor( - this.rainbowTime + this.addon.configuration().prefixDelay().get() * 10L + this.rainbowTime + this.addon.configuration().labelDelay().get() * 10L ) ); } diff --git a/core/src/main/resources/assets/rainbowgui/i18n/en_us.json b/core/src/main/resources/assets/rainbowgui/i18n/en_us.json index eb4665f..264a2d9 100644 --- a/core/src/main/resources/assets/rainbowgui/i18n/en_us.json +++ b/core/src/main/resources/assets/rainbowgui/i18n/en_us.json @@ -18,10 +18,10 @@ "speed": { "name": "Rainbow speed" }, - "prefixEnabled": { + "labelEnabled": { "name": "Rainbow prefix" }, - "prefixDelay": { + "labelDelay": { "name": "Prefix delay" }, "bracketsEnabled": { From a2747ea7ce48767987414d111ca6038108d33512 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Wed, 15 Apr 2026 18:46:08 +0200 Subject: [PATCH 3/3] fix: Bump version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b5531a2..be51ab7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";") group = "org.example" -version = providers.environmentVariable("VERSION").getOrElse("1.0.0") +version = providers.environmentVariable("VERSION").getOrElse("1.1.0") labyMod { defaultPackageName = "com.rappytv.rainbowgui"