initial commit

got healing working only in the wrong way
This commit is contained in:
2025-08-18 22:50:41 -04:00
commit 5aea4453b0
6 changed files with 165 additions and 0 deletions

61
HealingPlugin.cs Normal file
View File

@@ -0,0 +1,61 @@
using Terraria;
using TShockAPI;
using TerrariaApi.Server;
namespace TerrariaHealingPlugin;
[ApiVersion(2, 1)]
public class HealingPlugin : TerrariaPlugin
{
public override string Author => "Sneefaria Maintainers";
public override string Name => "HealingPlugin";
public override string Description => "A healing plugin, duh";
public override Version Version => new Version(1, 0, 0);
private DateTime _lastCheck = DateTime.UtcNow;
public HealingPlugin(Main game) : base(game) { }
public override void Initialize()
{
ServerApi.Hooks.GamePostInitialize.Register(this, OnGamePostInitialize);
ServerApi.Hooks.ServerJoin.Register(this, OnServerJoin);
ServerApi.Hooks.GameUpdate.Register(this, OnUpdate);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
ServerApi.Hooks.GamePostInitialize.Deregister(this, OnGamePostInitialize);
ServerApi.Hooks.ServerJoin.Deregister(this, OnServerJoin);
ServerApi.Hooks.GameUpdate.Deregister(this, OnUpdate);
}
base.Dispose(disposing);
}
private void OnUpdate(EventArgs args)
{
if ((DateTime.UtcNow - _lastCheck).TotalSeconds >= 1)
{
_lastCheck = DateTime.UtcNow;
foreach (var player in TShock.Players)
{
if (player != null && player.Active)
{
player.Heal(25); // heal all players 25 HP/second
}
}
}
}
private void OnGamePostInitialize(EventArgs args)
{
TShock.Log.Info($"{Name} v{Version} has been initialized.");
}
private void OnServerJoin(JoinEventArgs args)
{
TShock.Log.Info($"{args.Who} has joined the server.");
}
}