-
Notifications
You must be signed in to change notification settings - Fork 0
Add comprehensive plugin integration documentation #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Created API.md with full API reference, examples, and best practices - Created QUICKSTART.md for quick 5-minute integration guide - Updated README.md with prominent links to developer documentation Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Add null checks before instanceof checks for consistency - Fix syntax highlighting for Gradle code blocks - Simplify message checking example to use documented methods - Improve bulk notification example to avoid performance issues with getOfflinePlayers() Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Fix rate limiting example to use per-player cooldown tracking - Optimize bulk notification to avoid repeated getPlayer() calls - Add clarifying comments for version comparison - Add missing imports for Stream API usage Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive plugin integration documentation for Mailboxes, making it easy for plugin developers to integrate with the Mailboxes API. The documentation addresses issue #80 by providing clear, practical examples and step-by-step guides.
- Creates a quick start guide (QUICKSTART.md) for developers to send their first message in 5 minutes
- Adds complete API documentation (API.md) with detailed method references, examples, and best practices
- Updates README.md with clear links to the new documentation and highlights key features for developers
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| README.md | Added "For Plugin Developers" section with links to new documentation and highlighted key API features |
| QUICKSTART.md | New quick start guide with dependency setup, API access, and practical examples for common use cases |
| API.md | Comprehensive API reference with detailed method documentation, multiple real-world examples, best practices, and troubleshooting guide |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot address comments |
- Add Command, CommandExecutor, CommandSender imports to QUICKSTART.md command example - Fix QUICKSTART.md command example to properly reference plugin instance - Add Location, EventHandler, PlayerDeathEvent imports to event examples - Add ChatColor import to message checking example in API.md - Add Level import to error handling example in API.md - Add Map, HashMap, UUID imports to rate limiting example in API.md - Clarify getTrackedPlayerUUIDs() is a placeholder method in bulk notification example Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Add M_Mailbox, Message, and ArrayList imports to message checking example - Add Bukkit, Player, List, and UUID imports to bulk notification example Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 14 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public class QuestPlugin extends JavaPlugin { | ||
|
|
||
| private MailboxesAPI mailboxesAPI; | ||
|
|
||
| @Override | ||
| public void onEnable() { | ||
| setupMailboxesAPI(); | ||
| } | ||
|
|
||
| private void setupMailboxesAPI() { | ||
| Plugin plugin = getServer().getPluginManager().getPlugin("Mailboxes"); | ||
| if (plugin instanceof Mailboxes) { | ||
| mailboxesAPI = ((Mailboxes) plugin).getAPI(); | ||
| } | ||
| } | ||
|
|
||
| public void onQuestComplete(Player player, String questName) { | ||
| if (mailboxesAPI != null) { | ||
| String message = String.format( | ||
| "Congratulations! You've completed the '%s' quest! Your reward has been added to your account.", | ||
| questName | ||
| ); | ||
|
|
||
| mailboxesAPI.sendPluginMessageToPlayer("QuestPlugin", player, message); | ||
| } | ||
| } | ||
| } | ||
| ``` |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import statement for org.bukkit.plugin.java.JavaPlugin. The example extends JavaPlugin but doesn't import it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in cec6f8f. Added the missing import for JavaPlugin.
| public class EconomyPlugin extends JavaPlugin { | ||
|
|
||
| private MailboxesAPI mailboxesAPI; | ||
|
|
||
| public void notifyPlayerOfPayment(UUID playerUUID, double amount, String reason) { | ||
| if (mailboxesAPI == null) return; | ||
|
|
||
| String message = String.format( | ||
| "You received $%.2f! Reason: %s", | ||
| amount, | ||
| reason | ||
| ); | ||
|
|
||
| boolean sent = mailboxesAPI.sendPluginMessageToPlayer( | ||
| "EconomyPlugin", | ||
| playerUUID, | ||
| message | ||
| ); | ||
|
|
||
| if (sent) { | ||
| getLogger().info("Payment notification sent to player " + playerUUID); | ||
| } | ||
| } | ||
| } |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing imports for this example. The code uses JavaPlugin, Plugin, Mailboxes, and MailboxesAPI but doesn't show the necessary imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in cec6f8f. Added all missing imports: JavaPlugin, Plugin, Mailboxes, MailboxesAPI, and UUID.
API.md
Outdated
| import org.bukkit.event.entity.PlayerDeathEvent; | ||
|
|
||
| @EventHandler | ||
| public void onPlayerDeath(PlayerDeathEvent event) { | ||
| Player player = event.getEntity(); | ||
| Location deathLocation = player.getLocation(); | ||
|
|
||
| if (mailboxesAPI != null) { | ||
| String message = String.format( | ||
| "You died at coordinates: X=%.0f, Y=%.0f, Z=%.0f. Your items may still be there!", | ||
| deathLocation.getX(), | ||
| deathLocation.getY(), | ||
| deathLocation.getZ() | ||
| ); | ||
|
|
||
| // Send immediately | ||
| mailboxesAPI.sendPluginMessageToPlayer("DeathNotifier", player, message); |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import statement for org.bukkit.event.Listener. The example is annotated with @eventhandler but doesn't show that the class needs to implement Listener or provide context about event registration, which could confuse developers about how to properly use this code.
| import org.bukkit.event.entity.PlayerDeathEvent; | |
| @EventHandler | |
| public void onPlayerDeath(PlayerDeathEvent event) { | |
| Player player = event.getEntity(); | |
| Location deathLocation = player.getLocation(); | |
| if (mailboxesAPI != null) { | |
| String message = String.format( | |
| "You died at coordinates: X=%.0f, Y=%.0f, Z=%.0f. Your items may still be there!", | |
| deathLocation.getX(), | |
| deathLocation.getY(), | |
| deathLocation.getZ() | |
| ); | |
| // Send immediately | |
| mailboxesAPI.sendPluginMessageToPlayer("DeathNotifier", player, message); | |
| import org.bukkit.event.Listener; | |
| import org.bukkit.event.entity.PlayerDeathEvent; | |
| public class DeathNotifierListener implements Listener { | |
| @EventHandler | |
| public void onPlayerDeath(PlayerDeathEvent event) { | |
| Player player = event.getEntity(); | |
| Location deathLocation = player.getLocation(); | |
| if (mailboxesAPI != null) { | |
| String message = String.format( | |
| "You died at coordinates: X=%.0f, Y=%.0f, Z=%.0f. Your items may still be there!", | |
| deathLocation.getX(), | |
| deathLocation.getY(), | |
| deathLocation.getZ() | |
| ); | |
| // Send immediately | |
| mailboxesAPI.sendPluginMessageToPlayer("DeathNotifier", player, message); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in cec6f8f. Restructured the example as a proper Listener class with all necessary imports and context about event registration.
API.md
Outdated
| - Support for item attachments (optional) | ||
| - Access player mailboxes and messages | ||
|
|
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation states that messages can have "item attachments (optional)" but there's no example or documentation showing how to actually attach items to messages when sending them through the API. The sendPluginMessageToPlayer methods only accept String content. Consider adding documentation about how to work with attachments or clarifying that this feature is not available through the plugin messaging API.
| - Support for item attachments (optional) | |
| - Access player mailboxes and messages | |
| - Support for item attachments via the main Java API (optional; not available through the plugin messaging API) | |
| - Access player mailboxes and messages | |
| Note: The plugin messaging API methods (e.g., `sendPluginMessageToPlayer`) currently accept only `String` content and do not support item attachments. Use the main Java API to work with item attachments where supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in cec6f8f. Clarified that item attachments are not available through the plugin messaging API and are only available through the main plugin interface for player-to-player messages.
API.md
Outdated
| // Send immediately | ||
| mailboxesAPI.sendPluginMessageToPlayer("DeathNotifier", player, message); |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example code uses mailboxesAPI.sendPluginMessageToPlayer with a Player object to send immediate notifications, but the player has just died and respawned. There's a potential timing issue where this might not work as expected. Consider adding a comment or using the UUID variant instead to ensure the message is properly delivered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in cec6f8f. Changed to use the UUID variant to ensure the message is properly delivered even during respawn.
API.md
Outdated
| // Simple string comparison works for semantic versions like "v0.0.3" | ||
| // For more complex version checking, consider a version parsing library |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "Simple string comparison works for semantic versions like 'v0.0.3'" but this is misleading. String comparison using compareTo() does not correctly handle semantic versions. For example, "v0.0.10" would incorrectly compare as less than "v0.0.3". The comment should clarify this limitation rather than suggesting it works correctly.
| // Simple string comparison works for semantic versions like "v0.0.3" | |
| // For more complex version checking, consider a version parsing library | |
| // Basic lexicographical string comparison (not full semantic version handling) | |
| // This only works reliably if versions are consistently formatted (for example, zero-padded). | |
| // For correct semantic version comparison, use a dedicated version parsing/comparison library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in cec6f8f. Updated the comment to clearly state the limitations rather than suggesting it works correctly for semantic versions.
| ##### `getActiveMessage(int ID)` | ||
| **Returns:** `Message` - A specific active message by ID |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method name getMessage(int ID) is documented but does not exist in the M_Mailbox class. The actual method in M_Mailbox does not have this signature. According to the source code, M_Mailbox has getActiveMessage(int ID) and getArchivedMessage(int ID), but not a general getMessage(int ID) method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The getMessage(int ID) method does exist in M_Mailbox - see line 27-29 of M_Mailbox.java in the source code. Added documentation for it in cec6f8f to make it more visible in the API reference.
API.md
Outdated
| // getTrackedPlayerUUIDs() is a placeholder - implement this method to return | ||
| // the list of player UUIDs you want to notify (e.g., from a database or config) |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code comment refers to "getTrackedPlayerUUIDs()" as a placeholder method that should be implemented, but doesn't clarify that this is not part of the Mailboxes API and must be implemented by the developer. This could be confusing. Consider explicitly stating this is a method the developer needs to implement in their own plugin.
| // getTrackedPlayerUUIDs() is a placeholder - implement this method to return | |
| // the list of player UUIDs you want to notify (e.g., from a database or config) | |
| // getTrackedPlayerUUIDs() is a placeholder helper in YOUR plugin code – it is | |
| // not provided by the Mailboxes API. Implement this method in your own plugin | |
| // to return the list of player UUIDs you want to notify (e.g., from a database or config). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in cec6f8f. Expanded the comment to explicitly state this is a method the developer must implement in their own plugin code, not part of the Mailboxes API.
|
|
||
| Use UUID to send messages to offline players: | ||
|
|
||
| ```java |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import statement for UUID in the offline player example. The example uses UUID.fromString() but doesn't import java.util.UUID.
| ```java | |
| ```java | |
| import java.util.UUID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in cec6f8f. Added the missing import for UUID.
| ```java | ||
| public void notifyPayment(UUID playerUUID, double amount) { | ||
| String message = String.format("You received $%.2f!", amount); | ||
| mailboxesAPI.sendPluginMessageToPlayer("EconomyPlugin", playerUUID, message); | ||
| } | ||
| ``` |
Copilot
AI
Jan 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing import statement for UUID in the payment notification example. The example uses UUID as a parameter type but doesn't include the necessary import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in cec6f8f. Added the missing import for UUID.
|
@copilot Address comments |
- Add JavaPlugin import to all examples that extend JavaPlugin - Add Listener interface and proper event handler structure to event examples - Clarify that item attachments are not available through plugin messaging API - Add getMessage(int ID) method documentation to M_Mailbox (method exists in source) - Improve getTrackedPlayerUUIDs() placeholder comment to clarify it's user-implemented - Update version comparison warning about string comparison limitations - Change HashMap to ConcurrentHashMap for thread safety in rate limiting example - Add UUID imports to QUICKSTART.md examples that use UUID - Use UUID variant in death event to avoid timing issues with respawning players Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
- Simplify UUID usage comment in death event example - Use professional tone in placeholder method comment (no all caps) Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Plugin Integration Documentation Expansion
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.