diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 6a8d372d..b07daf3c 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -138,11 +138,6 @@ namespace TShockAPI item.netDefaults(type); item.Prefix(prefix); - if (stack > item.maxStack && type != 0 && args.Player.IgnoreActionsForCheating != "none" && !args.Player.Group.HasPermission(Permissions.ignorestackhackdetection)) - { - args.Player.IgnoreActionsForCheating = "Item Hack: " + item.name + " (" + stack + ") exceeds max stack of " + item.maxStack; - } - if (args.Player.IsLoggedIn) { args.Player.PlayerData.StoreSlot(slot, type, prefix, stack); @@ -699,6 +694,11 @@ namespace TShockAPI return true; } + if (TShock.Config.PvPMode == "disabled") + { + return true; + } + if (args.TPlayer.hostile != pvp) { long seconds = (long)(DateTime.UtcNow - args.Player.LastPvpChange).TotalSeconds; @@ -713,13 +713,8 @@ namespace TShockAPI if (TShock.Config.PvPMode == "always") { - if (pvp == true) - args.Player.IgnoreActionsForPvP = false; - else - { + if (!pvp) args.Player.Spawn(); - args.Player.IgnoreActionsForPvP = true; - } } NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", args.Player.Index); @@ -765,7 +760,7 @@ namespace TShockAPI { args.Player.SendMessage("You need to rejoin to ensure your trash can is cleared!", Color.Red); } - else if (args.Player.IgnoreActionsForPvP) + else if (TShock.Config.PvPMode == "always" && !args.TPlayer.hostile) { args.Player.SendMessage("PvP is forced! Enable PvP else you can't move or do anything!", Color.Red); } diff --git a/TShockAPI/TSPlayer.cs b/TShockAPI/TSPlayer.cs index 1eb79d4a..9e008af6 100644 --- a/TShockAPI/TSPlayer.cs +++ b/TShockAPI/TSPlayer.cs @@ -69,7 +69,6 @@ namespace TShockAPI public string Country = "??"; public int Difficulty; private string CacheIP; - public bool IgnoreActionsForPvP = false; public string IgnoreActionsForInventory = "none"; public string IgnoreActionsForCheating = "none"; public string IgnoreActionsForDisabledArmor = "none"; @@ -353,10 +352,9 @@ namespace TShockAPI public virtual void Disable() { LastThreat = DateTime.UtcNow; - SetBuff(35, 330); //Silenced - SetBuff(33, 330); //Weak - SetBuff(32, 330); //Slow - SetBuff(23, 330); //Cursed + SetBuff(33, 330, true); //Weak + SetBuff(32, 330, true); //Slow + SetBuff(23, 330, true); //Cursed } public virtual void Whoopie(object time) @@ -372,8 +370,11 @@ namespace TShockAPI } } - public virtual void SetBuff(int type, int time = 3600) + public virtual void SetBuff(int type, int time = 3600, bool bypass = false) { + if ((DateTime.UtcNow - LastThreat).TotalMilliseconds < 5000 && !bypass) + return; + SendData(PacketTypes.PlayerAddBuff, number: Index, number2: (float)type, number3: (float)time); } diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 3a12adb6..1dce2606 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -532,12 +532,35 @@ namespace TShockAPI player.Spawn(); } string check = "none"; + foreach (Item item in player.TPlayer.inventory) + { + if (!player.Group.HasPermission(Permissions.ignorestackhackdetection) && item.stack > item.maxStack && item.type != 0) + { + check = "Remove Item " + item.name + " (" + item.stack + ") exceeds max stack of " + item.maxStack; + } + } + player.IgnoreActionsForCheating = check; + check = "none"; foreach (Item item in player.TPlayer.armor) { if (!player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned(item.name, player)) - check = "Remove Armor/Accessory (" + item.name + ")"; + { + player.SetBuff(30, 120); //Bleeding + player.SetBuff(36, 120); //Broken Armor + check = "Remove Armor/Accessory " + item.name; + } } player.IgnoreActionsForDisabledArmor = check; + if (CheckIgnores(player)) + { + player.SetBuff(33, 120); //Weak + player.SetBuff(32, 120); //Slow + player.SetBuff(23, 120); //Cursed + } + else if(!player.Group.HasPermission(Permissions.usebanneditem) && TShock.Itembans.ItemIsBanned(player.TPlayer.inventory[player.TPlayer.selectedItem].name, player)) + { + player.SetBuff(23, 120); //Cursed + } } } Console.Title = string.Format("TerrariaShock Version {0} ({1}) ({2}/{3})", Version, VersionCodename, count, Config.MaxSlots); @@ -796,7 +819,6 @@ namespace TShockAPI if (Config.PvPMode == "always" && !player.TPlayer.hostile) { - player.IgnoreActionsForPvP = true; player.SendMessage("PvP is forced! Enable PvP else you can't move or do anything!", Color.Red); } @@ -1235,7 +1257,7 @@ namespace TShockAPI public static bool CheckIgnores(TSPlayer player) { bool check = false; - if (player.IgnoreActionsForPvP) + if (Config.PvPMode == "always" && !player.TPlayer.hostile) check = true; if (player.IgnoreActionsForInventory != "none") check = true; @@ -1243,6 +1265,8 @@ namespace TShockAPI check = true; if (player.IgnoreActionsForDisabledArmor != "none") check = true; + if (player.IgnoreActionsForClearingTrashCan) + check = true; if (!player.IsLoggedIn && Config.RequireLogin) check = true; return check;