Skip to content

Commit 43876b2

Browse files
committed
Redact player name in NPC messages
1 parent 66416a4 commit 43876b2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

Apps/Redact/Program.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private static bool Connection_OnReceivedServerMessagePacket(Packet packet)
239239
var p = (OXGaming.TibiaAPI.Network.ServerPackets.Message)packet;
240240
if (p.MessageMode == MessageModeType.Look)
241241
{
242-
if (_lookPlayerRx.IsMatch(p.Text) || p.Text.Contains("You see yourself."))
242+
if (_lookPlayerRx.IsMatch(p.Text) || p.Text.Contains("You see yourself.", StringComparison.OrdinalIgnoreCase))
243243
{
244244
p.Text = "Redacted";
245245
}
@@ -256,6 +256,12 @@ private static bool Connection_OnReceivedServerTalkPacket(Packet packet)
256256
p.SpeakerLevel = 100;
257257
p.SpeakerName = "Redacted";
258258
}
259+
else if (creature is object && creature.Type == CreatureType.Npc)
260+
{
261+
// In case the NPC used the player's name in their message,
262+
// we need to check and replace it.
263+
p.Text = p.Text.Replace(p.Client.Player.Name, "Redacted", StringComparison.OrdinalIgnoreCase);
264+
}
259265
return true;
260266
}
261267

0 commit comments

Comments
 (0)