Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
sgkoishi committed Apr 19, 2024
1 parent cb5328c commit 3d93f64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Core/Modded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public partial class Plugin
{
private HashSet<PacketTypes> AllowedPackets = new HashSet<PacketTypes>();
private readonly HashSet<PacketTypes> AllowedPackets = new HashSet<PacketTypes>();
private void OTHook_Modded_GetData(object? sender, OTAPI.Hooks.MessageBuffer.GetDataEventArgs args)
{
static bool ModdedEarlyChatSpam(int whoAmI, PacketTypes packetId, HashSet<PacketTypes> allowedPackets)
Expand All @@ -22,6 +22,8 @@ static bool ModdedEarlyChatSpam(int whoAmI, PacketTypes packetId, HashSet<Packet
&& packetId is not (PacketTypes.SocialHandshake
or PacketTypes.PlayerHp or PacketTypes.PlayerMana or PacketTypes.PlayerBuff
or PacketTypes.PasswordSend or PacketTypes.ClientUUID or PacketTypes.SyncLoadout)
// Cross-platform client
&& packetId != (PacketTypes) 150
// Cancelled packets from earlier hooks
&& packetId != (PacketTypes) 255)
{
Expand Down Expand Up @@ -66,7 +68,7 @@ static bool ModdedFakeName(int whoAmI, Span<byte> data)
}

var whoAmI = args.Instance.whoAmI;
if (ModdedEarlyChatSpam(whoAmI, (PacketTypes) args.PacketId, AllowedPackets))
if (ModdedEarlyChatSpam(whoAmI, (PacketTypes) args.PacketId, this.AllowedPackets))
{
this.Statistics.ModdedEarlyChatSpam++;
TShockAPI.TShock.Log.ConsoleInfo($"Unusual packet {args.PacketId} detected at state {Terraria.Netplay.Clients[whoAmI].State} and disconnected. ({Terraria.Netplay.Clients[whoAmI].Socket.GetRemoteAddress()})");
Expand Down
2 changes: 1 addition & 1 deletion Core/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private void ApplyConfig(TSPlayer? initiator)
TShockAPI.Commands.HandleCommand(TShockAPI.TSPlayer.Server, command);
}
Terraria.Initializers.ChatInitializer.Load();
foreach (var p in TerrariaApi.Server.ServerApi.Plugins)
foreach (var p in TerrariaApi.Server.ServerApi.Plugins)
{
if (p.Plugin is TerrariaPlugin plugin)
{
Expand Down

0 comments on commit 3d93f64

Please sign in to comment.