Break off from older commands and systems, move to more recent configurations.

Cheating detection no longer kicks, instead uses new system to block actions, and notifies user to fix the issue instead.
This commit is contained in:
Zidonuke 2011-12-20 22:41:49 -05:00
parent f414fb4e39
commit c06bf2fe2e
9 changed files with 66 additions and 55 deletions

View file

@ -155,7 +155,6 @@ namespace TShockAPI
add(Permissions.manageitem, DeleteItem, "delitem");
add(Permissions.cfg, SetSpawn, "setspawn");
add(Permissions.cfg, Reload, "reload");
add(Permissions.cfg, ShowConfiguration, "showconfig");
add(Permissions.cfg, ServerPassword, "serverpassword");
add(Permissions.cfg, Save, "save");
add(Permissions.cfg, Settle, "settle");
@ -1747,20 +1746,6 @@ namespace TShockAPI
SaveWorld.Start();
}
private static void ShowConfiguration(CommandArgs args)
{
args.Player.SendMessage("TShock Config:");
string lineThree = string.Format("RangeChecks : {0}, DisableBuild : {1}, ProtectSpawn : {2}, ProtectRadius : {3}",
TShock.Config.RangeChecks, TShock.Config.DisableBuild,
TShock.Config.SpawnProtection, TShock.Config.SpawnProtectionRadius);
args.Player.SendMessage(lineThree, Color.Yellow);
string lineFour = string.Format("MaxSlots : {0}, SpamChecks : {1}, InvMultiplier : {2}, DMS : {3}, SpawnRate {4}",
TShock.Config.MaxSlots, TShock.Config.SpamChecks,
TShock.Config.InvasionMultiplier, TShock.Config.DefaultMaximumSpawns,
TShock.Config.DefaultSpawnRate);
args.Player.SendMessage(lineFour, Color.Yellow);
}
private static void Reload(CommandArgs args)
{
FileTools.SetupConfig();

View file

@ -41,18 +41,14 @@ namespace TShockAPI
public bool InfiniteInvasion;
[Description("Enable or disable perma pvp.")]
public bool AlwaysPvP = false;
[Description("Kicks players who edit save files for cheating.")]
public bool KickCheaters = true;
[Description("Prevents tiles from being placed within SpawnProtectionRadius of the default spawn.")]
public bool SpawnProtection = true;
[Description("Radius from spawn tile for SpawnProtection.")]
public int SpawnProtectionRadius = 5;
public int SpawnProtectionRadius = 10;
[Description("Max slots for the server. If you want people to be kicked with \"Server is full\" set this to how many players you want max and then set Terraria max players to 2 higher.")]
public int MaxSlots = 8;
[Description("Global protection agent for any block distance based anti-grief check.")]
public bool RangeChecks = true;
[Description("Enable/Disable Terrarias built in spam checks.")]
public bool SpamChecks;
[Description("Disables any building; placing of blocks")]
public bool DisableBuild;
[Description("Kick a player if they exceed this number of tile kills within 1 second.")]
@ -63,10 +59,6 @@ namespace TShockAPI
public string AdminChatPrefix = "(Admin) ";
[Description("")]
public bool AdminChatEnabled = true;
[Description("Seconds a player has to wait between pvp toggles.")]
public int PvpThrottle;
[Description("Backup frequency in minutes. So, a value of 60 = 60 minutes. Backups are stored in the \\tshock\\backups folder.")]
public int BackupInterval;
[Description("How long backups are kept in minutes. 2880 = 2 days.")]

View file

@ -30,7 +30,7 @@ namespace TShockAPI.DB
AddGroup("default", "warp,canbuild");
AddGroup("newadmin", "default", "kick,editspawn,reservedslot");
AddGroup("admin", "newadmin", "ban,unban,whitelist,causeevents,spawnboss,spawnmob,managewarp,time,tp,pvpfun,kill,logs,immunetokick,tphere");
AddGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,ignorecheatdetection,usebanneditem,manageusers");
AddGroup("trustedadmin", "admin", "maintenance,cfg,butcher,item,heal,immunetoban,usebanneditem,manageusers");
AddGroup("vip", "default", "reservedslot");
String file = Path.Combine(TShock.SavePath, "groups.txt");

View file

@ -139,7 +139,7 @@ namespace TShockAPI
if (stack > item.maxStack && type != 0)
{
TShock.Utils.HandleCheater(args.Player, String.Format("Stack cheat detected. Remove {0} ({1}) > {2} and then rejoin", item.name, stack, item.maxStack));
args.Player.IgnoreActionsForCheating = true;
}
if (args.Player.IsLoggedIn)
@ -158,7 +158,7 @@ namespace TShockAPI
if (cur > 600 || max > 600)
{
TShock.Utils.HandleCheater(args.Player, "Health cheat detected. Please use a different character.");
args.Player.IgnoreActionsForCheating = true;
}
return false;
@ -172,7 +172,7 @@ namespace TShockAPI
if (cur > 600 || max > 600)
{
TShock.Utils.HandleCheater(args.Player, "Mana cheat detected. Please use a different character.");
args.Player.IgnoreActionsForCheating = true;
}
return false;
@ -574,14 +574,18 @@ namespace TShockAPI
float distance = Vector2.Distance(new Vector2((pos.X / 16f), (pos.Y / 16f)), new Vector2(Main.spawnTileX, Main.spawnTileY));
if (TShock.CheckIgnores(args.Player) && distance > 6f)
{
if (TShock.Config.AlwaysPvP && !args.TPlayer.hostile)
if (args.Player.IgnoreActionsForCheating)
{
args.Player.SendMessage("PvP is forced! Enable PvP else you can't move or do anything!", Color.Red);
args.Player.SendMessage("You have been disabled for cheating! Please login with a new character!", Color.Red);
}
if (TShock.Config.ServerSideInventory && !args.Player.IsLoggedIn)
else if (TShock.Config.ServerSideInventory && !args.Player.IsLoggedIn)
{
args.Player.SendMessage("Server Side Inventory is enabled! Please /register or /login to play!", Color.Red);
}
else if (TShock.Config.AlwaysPvP && !args.TPlayer.hostile)
{
args.Player.SendMessage("PvP is forced! Enable PvP else you can't move or do anything!", Color.Red);
}
args.Player.Spawn();
return true;
}

View file

@ -32,9 +32,6 @@ namespace TShockAPI
[Description("Prevents you from being banned")]
public static readonly string immunetoban;
[Description("Prevents you from being kicked by TShocks cheat detections")]
public static readonly string ignorecheatdetection;
[Description("Prevents you from being reverted by kill tile abuse detection")]
public static readonly string ignorekilltiledetection;

View file

@ -66,6 +66,7 @@ namespace TShockAPI
private string CacheIP;
public bool IgnoreActionsForPvP = false;
public bool IgnoreActionsForInventory = false;
public bool IgnoreActionsForCheating = false;
public PlayerData PlayerData;
public bool RealPlayer

View file

@ -726,7 +726,13 @@ namespace TShockAPI
TShock.Utils.ShowFileToUser(player, "motd.txt");
if (HackedHealth(player))
{
TShock.Utils.HandleCheater(player, "Health/Mana cheat detected. Please use a different character.");
player.IgnoreActionsForCheating = true;
player.SendMessage("You are using a health/mana cheat. Please choose a different character.");
}
if (HackedInventory(player))
{
player.IgnoreActionsForCheating = true;
}
NetMessage.syncPlayers();
@ -1014,6 +1020,49 @@ namespace TShockAPI
(player.TPlayer.statLife > 400);
}
public static bool HackedInventory(TSPlayer player)
{
bool check = false;
Item[] inventory = player.TPlayer.inventory;
Item[] armor = player.TPlayer.armor;
for (int i = 0; i < NetItem.maxNetInventory; i++)
{
if (i < 49)
{
Item item = new Item();
if (inventory[i] != null && inventory[i].netID != 0)
{
item.netDefaults(inventory[i].netID);
item.Prefix(inventory[i].prefix);
item.AffixName();
if (inventory[i].stack > item.maxStack)
{
check = true;
player.SendMessage(String.Format("Stack cheat detected. Remove item {0} ({1}) and then rejoin", item.name, inventory[i].stack), Color.Cyan);
}
}
}
else
{
Item item = new Item();
if (armor[i - 48] != null && armor[i - 48].netID != 0)
{
item.netDefaults(armor[i - 48].netID);
item.Prefix(armor[i - 48].prefix);
item.AffixName();
if (armor[i - 48].stack > item.maxStack)
{
check = true;
player.SendMessage(String.Format("Stack cheat detected. Remove armor {0} ({1}) and then rejoin", item.name, armor[i - 48].stack), Color.Cyan);
}
}
}
}
return check;
}
public static bool CheckInventory(TSPlayer player)
{
PlayerData playerData = player.PlayerData;
@ -1111,6 +1160,8 @@ namespace TShockAPI
check = true;
if (player.IgnoreActionsForInventory)
check = true;
if (player.IgnoreActionsForCheating)
check = true;
return check;
}
@ -1149,7 +1200,7 @@ namespace TShockAPI
Netplay.serverPort = file.ServerPort;
}
Netplay.spamCheck = file.SpamChecks;
Netplay.spamCheck = false;
RconHandler.Password = file.RconPassword;
RconHandler.ListenPort = file.RconPort;

View file

@ -453,23 +453,6 @@ namespace TShockAPI
return false;
}
public bool HandleCheater(TSPlayer player, string reason)
{
return HandleBadPlayer(player, "ignorecheatdetection", TShock.Config.KickCheaters, reason);
}
private bool HandleBadPlayer(TSPlayer player, string overridePermission, bool kick, string reason)
{
if (!player.Group.HasPermission(overridePermission) || !(player.Group.Name == "superadmin"))
{
if (kick)
{
return Kick(player, reason);
}
}
return false;
}
/// <summary>
/// Shows a file to the user.
/// </summary>