---
description: >-
  On this page we want to show you the real basics of Onsharp plugin
  development. We will create our first class with all needings so it will be
  loaded by Onsharp and explain the base concepts of it.
---

# Create a Basic Plugin

## Get the Onsharp Assembly

Head over to NUGET to get the Onsharp API assembly.

{% embed url="https://www.nuget.org/packages/Onsharp/" %}

## Create the Main Class

Each Plugin needs a Main Class. This main class is the starting point of the Onsharp Plugin. The Base Class for creating a Main Class is the abstract class `Onsharp.Plugins.Plugin`. Your Main Class needs to extend this class like so:

```csharp
using Onsharp.Plugins;

namespace Tutorial
{
    public class PluginMain : Plugin
    {
        public override void OnStart()
        {
             //Your start up logic here   
        }
        
        public override void OnStop()
        {
            //Your stop and clean up logic here
        }   
    }
}
```

You see, that the abstract class forces you to override two methods: The `OnStart()` which gets called when your plugin gets started and the `OnStop()` which gets called when your plugin gets stopped.\
Even though you finished up the Main Class, the plugin won't work. You need to define meta information in order to use the plugin. The meta data will be needed to identify your plugin and bring the systems together. To define the meta data you need to mark your Main Class with the **PluginMeta** attribute:

```csharp
using Onsharp.Plugins;

namespace Tutorial
{
    [PluginMeta("PLUGIN_ID", "PLUGIN_NAME", "VERSION", "AUTHOR")]
    public class PluginMain : Plugin
    {
        public override void OnStart()
        {
             //Your start up logic here   
        }
        
        public override void OnStop()
        {
            //Your stop and clean up logic here
        }   
    }
}
```

Here you have the explanation of the meta datas:

* The **PluginID**: The PluginID is the main identifier for your plugin. It must be unique, duplicated plugins won't be loaded by Onsharp. The PluginID is needed to identify your Plugin as well as a key for specific systems in Onsharp like the Data Storage system.
* The **Plugin Name**: The Name of a Plugin is an optional parameter and can be left away. The Plugin Name is intended solely to replace the PluginID as a display name in some places in Onsharp like the Logger.
* The **Version**: The Version of a plugin is required and tells you what stage of development the current plugin has.
* The **Author**: The Author of a the plugin is optional and will be replaced with OnsharpTeam if not entered. The author is just an information for the users by whom the plugin is made.

Now, that we defined a valied main class with the needed meta information, we can compile the code into a valid DLL and put it into the Onsharp plugins folder at the following path: `SERVER_DIR/onsharp/plugins` , Onsharp will take care of the rest. When you start the Onset server, Onsharp gets started and later your plugin, too. If it is the first time your plugin gets started, Onsharp will create all files and directories needed for management for you (e.g. the plugin's data folder and logs folder).

Now you are ready to go, to create your plugin. We recommend that you use the other pages to further explore the Onsharp Framework and learn its concepts and techniques. There are almost no limits for you.

{% hint style="warning" %}
One more thing in our own interest: If you find any bugs in the documentation or technical stuff, or if you have further questions, or if you just want to have a certain feature, feel free to tell us your request [here](https://github.com/OnsharpTeam/Onsharp/issues).
{% endhint %}

