From 9c90c4a536e3124552af37ea2527bf27126340ab Mon Sep 17 00:00:00 2001 From: TudbuT Date: Tue, 25 Jun 2024 11:25:16 +0200 Subject: [PATCH] stop notifications from appearing during initial module load --- .../de/com/baseband/client/feature/Feature.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Client/src/main/java/de/com/baseband/client/feature/Feature.java b/Client/src/main/java/de/com/baseband/client/feature/Feature.java index eeaa4eb..fb10f1f 100644 --- a/Client/src/main/java/de/com/baseband/client/feature/Feature.java +++ b/Client/src/main/java/de/com/baseband/client/feature/Feature.java @@ -50,7 +50,7 @@ public abstract class Feature extends ToggleButton implements SetCommand { public Feature() { super("Uninit", null, "Enabled"); - this.setLambda(this::updateEnabled); + this.setLambda(() -> updateEnabled(true)); Requires requiredAnnotation = getClass().getDeclaredAnnotation(Requires.class); if(requiredAnnotation != null) required.addAll(Arrays.asList(requiredAnnotation.value())); @@ -92,16 +92,18 @@ public abstract class Feature extends ToggleButton implements SetCommand { // own methods - public void updateEnabled() { + public void updateEnabled(boolean sendNotification) { if(enabled) { BaseBand.EVENT_BUS.subscribe(this); MinecraftForge.EVENT_BUS.register(this); - BaseBand.notify("§l" + this + "§a enabled§r."); + if(sendNotification) + BaseBand.notify("§l" + this + "§a enabled§r."); onEnable(); } else { BaseBand.EVENT_BUS.unsubscribe(this); MinecraftForge.EVENT_BUS.unregister(this); - BaseBand.notify("§l" + this + "§c disabled§r."); + if(sendNotification) + BaseBand.notify("§l" + this + "§c disabled§r."); onDisable(); } } @@ -253,7 +255,7 @@ public abstract class Feature extends ToggleButton implements SetCommand { hover(description.value()); setup(); - updateEnabled(); + updateEnabled(false); } private void addComponent(HashMap> sections, Section section, Component btn) { @@ -304,7 +306,7 @@ public abstract class Feature extends ToggleButton implements SetCommand { return; } enabled = enable; - updateEnabled(); + updateEnabled(false); } public void setEnabled(boolean enable) { @@ -319,7 +321,7 @@ public abstract class Feature extends ToggleButton implements SetCommand { } enabled = !enabled; handle.poll("Enabled"); - updateEnabled(); + updateEnabled(true); } protected boolean tryEnable() {