Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
fix enable/disable switchsetting got applied imminently
Browse files Browse the repository at this point in the history
  • Loading branch information
l3nnartt committed Aug 21, 2022
1 parent 2141b58 commit 8bda157
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ plugins {
}

group = "com.github.l3nnartt.fullbright"
version = "1.0"
version = "1.1"

plugins.apply("net.labymod.gradle.addon")

Expand Down Expand Up @@ -65,7 +65,7 @@ addon {
iconUrl("https://dl.lennartloesche.de/fullbright/logo.png", project(":core"))
author("L3nnart_")
description("Allows you to change the brightness of the game to full bright")
version("1.0")
version("1.1")
minecraftVersion("1.8<1.18")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.l3nnartt.fullbright.core;

import com.github.l3nnartt.fullbright.core.listener.ConfigUpdateListener;
import com.google.inject.Singleton;
import net.labymod.api.addon.LabyAddon;
import net.labymod.api.inject.LabyGuice;
Expand All @@ -12,9 +13,10 @@ public class FullBright extends LabyAddon<FullBrightConfiguration> {
@Override
protected void enable() {
this.registerSettingCategory();
this.registerListener(ConfigUpdateListener.class);

FullBrightSettings fullBrightSettings = LabyGuice.getInstance(FullBrightSettings.class);
if (this.configuration().enabled().get()) {
FullBrightSettings fullBrightSettings = LabyGuice.getInstance(FullBrightSettings.class);
fullBrightSettings.setGamma(10.0f);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.l3nnartt.fullbright.core;

public interface FullBrightSettings {

void setGamma(float gamma);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.github.l3nnartt.fullbright.core.listener;

import com.github.l3nnartt.fullbright.core.FullBrightSettings;
import net.labymod.api.event.Subscribe;
import net.labymod.api.event.labymod.config.SettingUpdateEvent;
import net.labymod.api.inject.LabyGuice;

public class ConfigUpdateListener {

FullBrightSettings fullBrightSettings = LabyGuice.getInstance(FullBrightSettings.class);

@Subscribe
public void onSettingUpdate(SettingUpdateEvent event) {
if (event.setting().getId().equals("enabled")) {
if (!(boolean) event.getValue()) {
fullBrightSettings.setGamma(1.0f);
} else {
fullBrightSettings.setGamma(10.0f);
}
}
}
}
10 changes: 5 additions & 5 deletions core/src/main/resources/assets/fullbright/i18n/de_de.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"fullbright": {
"settings": {
"name": "FullBright",
"enabled": {
"name": "Aktiviert"
"fullbright" : {
"settings" : {
"name" : "FullBright",
"enabled" : {
"name" : "Aktiviert"
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/resources/assets/fullbright/i18n/en_us.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"fullbright": {
"settings": {
"name": "FullBright",
"enabled": {
"name": "Enabled"
"fullbright" : {
"settings" : {
"name" : "FullBright",
"enabled" : {
"name" : "Enabled"
}
}
}
Expand Down

0 comments on commit 8bda157

Please sign in to comment.