Skip to content

R | Advanced Techniques, Gotchas & FAQ

Sartaj Singh edited this page May 31, 2025 · 2 revisions

R | Advanced Techniques, Gotchas & FAQ


Table of Contents


1. Advanced Techniques

1.1 Registering Content Dynamically

You can register items, foods, commands, and events at runtime, not just during plugin startup.
This is useful for:

  • Addons loading content after FXItems.
  • Reloadable packs.
  • Dynamic event- or time-based registration.

Example:

Registry registry = new RegistryAPI();
registry.registerItem("DYNAMIC_SWORD", new FXItemDefinition(...));

1.2 Using FXItems Utilities with Other Plugins

You can use the FXItems UtilsAPI in any plugin that depends on FXItems — you are not limited to FXItems' internal logic.

Example:

Utils utils = new UtilsAPI();
utils.setSize(player, 1.5f);

1.3 Custom Abilities & Behaviors

  • Implement custom ItemBehavior or FXFoodBehavior classes.
  • Register listeners for custom events (e.g., LegendaryItemCraftListener).
  • Access the registry and utility APIs from within your custom handlers.

1.4 Creating Addons

  • Add FXItems as a dependency in your own plugin.
  • Use both RegistryAPI and UtilsAPI to register content and use utilities.
  • See Q | FXItems API & Making Addons for full patterns.

1.5 Integrating with ModelEngine and EntitySize

  • FXItems will use ModelEngine for projectiles if useModelEngine = true and ModelEngine is present.
  • EntitySize features (like size changes) are only available if the EntitySize plugin is installed.
  • Always check for feature availability before calling size/model methods.

2. Common Gotchas & Troubleshooting

2.1 Registry Not Found / NullPointer

  • Don’t register items/foods/commands/events directly into static maps.
  • Always use the RegistryAPI.
  • Ensure registration occurs after FXItems has loaded.

2.2 Missing Dependencies

  • ModelEngine: Required for custom model projectiles. If missing, projectiles will fallback to standard entities or throw errors if explicitly requested.
  • EntitySize: Needed for resizing entities/players. If missing, size-related functions will be no-ops or log warnings.
  • PlaceholderAPI: Only needed for placeholder integration.

2.3 Permissions

  • Check plugin.yml for permissions like fxitems.nightvision, fxitems.op, and fxitems.utils.
  • Make sure your players/groups have the proper permissions for custom commands or utilities.

2.4 Addon Loading Order

  • If making an addon, set depend: [FXItems] or softdepend: [FXItems] in your plugin.yml.
  • Register your content in onEnable or after FXItems has initialized.

2.5 Custom Items Not Recognizing

  • Use the exact display name (with color codes) and material in isCustomItem.
  • Lore or metadata mismatches will cause custom item checks to fail.

2.6 Mana Not Regenerating

  • Call utils.initializeManaUtils(plugin) in your plugin or ensure FXItems has initialized mana tracking.
  • Mana only regenerates for players who have recently used mana.

2.7 Projectiles Not Working

  • If using ModelEngine, confirm it’s installed and enabled before calling ModelEngine projectile methods.
  • Ensure all parameters for createCustomProjectile are valid, especially modelId if useModelEngine is true.

2.8 One-Time Craft Not Working

  • Use OneTimeCraftUtils or the relevant API methods, not your own tracking.
  • Remember: one-time crafts are not persistent across server restarts unless you add your own persistence.

3. FAQ

Q: How do I add a new custom item?
A: Create an FXItemDefinition and register it via RegistryAPI.registerItem.

Q: How do I check if an ItemStack is a specific FXItem?
A: Use UtilsAPI.isCustomItem(item, material, displayName).

Q: Can I use FXItems utilities in another plugin?
A: Yes, as long as you depend on FXItems and instantiate UtilsAPI.

Q: Can I reload FXItems without restarting the server?
A: Use /fxreload to reload configuration, but for full registry reload, restart the server.

Q: Where are my items/foods/commands/events registered?
A: In your plugin’s onEnable, using the RegistryAPI or equivalent.

Q: How do I make an item/food/command only available once?
A: Use OneTimeCraftUtils or the relevant utility API methods.

Q: My custom ability isn’t triggering!
A: Check event registration, item checks, and that your class implements the right interfaces.

Q: How do I add support for PlaceholderAPI?
A: Use PlaceholderAPI’s registration methods and FXItems hooks, if available.


4. See Also


Clone this wiki locally