Creating a Plugin

A general tutorial for creating a Hogwarp plugin. Version: 0.8.0 beta 2

Create a project

In Visual Studio, create a new project, select Class Library, then click Next.

On the next page, give the project the name of your choice and click Next. In this example we use Tutorial.

When asked to select the Framework, pick .NET 8.0 (Long Term Support). This is very important!

Click Create.

Configure the project

You should now be in Visual Studio with a basic class.

In the solution explorer, expand your project and right click on dependencies, then click Add Project Reference...

A window will open, click on Browse...

Go to the HogWarp install location, then in the Server folder and select HogWarpSdk.dll.

Click on Add. Then Ok.

Entry

The server mods need to respect a special naming convention to be loaded correctly.

When attempting to load a mod, the server will look for the ModName.Plugin class, where ModName is the name you chose when creating your project.

Create a Plugin.cs file in your solution and fill out the required fields.

Plugin.cs
namespace Tutorial;

public class Plugin : HogWarpSdk.IPlugin
{
    public string Author { get; } = "YourName";
    public string Name { get; } = "Tutorial";
    public Version Version { get; } = new(1, 0, 0, 0);
    
    public Plugin()
    {
        var logger = new HogWarpSdk.Systems.Logger(Name);
        logger.Info("Hello, World!");
    }

    public void PostLoad() { }

    public void Shutdown() { }
}   

For now, we leave PostLoadand Shutdown empty, as we don't need them here.

Output Path Generation

If you choose this folder structure for you project:

Hogwarp->Server->Server->YourPluginName

You can of course alter this path to your likings if you know how to do so.

You can add the following PropertyGroup into your csproj file:

<PropertyGroup>
    <OutputPath>$(SolutionDir)..\..\Mods\$(AssemblyName)\</OutputPath>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

If you have done this and build your mod it should have generated the folders and files for you.

The files should now be in your Hogwarp->Server->Mods folder.

Simple Output Path

Now build your mod, you will see a path to a DLL being produced, browse to this location.

You must now copy the DLL so that you get something like Server/Mods/ModName/ModName.dll.

For example with the "Tutorial" plugin the path will be Server/Mods/Tutorial/Tutorial.dll

Launching

If you now launch the server you should see your plugin gets loaded correctly:

Last updated