-
-
Notifications
You must be signed in to change notification settings - Fork 925
feat: add custom block registry for third-party plugin integration #5239
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: master
Are you sure you want to change the base?
Conversation
This adds support for custom block plugins like Oraxen and ItemsAdder
to integrate with mcMMO's skill system. Plugin developers can now
register their custom blocks to award XP when players break them.
New features:
1. CustomBlockRegistry - A registry where plugins can register their
custom blocks along with skill type and XP amount
2. McMMOCustomBlockBreakEvent - An event that fires when a registered
custom block is broken, allowing plugins to modify XP values
3. ExperienceAPI additions:
- registerCustomBlock(pluginName, blockId, skill, xp)
- unregisterCustomBlock(pluginName, blockId)
- unregisterAllCustomBlocks(pluginName)
- addXpFromCustomBlock(player, blockId, skill, xp)
Example usage for plugin developers:
// In your plugin's onEnable:
ExperienceAPI.registerCustomBlock("myplugin", "mythril_ore", "MINING", 150);
// In your plugin's onDisable:
ExperienceAPI.unregisterAllCustomBlocks("myplugin");
This is the mcMMO side of a two-part integration. A companion PR is being
submitted to Oraxen that uses these new APIs.
|
I'm not opposed to adding an API for an easy "it just works" experience for users of mcMMO and other plugins, however, I think config should be involved in this process. If a plugin is registering a custom block, it should make an entry into the relevant config and users should be able to override that entry (for example, setting the XP values to whatever they want). So, if a plugin were to register a custom block for a user, it should create relevant experience.yml values if it's the "first contact" of this custom block/etc. Perhaps experience related to custom things could simply go in its own config to keep things segregated, it doesn't really matter much, or rather I haven't given it sufficient thought. I haven't had time to sit and think about all the things in this PR, this is just my initial thoughts after skimming the files changed. I'm reminded of #5205 and #5205, it is likely the work related to those issues would also bring about support for custom blocks/entities/etc. |
- Create CustomBlocksConfig.java to manage custom-blocks.yml - Implements 'first contact' pattern: only creates entries for new blocks - Config values take priority over API-registered values - Allows server owners to customize XP or disable specific blocks - Add default custom-blocks.yml resource with documentation
- Load persisted custom blocks from config on startup - Respect user-configured XP values and skill types - Support disabling blocks via config (enabled: false) - Add reload() method for config reloading - Preserve user customizations across plugin updates
- Load CustomBlocksConfig and persisted blocks during plugin enable - Update ExperienceAPI documentation to explain config integration - Clarify that config values override API-registered values - Note that unregister only affects runtime, preserving config entries
Thanks for the feedback! I updated the pr to use a config-backed approach. You are right, that should be better.
The config is now the source of truth but the API stays simple for plugin developers. |
Summary
Hi!
I'm the maintainer of Oraxen and I propose this integration that would make it easier for custom block plugins to work with mcMMO.
This PR adds a new
CustomBlockRegistrythat allows plugins like Oraxen (but also others like ItemsAdder) to register their custom blocks so that players can earn mcMMO skill XP when breaking them.What's included:
How it works
Plugin developers can register their custom blocks in their onEnable:
And clean up in onDisable:
Why this matters
Currently, custom block plugins have no clean way to integrate with mcMMO. Players who use both Oraxen and mcMMO often ask why breaking custom ores doesn't give them Mining XP. This PR solves that problem!
Companion PR
I've also submitted a companion PR to Oraxen that uses these new APIs: oraxen/oraxen#1703
Backwards compatibility
This is purely additive and doesn't change any existing behavior. All existing blocks and XP handling continues to work exactly as before.
Test plan
Thanks for considering this! I'm happy to make any adjustments based on your feedback. Looking forward to better integration between our plugins!