initial commit
This commit is contained in:
2
HelloWorldPlugin/.gitignore
vendored
Normal file
2
HelloWorldPlugin/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
bin/
|
||||||
|
obj/
|
89
HelloWorldPlugin/HelloWorldPlugin.cs
Normal file
89
HelloWorldPlugin/HelloWorldPlugin.cs
Normal file
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the author(s) of this plugin
|
||||||
|
/// </summary>
|
||||||
|
public override string Author => "wymiller";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the description of this plugin.
|
||||||
|
/// A short, one lined description that tells people what your plugin does.
|
||||||
|
/// </summary>
|
||||||
|
public override string Description => "A hello world plugin";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name of this plugin.
|
||||||
|
/// </summary>
|
||||||
|
public override string Name => "Hello World Plugin";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the version of this plugin.
|
||||||
|
/// </summary>
|
||||||
|
public override Version Version => new Version(1, 0, 0, 0);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the HelloWorldPlugin class.
|
||||||
|
/// This is where you set the plugin's order and perfrom other constructor logic
|
||||||
|
/// </summary>
|
||||||
|
public HelloWorldPlugin(Main game) : base(game)
|
||||||
|
{
|
||||||
|
Console.WriteLine("[HelloWorldPlugin] Plugin is being loaded...");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles plugin initialization.
|
||||||
|
/// Fired when the server is started and the plugin is being loaded.
|
||||||
|
/// You may register hooks, perform loading procedures etc here.
|
||||||
|
/// </summary>
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
Console.WriteLine("[HelloWorldPlugin] Hello, World!");
|
||||||
|
ServerApi.Hooks.NetGreetPlayer.Register(this, OnPlayerJoin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the OnPlayerJoin event (called a hook)
|
||||||
|
/// Fired on any player joining the game
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="args"></param>
|
||||||
|
private void OnPlayerJoin(GreetPlayerEventArgs args)
|
||||||
|
{
|
||||||
|
var player = TShock.Players[args.Who];
|
||||||
|
if (player != null && player.Active)
|
||||||
|
{
|
||||||
|
player.SendMessage($"Hello, {player}!", Color.Green);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles plugin disposal logic.
|
||||||
|
/// *Supposed* to fire when the server shuts down.
|
||||||
|
/// You should deregister hooks and free all resources here.
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
HelloWorldPlugin/HelloWorldPlugin.csproj
Normal file
15
HelloWorldPlugin/HelloWorldPlugin.csproj
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="OTAPI.Upcoming" Version="3.2.6" />
|
||||||
|
<PackageReference Include="TSAPI" Version="5.2.1" />
|
||||||
|
<PackageReference Include="TShock" Version="5.2.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
16
TerrariaPluginTemplate.sln
Normal file
16
TerrariaPluginTemplate.sln
Normal file
@@ -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
|
Reference in New Issue
Block a user