initial commit
got healing working only in the wrong way
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
.vs/
|
61
HealingPlugin.cs
Normal file
61
HealingPlugin.cs
Normal 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.");
|
||||||
|
}
|
||||||
|
}
|
12
TerrariaHealingPlugin.csproj
Normal file
12
TerrariaHealingPlugin.csproj
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="OTAPI.Upcoming" Version="3.1.20" />
|
||||||
|
<PackageReference Include="TSAPI" Version="5.2.1" />
|
||||||
|
<PackageReference Include="TShock" Version="5.2.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
40
flake.lock
generated
Normal file
40
flake.lock
generated
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-schemas": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1721999734,
|
||||||
|
"narHash": "sha256-G5CxYeJVm4lcEtaO87LKzOsVnWeTcHGKbKxNamNWgOw=",
|
||||||
|
"rev": "0a5c42297d870156d9c57d8f99e476b738dcd982",
|
||||||
|
"revCount": 75,
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.1.5/0190ef2f-61e0-794b-ba14-e82f225e55e6/source.tar.gz"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://flakehub.com/f/DeterminateSystems/flake-schemas/%2A"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1755471983,
|
||||||
|
"narHash": "sha256-axUoWcm4cNQ36jOlnkD9D40LTfSQgk8ExfHSRm3rTtg=",
|
||||||
|
"rev": "48f4c982de68d966421d2b6f1ddbeb6227cc5ceb",
|
||||||
|
"revCount": 808437,
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2505.808437%2Brev-48f4c982de68d966421d2b6f1ddbeb6227cc5ceb/0198be44-d6e9-7645-acdf-d6811d0e6b6b/source.tar.gz"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://flakehub.com/f/NixOS/nixpkgs/%2A"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-schemas": "flake-schemas",
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
46
flake.nix
Normal file
46
flake.nix
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# This flake was initially generated by fh, the CLI for FlakeHub (version 0.1.22)
|
||||||
|
{
|
||||||
|
description = "Terraria Plugin flake";
|
||||||
|
inputs = {
|
||||||
|
flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*";
|
||||||
|
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
flake-schemas,
|
||||||
|
nixpkgs,
|
||||||
|
}: let
|
||||||
|
supportedSystems = ["x86_64-linux" "aarch64-darwin"];
|
||||||
|
forEachSupportedSystem = f:
|
||||||
|
nixpkgs.lib.genAttrs supportedSystems (system:
|
||||||
|
f {
|
||||||
|
pkgs = import nixpkgs {inherit system;};
|
||||||
|
});
|
||||||
|
in {
|
||||||
|
schemas = flake-schemas.schemas;
|
||||||
|
|
||||||
|
devShells = forEachSupportedSystem ({pkgs}: {
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
packages = with pkgs; [
|
||||||
|
curl
|
||||||
|
git
|
||||||
|
jq
|
||||||
|
wget
|
||||||
|
nixpkgs-fmt
|
||||||
|
dotnet-sdk_9
|
||||||
|
dotnetPackages.Nuget
|
||||||
|
omnisharp-roslyn
|
||||||
|
mono
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
env = {
|
||||||
|
DOTNET_ROOT = "${pkgs.dotnet-sdk_9}/share/dotnet";
|
||||||
|
DOTNET_GENERATE_ASPNET_CERTIFICATE = "false";
|
||||||
|
DOTNET_NOLOGO = "true";
|
||||||
|
DOTNET_CLI_TELEMETRY_OPTOUT = "false";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
Reference in New Issue
Block a user