diff --git a/TShockAPI/Bouncer.cs b/TShockAPI/Bouncer.cs
index 27715e81..d76d488f 100644
--- a/TShockAPI/Bouncer.cs
+++ b/TShockAPI/Bouncer.cs
@@ -49,6 +49,46 @@ namespace TShockAPI
// Setup hooks
GetDataHandlers.SendTileSquare.Register(OnSendTileSquare);
+ GetDataHandlers.HealOtherPlayer.Register(OnHealOtherPlayer);
+ }
+
+ /// OnHealOtherPlayer - The handler for the HealOther events in Bouncer
+ /// sender
+ /// args
+ internal void OnHealOtherPlayer(object sender, GetDataHandlers.HealOtherPlayerEventArgs args)
+ {
+ short amount = args.Amount;
+ byte plr = args.TargetPlayerIndex;
+
+ if (amount <= 0 || Main.player[plr] == null || !Main.player[plr].active)
+ {
+ args.Handled = true;
+ return;
+ }
+
+ if (amount > TShock.Config.MaxDamage * 0.2)
+ {
+ args.Player.Disable("HealOtherPlayer cheat attempt!", DisableFlags.WriteToLogAndConsole);
+ args.Handled = true;
+ return;
+ }
+
+ if (args.Player.HealOtherThreshold > TShock.Config.HealOtherThreshold)
+ {
+ args.Player.Disable("Reached HealOtherPlayer threshold.", DisableFlags.WriteToLogAndConsole);
+ args.Handled = true;
+ return;
+ }
+
+ if (TShock.CheckIgnores(args.Player) || (DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
+ {
+ args.Handled = true;
+ return;
+ }
+
+ args.Player.HealOtherThreshold++;
+ args.Handled = false;
+ return;
}
/// OnSendTileSquare - The handler for SendTileSquare events in Bouncer
diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs
index 40eec2c5..153bd7a1 100644
--- a/TShockAPI/GetDataHandlers.cs
+++ b/TShockAPI/GetDataHandlers.cs
@@ -532,6 +532,43 @@ namespace TShockAPI
return false;
}
+ /// HandledEventArgs - The event args object for the HealOtherPlayer event
+ public class HealOtherPlayerEventArgs : HandledEventArgs
+ {
+ /// Player - The TSPlayer object that caused the event
+ public TSPlayer Player { get; set; }
+
+ /// TargetPlayerIndex - The Terraria player index of the target player
+ public byte TargetPlayerIndex { get; set; }
+
+ /// Amount - The amount to heal by
+ public short Amount { get; set; }
+ }
+
+ /// HealOtherPlayer - When a player heals another player
+ public static HandlerList HealOtherPlayer;
+
+ /// OnHealOtherPlayer - Fires the HealOtherPlayer event
+ /// player - The TSPlayer that started the event
+ /// targetPlayerIndex - The Terraria player index that the event targets
+ /// amount - The amount to heal
+ /// bool
+ private static bool OnHealOtherPlayer(TSPlayer player, byte targetPlayerIndex, short amount)
+ {
+ if (HealOtherPlayer == null)
+ return false;
+
+ var args = new HealOtherPlayerEventArgs
+ {
+ Player = player,
+ TargetPlayerIndex = targetPlayerIndex,
+ Amount = amount,
+ };
+
+ HealOtherPlayer.Invoke(null, args);
+ return args.Handled;
+ }
+
///
/// For use in a SendTileSquare event
///
@@ -1312,29 +1349,9 @@ namespace TShockAPI
byte plr = args.Data.ReadInt8();
short amount = args.Data.ReadInt16();
- if (amount <= 0 || Main.player[plr] == null || !Main.player[plr].active)
- {
+ if (OnHealOtherPlayer(args.Player, plr, amount))
return true;
- }
- if (amount > TShock.Config.MaxDamage * 0.2)
- {
- args.Player.Disable("HealOtherPlayer cheat attempt!", DisableFlags.WriteToLogAndConsole);
- return true;
- }
-
- if (args.Player.HealOtherThreshold > TShock.Config.HealOtherThreshold)
- {
- args.Player.Disable("Reached HealOtherPlayer threshold.", DisableFlags.WriteToLogAndConsole);
- return true;
- }
-
- if (TShock.CheckIgnores(args.Player) || (DateTime.UtcNow - args.Player.LastThreat).TotalMilliseconds < 5000)
- {
- return true;
- }
-
- args.Player.HealOtherThreshold++;
return false;
}