-
Notifications
You must be signed in to change notification settings - Fork 0
Plugin Tutorial [LeoConsole v1.5.0]
BoettcherDasOriginal edited this page May 1, 2022
·
1 revision
If you use Visual Studio 2022 choose: home -> new Project -> class library (.NET 6)
Than in your project Dependencies -> Add Project Reference -> and add ILeoConsole.dll
which can be found in your LeoConsole installation folder.
If your not using Visual Studio, just make sure that u attach ILeoConsole.dll
to your project
// https://github.com/BoettcherDasOriginal/LeoConsole-ExamplePlugin/
// ExamplePlugin.cs
using ILeoConsole;
using ILeoConsole.Plugin;
using ILeoConsole.Core;
namespace LeoConsole_ExamplePlugin
{
public class ExamplePlugin : IPlugin
{
public string Name { get { return "ExamplePlugin"; } }
public string Explanation { get { return "Example Plugin"; } }
private IData _data;
public IData data { get { return _data; } set { _data = value; } }
private List<ICommand> _Commands;
public List<ICommand> Commands { get { return _Commands; } set { _Commands = value; } }
public void PluginMain()
{
// Add Data
_data = new ConsoleData();
// Add Commands
_Commands = new List<ICommand>();
_Commands.Add(new randomNumber());
}
}
}
- Name -> the name of your plugin
- Explanation -> the description of your plugin
- data -> an interface to the data class from LeoConsole
- Commands -> a list of all your custom commands
- PluginMain() -> is called when LeoConsole loads your plugin
// https://github.com/BoettcherDasOriginal/LeoConsole-ExamplePlugin/
// randomNumber.cs
using ILeoConsole;
using ILeoConsole.Plugin;
using ILeoConsole.Core;
namespace LeoConsole_ExamplePlugin
{
public class randomNumber : ICommand
{
Random rand = new Random();
public string Name { get { return "randomNumber"; } }
public string Description { get { return "generiert einen zuffälligen Code"; } }
public Action CommandFunktion { get { return () => Command(); } }
private string[] _InputProperties;
public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } }
public void Command()
{
try
{
int length = Convert.ToInt32(InputProperties[1]);
int Buchstabe;
int textOrNumber;
if (_InputProperties != null)
{
Console.WriteLine("Neuer Code: ");
for (int i = 0; i < length; i++)
{
else
{
Console.Write(rand.Next(0, 9).ToString());
}
}
Console.WriteLine("");
}
}
catch (Exception ex)
{
Console.WriteLine("Exception: " + ex.Message + "\n");
}
}
}
}
- Name -> the name of your command
- Description -> the description of your command
- InputProperties -> the given parameter from the user
- Command() -> the main function of your command
Note: Make sure to add this command class to your command list in the plugin main class
// https://github.com/BoettcherDasOriginal/LeoConsole-ExamplePlugin/
// randomNumber.cs
using ILeoConsole;
using ILeoConsole.Plugin;
using ILeoConsole.Core;
namespace LeoConsole_ExamplePlugin
{
public class ConsoleData : IData
{
public static User _User;
public User User { get { return _User; } set { _User = value; } }
public static string _SavePath;
public string SavePath { get { return _SavePath; } set { _SavePath = value; } }
public static string _DownloadPath;
public string DownloadPath { get { return _DownloadPath; } set { _DownloadPath = value; } }
}
}
- User -> the current logged in user
- SavePath -> the current save path
- DownloadPath -> the current download path
Note: Make sure to set this to your data class in the plugin main class
- Go to your LeoConsole installation folder -> data -> plugins
- Copy your Plugin dll in to this folder
- Start LeoConsole.exe and your plugin should be loaded
- Test your Functions and wait for something to go wrong :D
- Compile your sources to an .dll file, for example:
examplePlugin.dll
- Go to https://github.com/BoettcherDasOriginal/LeoConsole/blob/main/PackageList.txt
- Add in a new line:
pkg -n:yourPluginName -d:yourDirectDownloadLink
(Make Sure that the DownloadLink is withouthttps://
)
For Example:pkg -n:examplePlugin -d:github.com/BoettcherDasOriginal/LeoConsole-ExamplePlugin/releases/latest/download/LeoConsole-ExamplePlugin.dll
- Make an Pull Request and wait for me to accept it
- Install your Plugin with the package manager:
pkg update pkg get yourPluginName
The complete source code of the sample plugin can be found here
An awesome plugin template by @alexcoder04 can be found here