Created Plugin Development (markdown)

Julian 2020-09-28 20:25:17 -04:00
parent 4f33bc3aff
commit d1f8fef59d

47
Plugin-Development.md Normal file

@ -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.