Improve OnPlayerBuff logic to properly handle buffs from other players
Previously, we checked if the target player was null, before checking if their ID was out of bounds, so the check was moved to be first. We now check if the buff being applied is within bounds. We introduce `AddPlayerBuffWhitelist` to replace `WhitelistBuffMaxTime`, which allows us to specify a maximum amount of ticks a buff can be applied to another player for, and if it can be applied without the target being in PvP. If a buff is not within this array, it is *not* allowed to be applied by other players. When rejecting from `OnPlayerBuff`, we send a `PlayerBuff` instead of `PlayerAddBuff`, to sync the current buffs of the target, without syncing the rejected one.
This commit is contained in:
parent
16d48a4a56
commit
23fd7acd79
2 changed files with 244 additions and 42 deletions
|
|
@ -79,20 +79,8 @@ namespace TShockAPI
|
|||
{
|
||||
private static Dictionary<PacketTypes, GetDataHandlerDelegate> GetDataHandlerDelegates;
|
||||
|
||||
public static int[] WhitelistBuffMaxTime;
|
||||
|
||||
public static void InitGetDataHandler()
|
||||
{
|
||||
#region Blacklists
|
||||
|
||||
WhitelistBuffMaxTime = new int[Main.maxBuffTypes];
|
||||
WhitelistBuffMaxTime[20] = 600;
|
||||
WhitelistBuffMaxTime[0x18] = 1200;
|
||||
WhitelistBuffMaxTime[0x1f] = 120;
|
||||
WhitelistBuffMaxTime[0x27] = 420;
|
||||
|
||||
#endregion Blacklists
|
||||
|
||||
GetDataHandlerDelegates = new Dictionary<PacketTypes, GetDataHandlerDelegate>
|
||||
{
|
||||
{ PacketTypes.PlayerInfo, HandlePlayerInfo },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue