Skip to content

Commit 4cfa769

Browse files
committed
Fix notification status display
1 parent 37db5c5 commit 4cfa769

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2.3.0-beta.7
4+
5+
- Fixed notification status display
6+
37
## 2.3.0-beta.6
48

59
- Improved format util error logging

common/src/main/java/dev/terminalmc/chatnotify/config/Notification.java

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public class Notification {
4141
/**
4242
* Whether this instance is eligible for activation.
4343
*/
44-
private boolean enabled;
45-
private static final boolean enabledDefault = true;
44+
public boolean enabled;
45+
public static final boolean enabledDefault = true;
4646

4747
/**
4848
* Whether this instance allows use of exclusion triggers.
@@ -143,8 +143,8 @@ static Notification createUser() {
143143
new Trigger("Profile name"),
144144
new Trigger("Display name")
145145
)),
146-
new ArrayList<>(),
147-
new ArrayList<>()
146+
exclusionTriggersDefault.get(),
147+
responseMessagesDefault.get()
148148
);
149149
}
150150

@@ -154,38 +154,28 @@ static Notification createUser() {
154154
*/
155155
static Notification createBlank(Sound sound, TextStyle textStyle) {
156156
return new Notification(
157-
true,
158-
false,
159-
false,
160-
false,
157+
enabledDefault,
158+
exclusionEnabledDefault,
159+
responseEnabledDefault,
160+
blockMessageDefault,
161161
sound,
162162
textStyle,
163-
new TitleText(),
163+
titleTextDefault.get(),
164164
new ArrayList<>(List.of(
165165
new Trigger("")
166166
)),
167-
new ArrayList<>(),
168-
new ArrayList<>()
167+
exclusionTriggersDefault.get(),
168+
responseMessagesDefault.get()
169169
);
170170
}
171171

172-
// Notifications can be enabled and disabled manually, but for user
173-
// convenience we also perform some actions automatically.
174-
175172
/**
176173
* @return {@code true} if this instance is eligible for activation,
177174
* {@code false} otherwise.
178175
*/
179-
public boolean isEnabled() {
176+
public boolean canActivate() {
180177
return enabled && !editing;
181178
}
182-
183-
/**
184-
* Enables or disables this instance.
185-
*/
186-
public void setEnabled(boolean enabled) {
187-
this.enabled = enabled;
188-
}
189179

190180
// List reordering
191181

common/src/main/java/dev/terminalmc/chatnotify/gui/widget/list/option/MainOptionList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ private static class NotifConfigEntry extends Entry {
183183
CommonComponents.OPTION_ON.copy().withStyle(ChatFormatting.GREEN),
184184
CommonComponents.OPTION_OFF.copy().withStyle(ChatFormatting.RED))
185185
.displayOnlyValue()
186-
.withInitialValue(notif.isEnabled())
186+
.withInitialValue(notif.enabled)
187187
.create(x + mainButtonWidth + SPACING, 0, statusButtonWidth, height,
188-
Component.empty(), (button, status) -> notif.setEnabled(status)));
188+
Component.empty(), (button, status) -> notif.enabled = status));
189189

190190
if (index > 0) {
191191
// Delete button

common/src/main/java/dev/terminalmc/chatnotify/util/MessageUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public class MessageUtil {
146146

147147
// Check each notification, in order
148148
for (Notification notif : Config.get().getNotifs()) {
149-
if (!notif.isEnabled()) continue;
149+
if (!notif.canActivate()) continue;
150150

151151
// Trigger search
152152
for (Trigger trig : notif.triggers) {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Neo/Forge version ranges: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
44

55
# Project
6-
mod_version=2.3.0-beta.6+1.21
6+
mod_version=2.3.0-beta.7+1.21
77
mod_group=dev.terminalmc
88
mod_id=chatnotify
99
mod_name=ChatNotify

0 commit comments

Comments
 (0)