commit 2682c80120be0b5a40adb50b25eb67f9576a3a4d Author: Wyatt J. Miller Date: Wed Aug 13 21:27:09 2025 -0400 initial commit diff --git a/HelloWorldPlugin/.gitignore b/HelloWorldPlugin/.gitignore new file mode 100644 index 0000000..cbbd0b5 --- /dev/null +++ b/HelloWorldPlugin/.gitignore @@ -0,0 +1,2 @@ +bin/ +obj/ \ No newline at end of file diff --git a/HelloWorldPlugin/HelloWorldPlugin.cs b/HelloWorldPlugin/HelloWorldPlugin.cs new file mode 100644 index 0000000..a1ec116 --- /dev/null +++ b/HelloWorldPlugin/HelloWorldPlugin.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; +using TShockAPI; +using Terraria; +using TerrariaApi.Server; + +namespace HelloWorldPlugin +{ + [ApiVersion(2, 1)] + public class HelloWorldPlugin : TerrariaPlugin + { + /// + /// Gets the author(s) of this plugin + /// + public override string Author => "wymiller"; + + /// + /// Gets the description of this plugin. + /// A short, one lined description that tells people what your plugin does. + /// + public override string Description => "A hello world plugin"; + + /// + /// Gets the name of this plugin. + /// + public override string Name => "Hello World Plugin"; + + /// + /// Gets the version of this plugin. + /// + public override Version Version => new Version(1, 0, 0, 0); + + /// + /// Initializes a new instance of the HelloWorldPlugin class. + /// This is where you set the plugin's order and perfrom other constructor logic + /// + public HelloWorldPlugin(Main game) : base(game) + { + Console.WriteLine("[HelloWorldPlugin] Plugin is being loaded..."); + } + + /// + /// Handles plugin initialization. + /// Fired when the server is started and the plugin is being loaded. + /// You may register hooks, perform loading procedures etc here. + /// + public override void Initialize() + { + Console.WriteLine("[HelloWorldPlugin] Hello, World!"); + ServerApi.Hooks.NetGreetPlayer.Register(this, OnPlayerJoin); + } + + /// + /// Handles the OnPlayerJoin event (called a hook) + /// Fired on any player joining the game + /// + /// + private void OnPlayerJoin(GreetPlayerEventArgs args) + { + var player = TShock.Players[args.Who]; + if (player != null && player.Active) + { + player.SendMessage($"Hello, {player}!", Color.Green); + } + } + + /// + /// Handles plugin disposal logic. + /// *Supposed* to fire when the server shuts down. + /// You should deregister hooks and free all resources here. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + // Deregister hooks here + if (disposing) + { + ServerApi.Hooks.NetGreetPlayer.Deregister(this, OnPlayerJoin); + Console.WriteLine("[HelloWorldPlugin] Plugin is being unloaded..."); + } + } + base.Dispose(disposing); + } + } +} \ No newline at end of file diff --git a/HelloWorldPlugin/HelloWorldPlugin.csproj b/HelloWorldPlugin/HelloWorldPlugin.csproj new file mode 100644 index 0000000..a24ed3d --- /dev/null +++ b/HelloWorldPlugin/HelloWorldPlugin.csproj @@ -0,0 +1,15 @@ + + + + net9.0 + enable + enable + + + + + + + + + diff --git a/TerrariaPluginTemplate.sln b/TerrariaPluginTemplate.sln new file mode 100644 index 0000000..d6ba76d --- /dev/null +++ b/TerrariaPluginTemplate.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorldPlugin", "HelloWorldPlugin\HelloWorldPlugin.csproj", "{F02910DB-41DA-4297-99BE-49B90A594C94}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F02910DB-41DA-4297-99BE-49B90A594C94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F02910DB-41DA-4297-99BE-49B90A594C94}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F02910DB-41DA-4297-99BE-49B90A594C94}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F02910DB-41DA-4297-99BE-49B90A594C94}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal