OnPlayerSlot now uses GetDataHandledEventArgs.

This commit is contained in:
Lucas Nicodemus 2017-12-23 14:14:58 -07:00
parent 3f9c0ebbfe
commit d54af26916

View file

@ -207,7 +207,7 @@ namespace TShockAPI
/// <summary> /// <summary>
/// For use in a PlayerSlot event /// For use in a PlayerSlot event
/// </summary> /// </summary>
public class PlayerSlotEventArgs : HandledEventArgs public class PlayerSlotEventArgs : GetDataHandledEventArgs
{ {
/// <summary> /// <summary>
/// The Terraria playerID /// The Terraria playerID
@ -234,13 +234,15 @@ namespace TShockAPI
/// PlayerSlot - called at a PlayerSlot event /// PlayerSlot - called at a PlayerSlot event
/// </summary> /// </summary>
public static HandlerList<PlayerSlotEventArgs> PlayerSlot = new HandlerList<PlayerSlotEventArgs>(); public static HandlerList<PlayerSlotEventArgs> PlayerSlot = new HandlerList<PlayerSlotEventArgs>();
private static bool OnPlayerSlot(byte _plr, byte _slot, short _stack, byte _prefix, short _type) private static bool OnPlayerSlot(TSPlayer player, MemoryStream data, byte _plr, byte _slot, short _stack, byte _prefix, short _type)
{ {
if (PlayerSlot == null) if (PlayerSlot == null)
return false; return false;
var args = new PlayerSlotEventArgs var args = new PlayerSlotEventArgs
{ {
Player = player,
Data = data,
PlayerId = _plr, PlayerId = _plr,
Slot = _slot, Slot = _slot,
Stack = _stack, Stack = _stack,
@ -1603,7 +1605,7 @@ namespace TShockAPI
bypassTrashCanCheck = true; bypassTrashCanCheck = true;
} }
if (OnPlayerSlot(plr, slot, stack, prefix, type) || plr != args.Player.Index || slot < 0 || if (OnPlayerSlot(args.Player, args.Data, plr, slot, stack, prefix, type) || plr != args.Player.Index || slot < 0 ||
slot > NetItem.MaxInventory) slot > NetItem.MaxInventory)
return true; return true;
if (args.Player.IgnoreSSCPackets) if (args.Player.IgnoreSSCPackets)