Skip to content

Commit ab7672c

Browse files
committed
perf: these keys can be updated as well
1 parent 0e4d18f commit ab7672c

8 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/main/java/net/apple70cents/chattools/features/bubble/BubbleRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void render(Entity entity, PoseStack poseStack, MultiBufferSource multiBu
8383
if (mc.player == null) {
8484
return;
8585
}
86-
Component renderComponent = ((boolean) ConfigUtils.get("general.NickHider.Enabled")) ? NickHider.work(text) : text;
86+
Component renderComponent = ConfigUtils.NICK_HIDER_ENABLED ? NickHider.work(text) : text;
8787
int yOffset = ((Number) ConfigUtils.get("bubble.YOffset")).intValue();
8888

8989
poseStack.pushPose();

src/main/java/net/apple70cents/chattools/features/general/NickHider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class NickHider {
3232
MessageUtils.sendToNonPublicChat(TextUtils.trans("texts.CircuitBreaker.exceed.NickHider", threshold));
3333
MessageUtils.sendToActionbar(TextUtils.trans("texts.CircuitBreaker.exceed.NickHider", threshold));
3434
LoggerUtils.warn("[ChatTools] " + TextUtils.trans("texts.CircuitBreaker.exceed.NickHider", threshold).getString());
35-
}).setFailsafeJudgement(() -> (Boolean) ConfigUtils.get("general.NickHider.Enabled"));
35+
}).setFailsafeJudgement(() -> ConfigUtils.NICK_HIDER_ENABLED);
3636

3737
public static Component work(Component message) {
3838
while (cache.size() > ((Number) ConfigUtils.get("general.NickHider.CacheSize")).intValue()) {

src/main/java/net/apple70cents/chattools/mixins/BookViewScreenMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public abstract class BookViewScreenMixin {
2626
//$$ cir.setReturnValue(style);
2727
//$$ return;
2828
//$$ }
29-
//$$ if (!(boolean) ConfigUtils.get("general.PreviewClickEvents.Enabled")) {
29+
//$$ if (!ConfigUtils.PREVIEW_CLICK_EVENTS_ENABLED) {
3030
//$$ cir.setReturnValue(style);
3131
//$$ return;
3232
//$$ }

src/main/java/net/apple70cents/chattools/mixins/ChatComponentMixin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void onReceivingMessages(Args args) {
105105
if (ChatFilter.shouldFilter(message)) {
106106
return;
107107
}
108-
if ((boolean) ConfigUtils.get("bubble.Enabled")) {
108+
if (ConfigUtils.BUBBLE_ENABLED) {
109109
// it must be done before NickHider began to work
110110
BubbleRenderer.addChatBubble(message);
111111
}
@@ -117,7 +117,7 @@ public void onReceivingMessages(Args args) {
117117
if ((boolean) ConfigUtils.get("general.OverrideChatColor.Enabled")) {
118118
message = ChatColorEraser.work(message);
119119
}
120-
if ((boolean) ConfigUtils.get("general.NickHider.Enabled")) {
120+
if (ConfigUtils.NICK_HIDER_ENABLED) {
121121
message = NickHider.work(message);
122122
}
123123
int occurrenceCount = 1;
@@ -169,7 +169,7 @@ public void onReceivingMessages(Args args) {
169169
//$$ cir.setReturnValue(style);
170170
//$$ return;
171171
//$$ }
172-
//$$ if (!(boolean) ConfigUtils.get("general.PreviewClickEvents.Enabled")) {
172+
//$$ if (!ConfigUtils.PREVIEW_CLICK_EVENTS_ENABLED) {
173173
//$$ cir.setReturnValue(style);
174174
//$$ return;
175175
//$$ }

src/main/java/net/apple70cents/chattools/mixins/ChatScreenMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private void increaseChatFieldMaxLength(CallbackInfo ci) {
3939
if (!ConfigUtils.CHAT_TOOLS_ENABLED) {
4040
return;
4141
}
42-
if (!(boolean) ConfigUtils.get("general.IncreaseChatFieldMaxLength")) {
42+
if (!ConfigUtils.INCREASE_CHAT_FIELD_MAX_LENGTH_ENABLED) {
4343
return;
4444
}
4545
input.setMaxLength(Integer.MAX_VALUE);
@@ -51,7 +51,7 @@ private void doNotTruncate(String text, CallbackInfoReturnable<String> cir) {
5151
if (!ConfigUtils.CHAT_TOOLS_ENABLED) {
5252
return;
5353
}
54-
if (!(boolean) ConfigUtils.get("general.IncreaseChatFieldMaxLength")) {
54+
if (!ConfigUtils.INCREASE_CHAT_FIELD_MAX_LENGTH_ENABLED) {
5555
return;
5656
}
5757
cir.setReturnValue(StringUtils.normalizeSpace(text.trim()));

src/main/java/net/apple70cents/chattools/mixins/ServerboundChatPacketMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private int increaseMaxLength(int endIndex) {
2020
if (!ConfigUtils.CHAT_TOOLS_ENABLED) {
2121
return 256;
2222
}
23-
if (!(boolean) ConfigUtils.get("general.IncreaseChatFieldMaxLength")) {
23+
if (!ConfigUtils.INCREASE_CHAT_FIELD_MAX_LENGTH_ENABLED) {
2424
return 256;
2525
}
2626
return Integer.MAX_VALUE;

src/main/java/net/apple70cents/chattools/utils/ConfigUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class ConfigUtils {
77
public final static ConfigStorage DEFAULT_CONFIG = new ConfigStorage(true);
88
public static ConfigStorage CONFIG;
99

10-
// Cached config values for hot paths
10+
// Cached config values for frequently-used keys
1111
public static boolean CHAT_TOOLS_ENABLED = false;
1212
public static boolean DISABLE_TEXT_OBFUSCATION_ENABLED = false;
1313
public static boolean BUBBLE_ENABLED = false;

src/main/java/net/apple70cents/chattools/utils/MessageUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static void sendToActionbar(Component text) {
5050
if (Minecraft.getInstance().player == null) {
5151
return;
5252
}
53-
if (!(boolean) ConfigUtils.get("general.ExclusiveActionbar.Enabled")) {
53+
if (!ConfigUtils.EXCLUSIVE_ACTIONBAR_ENABLED) {
5454
sendToOriginalActionbar(text);
5555
} else {
5656
ExclusiveActionbarHandler.addToRenderQueue(text, 4000);
@@ -61,7 +61,7 @@ public static void sendToActionbar(Component text, int duration) {
6161
if (Minecraft.getInstance().player == null) {
6262
return;
6363
}
64-
if (!(boolean) ConfigUtils.get("general.ExclusiveActionbar.Enabled")) {
64+
if (!ConfigUtils.EXCLUSIVE_ACTIONBAR_ENABLED) {
6565
LoggerUtils.warn(
6666
"[ChatTools] Customized actionbar duration is not supported when Exclusive Actionbar is disabled.");
6767
sendToActionbar(text);

0 commit comments

Comments
 (0)