Introduction
Blacksmith Plugin Manager is the first of a suite of plugin development tools i am working on. Originally for personal use, but now being shared.
The aim of the Plugin Manager is to provide an easy way to manage dependencies without having to worry about plugin load order. As well as allowing users to include plugins from the internet far easier.
Features
Online plugin download: Plugins can be included using a URL to download at runtime. These plugins can also be cached so they are only downloaded once for offline projects. Any plugin can be included in this manner.
Dependancy management: Compatible Plugins are not initialised until their dependancies are ready.
Access compatible plugins from anywhere: compatible plugins are stored in an object for access from other plugins, allowing for a clean global scope.
How to Use
End users: Either copy the below script and save it as a text file "BlacksmithPluginManager.js" or else right click on the github link and select "save as" or "download" depending on your browser.
However you get the file, save it in your projects js/plugins folder.
Once you have the file, enable it in the plugin manager within RPG Maker.
You can then include any plugins you have a direct url to in the plugin parameters on the page within. and they will be included within your project, no further work needed.
Plugin developers: Instead of using a Self-Executing Anonymous Function to isolate your code, compatible plugins should use the following structure:
Code:
new PluginManager.Plugin({
id: "examplePluginID", //required - this should match the filename
name: "Example Plugin", //optional - if not provided will be generated based on id
dependencies: ["exampleDependancyID", {url: http://www.example.com/examplePlugin/xyyyzzq.js, id: exampleOnlineDependancy}], //optional - you can leave out or leave an empty array for no dependancies. This should match the id (as above) of the required plugin, or else be the URL of a plugin available online, with the id matching the ID as above.
initializer: function (callback) { //required - all your code should go in here
//throw error about init function already registered
}
}
get dependencies(){
if (
!this._dependencies ||
this._dependencies instanceof Plugin ||
this._dependencies.length===0
){
return false;
}
if (this._dependencies instanceof Plugin){
return [this._dependencies];
}
if (this._dependencies.length > 0){
return this._dependencies
}
}
global (name, value){
if (value!==undefined){
Globals[this._id][name] = value;
}
return Globals[this._id][name];
}
}
PluginManager.Plugin = Plugin;
PluginManager.plugins = pluginList
})();
复制代码
FAQ
Q: I'm working on a plugin that depends on another plugin and it's not a compatible plugin, how do i include it?
A: Just include the dependancy in the same way you would a compatible plugin. All non-compatible plugins are loaded before blacksmith plugins, so you can guarantee the dependancy will be loaded first.
Q: I'm insane and want to include a plugin available over ftp.
A: Why? what even... ?!? Luckily i'm insane too and included a rudimentary FTP client in the code, so there is partial support for including ftp sources. You will need to enable caching online plugins, and run the game once in test mode for it to work though.
Q: What's this i hear about JSON files?
A: You can include configuration for any plugins in a json file named after the plugin. I.E. "js/plugins/examplePlugin.json"
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish and/or distribute copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
That no additional charge is ascribed to the inclusion of the software.
That attribution is included with any use of the software such that it is visible to end users, either within any bundled software or on any related download pages.
That no bundled items intentionally promote hate speech or discrimination of protected minorities.
Additionally, permission to sublicense, and/or sell copies of the Software may be obtained by contacting the copyright holder. This permission may come with additional and/or more specific costs and/or conditions.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Author's Notes
All feedback is greatly appreciated!