Skip to content

feat(ModuleNotifier): Add Module to get feedback in chat when modules toggle#258

Open
IceTank wants to merge 2 commits intolambda-client:1.21.11from
IceTank:feature/module/module-notifyer
Open

feat(ModuleNotifier): Add Module to get feedback in chat when modules toggle#258
IceTank wants to merge 2 commits intolambda-client:1.21.11from
IceTank:feature/module/module-notifyer

Conversation

@IceTank
Copy link
Contributor

@IceTank IceTank commented Mar 7, 2026

Adds chat feedback when modules toggle

@IceTank IceTank marked this pull request as ready for review March 7, 2026 21:36
@IceTank IceTank changed the title Add ModuleNotifier to get feedback in chat when modules toggle feat(ModuleNotifier): Add Module to get feedback in chat when modules toggle Mar 7, 2026
@github-project-automation github-project-automation bot moved this to Backlog in Kanban Mar 11, 2026
@beanbag44 beanbag44 self-requested a review March 12, 2026 14:56
@IceTank
Copy link
Contributor Author

IceTank commented Mar 13, 2026

I refactored the ModuleNotifier so it listens to events produced by the module when toggling

Copy link
Member

@beanbag44 beanbag44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know, just assuming but if portions of this pr and others are written with ai, please try to clean up the code (unused imports, old comments, etc), and test it to make sure it has the desired outcome

import com.lambda.util.text.styled
import com.lambda.util.text.text
import net.minecraft.client.toast.SystemToast
import net.minecraft.text.MutableText
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import

}

/**
* Logs messages to the in game chat if available while stripping the message styles
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be outdated now

}

fun toggle() {
if (ModuleEvent.Toggle(this@Module, !isEnabled).post().isCanceled()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabled and Disabled dont seem to get called when the module is toggled. The toggle event should be posted first, then the corresponding event for the new value


fun disable() {
if (ModuleEvent.Disabled(this@Module).post().isCanceled()) {
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a styling choice but i typically omit the brackets for early returns and small one-liner if blocks. The return can just be placed at the end of the if statement without the brackets, or just on the next line

}

private fun logToTargets(message: Text) {
if (notifyTarget.contains(NotifyTarget.Chat)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use NotifyTarget.Chat in notifyTarget

object ModuleNotifier : Module(
name = "ModuleNotifier",
description = "Notifies you when a module is enabled or disabled",
tag = com.lambda.module.tag.ModuleTag.CLIENT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use an import instead of the full qualified reference

init {
listen<ModuleEvent.Enabled> {
runSafe {
logToTargets(Text.literal("on").withColor(Colors.GREEN))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have a text dsl builder for stuff like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants