Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions TShockAPI/TSPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ public Group Group
/// </summary>
public DateTime LastPvPTeamChange;

/// <summary>
/// The last time stack-hack detection was run for this player.
/// </summary>
public DateTime LastStackDetectionCheck;

/// <summary>
/// Temp points for use in regions and other plugins.
/// </summary>
Expand Down Expand Up @@ -1528,6 +1533,7 @@ public TSPlayer(int index)
Group = Group.DefaultGroup;
IceTiles = new List<Point>();
AwaitingResponse = new Dictionary<string, Action<object>>();
LastStackDetectionCheck = DateTime.UtcNow.AddSeconds(-(index % 5));
}

/// <summary>
Expand All @@ -1542,6 +1548,7 @@ protected TSPlayer(String playerName)
FakePlayer = new Player { name = playerName, whoAmI = -1 };
Group = Group.DefaultGroup;
AwaitingResponse = new Dictionary<string, Action<object>>();
LastStackDetectionCheck = DateTime.UtcNow;

if (playerName == "All" || playerName == "Server")
FinishedHandshake = true; //Hot fix for the all player object not getting packets like TimeSet, etc because they have no state and finished handshake will always be false.
Expand Down
17 changes: 11 additions & 6 deletions TShockAPI/TShock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,15 +1221,20 @@ private void OnSecondUpdate()

if (!Main.ServerSideCharacter || (Main.ServerSideCharacter && player.IsLoggedIn))
{
if (!player.HasPermission(Permissions.ignorestackhackdetection))
var stackCheckDue = (DateTime.UtcNow - player.LastStackDetectionCheck).TotalSeconds >= 5;
if (stackCheckDue)
{
player.IsDisabledForStackDetection = player.HasHackedItemStacks(shouldWarnPlayer: true);
player.LastStackDetectionCheck = DateTime.UtcNow;
if (!player.HasPermission(Permissions.ignorestackhackdetection))
{
player.IsDisabledForStackDetection = player.HasHackedItemStacks(shouldWarnPlayer: true);
}
}
}

if (player.IsBeingDisabled())
{
player.Disable(flags: flags);
}
if (player.IsBeingDisabled())
{
player.Disable(flags: flags);
}
Comment on lines +1235 to 1238
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

player.Disable() now runs outside the ServerSideCharacter check, changing original behavior. Previously only disabled when !Main.ServerSideCharacter || (Main.ServerSideCharacter && player.IsLoggedIn), now runs unconditionally.

Move this block inside the closing brace at line 1233:

Suggested change
if (player.IsBeingDisabled())
{
player.Disable(flags: flags);
}
}
if (player.IsBeingDisabled())
{
player.Disable(flags: flags);
}
}

}
}
Expand Down