This is a template for an h1z1-server plugin that can be used as a starting point for developing custom plugins. It extends the BasePlugin class provided by the h1z1-server framework and demonstrates how to override the default behavior of a public function in the ZoneServer2016 class.
To use this plugin template, follow these steps:
-
Make sure you have the h1z1-server framework installed and set up in your project. Refer to the main h1z1-server repository's documentation for installation and setup instructions.
-
Clone and pull this plugin-template repository, and put it into the "plugins" folder generated by your h1z1-server instance.
-
Update the tsconfig.json of the plugin so that the "@h1z1-server/*" path points to your h1z1-server folder so that your plugin can resolve imports.
-
Customize the plugin properties to fit your needs:
- Update the
name,description,author, andversionproperties to reflect your plugin's information. - Define any additional properties required by your plugin.
- Modify the
loadConfigmethod to handle loading configuration values fromconfig.yamlor any other configuration source specific to your plugin.
- Update the
-
Implement the
initmethod to add your custom logic:- Use the
serverparameter to access theZoneServer2016instance and its methods. - Override the default behavior of a public function, such as
sendChatText, by using theserver.pluginManager.hookMethodmethod. Customize the logic inside the hook to suit your needs.
- Use the
-
Compile / transpile the plugin using the
npm run buildcommand. -
Build and run your h1z1-server project, and the plugin will be loaded and activated.
Once the plugin is loaded and activated, it will override the default behavior of the sendChatText function in the ZoneServer2016 class. Instead of sending the original message parameter to the client, it will send the custom chatTextMessage property defined in the plugin.
To customize the plugin further, refer to the main h1z1-server repository's documentation, as well as the available classes and methods provided by the server framework.