stop notifications from appearing during initial module load
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m31s

This commit is contained in:
Daniella / Tove 2024-06-25 11:25:16 +02:00
parent 03ef53d2e4
commit 9c90c4a536
Signed by: TudbuT
GPG key ID: B3CF345217F202D3

View file

@ -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<String, ArrayList<Component>> 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() {