Skip to content

Commit 37d574e

Browse files
authored
Merge pull request #107 from DFOnline/feat/hide-scope-change-messages
Hide Scope Change Messages
2 parents c8ca08f + 997bf05 commit 37d574e

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

src/main/java/dev/dfonline/codeclient/CodeClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ private static void loadFeatures() {
177177
feat(new ValueDetails());
178178
feat(new ChatAutoEdit());
179179
feat(new CPUDisplay());
180+
feat(new MessageHiding());
180181
}
181182

182183
/**

src/main/java/dev/dfonline/codeclient/config/Config.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public class Config {
7979
public boolean GiveUuidNameStrings = true;
8080
public boolean CPUDisplay = true;
8181
public CPUDisplayCorner CPUDisplayCornerOption = CPUDisplayCorner.TOP_LEFT;
82+
public boolean HideScopeChangeMessages = true;
8283

8384
public Config() {
8485
}
@@ -161,6 +162,7 @@ public void save() {
161162
object.addProperty("GiveUuidNameStrings", GiveUuidNameStrings);
162163
object.addProperty("CPUDisplay", CPUDisplay);
163164
object.addProperty("CPUDisplayCorner", CPUDisplayCornerOption.name());
165+
object.addProperty("HideScopeChangeMessages", HideScopeChangeMessages);
164166
FileManager.writeConfig(object.toString());
165167
} catch (Exception e) {
166168
CodeClient.LOGGER.info("Couldn't save config: " + e);
@@ -670,6 +672,16 @@ public YetAnotherConfigLib getLibConfig() {
670672
)
671673
.controller(nodeOption -> () -> new EnumController<>(nodeOption, Config.CPUDisplayCorner.class))
672674
.build())
675+
.option(Option.createBuilder(Boolean.class)
676+
.name(Text.translatable("codeclient.config.hide_scope_change_messages"))
677+
.description(OptionDescription.of(Text.translatable("codeclient.config.hide_scope_change_messages.description")))
678+
.binding(
679+
true,
680+
() -> HideScopeChangeMessages,
681+
opt -> HideScopeChangeMessages = opt
682+
)
683+
.controller(TickBoxControllerBuilder::create)
684+
.build())
673685
//</editor-fold>
674686
//<editor-fold desc="Action Viewer">
675687
.group(OptionGroup.createBuilder()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package dev.dfonline.codeclient.dev;
2+
3+
import dev.dfonline.codeclient.CodeClient;
4+
import dev.dfonline.codeclient.Feature;
5+
import dev.dfonline.codeclient.config.Config;
6+
import dev.dfonline.codeclient.location.Dev;
7+
import net.minecraft.network.packet.Packet;
8+
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
9+
import net.minecraft.text.Text;
10+
11+
import java.util.regex.Pattern;
12+
13+
public class MessageHiding extends Feature {
14+
15+
@Override
16+
public boolean onReceivePacket(Packet<?> packet) {
17+
if (packet instanceof GameMessageS2CPacket message) {
18+
Text content = message.content();
19+
String string = content.getString();
20+
21+
// Nested for future dev-only features.
22+
if (CodeClient.location instanceof Dev) {
23+
if (Config.getConfig().HideScopeChangeMessages) {
24+
Pattern pattern = Pattern.compile("^Scope set to (GAME|SAVE|LOCAL|LINE) \\((\\w ?)+\\)\\.$");
25+
return pattern.matcher(string).matches();
26+
}
27+
}
28+
}
29+
30+
return false;
31+
}
32+
33+
}

src/main/resources/assets/codeclient/lang/en_us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@
122122
"codeclient.config.cpu_display.description": "Whether to show the plot's CPU usage onscreen separate from the actionbar.",
123123
"codeclient.config.cpu_display_corner.name": "On-Screen CPU Display Corner",
124124
"codeclient.config.cpu_display_corner.description": "Which corner to place the on-screen CPU display.",
125+
"codeclient.config.hide_scope_change_messages": "Hide Scope Change Messages",
126+
"codeclient.config.hide_scope_change_messages.description": "Hides the message sent when changing a variable's scope.",
125127
"codeclient.config.action_viewer": "Action Viewer",
126128
"codeclient.config.action_viewer.description": "Display a tooltip that shows the code block's description.",
127129
"codeclient.config.action_viewer.enable": "Enable Action Viewer",

0 commit comments

Comments
 (0)