Make a Plugin Optional but Database-Ready
Use Soft Dependencies
Some plugins work fine without a database but gain extra features when MongoDB is available. Use soft dependencies to allow this flexibility.
1. Open your plugin's plugin.yml
2. Add the line softdepend: [MongoDBLoader]
3. Save and restart the server
How This Works
With softdepend, your plugin loads regardless of whether MongoDB Loader Plugin is present. However, if MongoDB Loader Plugin is installed, it will load first, giving your plugin access to database tools.
Code Considerations
Your plugin code should check whether MongoDB Loader Plugin loaded before attempting database operations. If it's not available, your plugin should fall back to alternative storage methods—like local files—or disable database features gracefully.
This approach is ideal for plugins that enhance servers with optional features, ensuring they never break a server setup.