From d1f8fef59d4990b1f3f2fca13a3ac95b10c2e503 Mon Sep 17 00:00:00 2001 From: Julian Date: Mon, 28 Sep 2020 20:25:17 -0400 Subject: [PATCH] Created Plugin Development (markdown) --- Plugin-Development.md | 47 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Plugin-Development.md diff --git a/Plugin-Development.md b/Plugin-Development.md new file mode 100644 index 0000000..e74df39 --- /dev/null +++ b/Plugin-Development.md @@ -0,0 +1,47 @@ +## Extending Plugins + +### NuGet Package +The NuGet package for **IW4MAdmin's** "Shared Library" can be obtained from the [NuGet Gallery](https://www.nuget.org/packages/RaidMax.IW4MAdmin.SharedLibraryCore) +Referencing this package will give you the ability to write plugins against **IW4MAdmin's** core library. +### Code +**IW4MAdmin's** functionality can be extended by writing additional plugins in C#. +Each class library must implement the `IPlugin` interface. +See the existing [plugins](https://github.com/RaidMax/IW4M-Admin/tree/master/Plugins) for examples. +### JavaScript +**IW4MAdmin** functionality can also be extended using JavaScript. +The JavaScript parser supports [ECMA 5.1](https://ecma-international.org/ecma-262/5.1/) standards. +### Plugin Object Template +In order to be properly parsed by the JavaScript engine, every plugin must conform to the following template. +```js +var plugin = { + author: 'YourHandle', + version: 1.0, + name: 'Sample JavaScript Plugin', + + onEventAsync: function (gameEvent, server) { + }, + + onLoadAsync: function (manager) { + }, + + onUnloadAsync: function () { + }, + + onTickAsync: function (server) { + } +}; +``` +### Required Properties +- `author` — [string] Author of the plugin (usually your name or online name/alias) +- `version` — [float] Version number of your plugin (useful if you release several different versions) +- `name` — [string] Name of your plugin (be descriptive!) +- `onEventAsync` — [function] Handler executed when an event occurs + - `gameEvent` — [parameter object] Object containing event type, origin, target, and other info (see the GameEvent class declaration) + - `server` — [parameter object] Object containing information and methods about the server the event occured on (see the Server class declaration) +- `onLoadAsync` — [function] Handler executed when the plugin is loaded by code + - `manager` — [parameter object] Object reference to the application manager (see the IManager interface definition) +- `onUnloadAsync` — [function] Handler executed when the plugin is unloaded by code (see live reloading) +- `onTickAsync` — [function] Handler executed approximately once per second by code *(unimplemented as of version 2.\*)* + - `server` — [parameter object] Object containing information and methods about the server the event occured on (see the Server class declaration) +### Live Reloading +Thanks to JavaScript's flexibility and parsability, the plugin importer scans the plugins folder and reloads the JavaScript plugins on demand as they're modified. This allows faster development/testing/debugging. \ No newline at end of file