Skip to content

Commit 59ee8b1

Browse files
committed
Fixed Mention, Updated NiceWurst Allow List
1 parent 3d4fdfa commit 59ee8b1

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fabric_api_version=0.140.2+1.21.11
1616

1717
# Mod Properties
1818
mod_version=v7.52-CevAPI-MC1.21.11
19-
fork_release_version=0.45
19+
fork_release_version=0.46
2020
maven_group=net.wurstclient
2121
archives_base_name=Wurst-Client
2222
mod_loader=Fabric

src/main/java/net/wurstclient/hacks/MentionHack.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public final class MentionHack extends Hack
3333
implements ChatInputListener, ChatOutputListener
3434
{
3535
private static final long SELF_ECHO_WINDOW_MS = 5000L;
36+
private static final int JOIN_GRACE_TICKS = 200;
3637

3738
private static final String CHAT_PREFIX_PATTERN =
3839
"(?:(?:\\[[^\\]]{1,32}\\]|‹[^›]{1,32}›)\\s*)*";
@@ -126,6 +127,8 @@ public void onReceivedMessage(ChatInputEvent event)
126127
ChatLine line = parseChatLine(plain);
127128
if(line.sender().equalsIgnoreCase(ownName))
128129
return;
130+
if(isLikelyJoinLeaveAnnouncement(line, ownName))
131+
return;
129132
if(line.sender().equals("System") && isLikelyOwnEcho(line.text()))
130133
return;
131134

@@ -148,6 +151,45 @@ private boolean containsMention(String text, String ownName)
148151
return false;
149152
}
150153

154+
private boolean containsNameVariant(String text, String ownName)
155+
{
156+
if(text == null || text.isBlank())
157+
return false;
158+
159+
for(String variant : getNameVariants(ownName))
160+
{
161+
Pattern namePattern = Pattern
162+
.compile("(?i)(^|\\W)" + Pattern.quote(variant) + "(\\W|$)");
163+
if(namePattern.matcher(text).find())
164+
return true;
165+
}
166+
167+
return false;
168+
}
169+
170+
private boolean isLikelyJoinLeaveAnnouncement(ChatLine line, String ownName)
171+
{
172+
if(line == null || ownName == null || ownName.isBlank())
173+
return false;
174+
if(!"System".equals(line.sender()))
175+
return false;
176+
177+
String text = line.text();
178+
if(!containsNameVariant(text, ownName))
179+
return false;
180+
181+
String lower = text.toLowerCase(Locale.ROOT);
182+
boolean joinLeaveKeywords = lower.contains(" joined")
183+
|| lower.contains(" left") || lower.contains(" disconnected")
184+
|| lower.contains(" logged in") || lower.contains(" logged out")
185+
|| lower.contains("welcome");
186+
187+
// Also ignore unnamed join banners shortly after connecting.
188+
boolean withinJoinGrace =
189+
MC.player != null && MC.player.tickCount <= JOIN_GRACE_TICKS;
190+
return joinLeaveKeywords || withinJoinGrace;
191+
}
192+
151193
private Set<String> getNameVariants(String ownName)
152194
{
153195
LinkedHashSet<String> variants = new LinkedHashSet<>();

src/main/java/net/wurstclient/nicewurst/NiceWurstModule.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,20 @@ public final class NiceWurstModule
9797
Set.of("Breadcrumbs", "DurabilityHUD", "Fullbright", "HealthTags",
9898
"ItemESP", "LavaWaterESP", "LogoutSpots", "MobESP", "MobHealth",
9999
"MobSearch", "MobSpawnESP", "NameTags", "NewChunks",
100-
"NoBackground", "NoFireOverlay", "NoVignette", "NoWeather",
101-
"Freecam", "OpenWaterESP", "PearlESP", "PlayerESP", "PortalESP",
102-
"Radar", "Search", "TrialSpawnerESP", "TridentESP", "Waypoints",
103-
"WardenESP", "HideWurst"));
100+
"NewerNewChunks", "NoBackground", "NoFireOverlay", "NoVignette",
101+
"NoWeather", "Freecam", "OpenWaterESP", "PearlESP", "PlayerESP",
102+
"PortalESP", "Radar", "Search", "TrialSpawnerESP", "TridentESP",
103+
"Waypoints", "WardenESP", "HideWurst"));
104+
105+
ALLOWED_HACKS.put(Category.CHAT, Set.of("AutoChat", "Mention"));
104106

105107
ALLOWED_HACKS.put(Category.OTHER,
106108
Set.of("AntiAFK", "Antisocial", "AntiCheatDetect", "AutoFish",
107109
"AutoLibrarian", "AutoReconnect", "AutoTrader", "CheatDetector",
108110
"ClickGUI", "FeedAura", "Navigator", "LivestreamDetector",
109111
"PacketRate", "Panic", "PortalGUI", "SafeTP", "UI-Utils",
110112
"SeedMapperHelper", "TooManyHax", "HideModMenu", "GameStats",
111-
"DamageDetect"));
113+
"DamageDetect", "ClientChatOverlay"));
112114

113115
ALLOWED_HACKS.put(Category.ITEMS,
114116
Set.of("AntiDrop", "AutoDisenchant", "AutoDrop", "AutoEat",

0 commit comments

Comments
 (0)