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.

Click Create.
In JetBrains Rider, create new new solution by clicking New Solution.

A window will pop up and you have to select the Class Library at the list to the left.

Then give the project a name and select a solution directory of your choice.

At last please select net8.0 as your Target Framework and press Create at the bottom right

Picking net8.0 as your Target Framework is very important. Make sure you have installed the .NET SDK 8.0 from Microsoft
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.
You should now be in JebBrains Rider with a Class1.cs file.
In the solution explorer, expand your project and right click on Dependencies , then click Reference...

A window will open, click on Add From...

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

Click on Open .
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.
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:

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.
Just rename the Class1.cs to Plugin.cs like this or use shortcut for it.


We added a constructor and a logger message to check if everything works fine.
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() { }
}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>You can open it like this:

And add those two options:

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