Skip to content

Developing with Grand Economy

The_Fireplace edited this page Feb 27, 2022 · 2 revisions

Using the Entrypoint

To use currency from Grand Economy and/or register your own currency, you'll want to use the entrypoint.

  1. Create a class that implements GrandEconomyEntrypoint
  2. Add whatever logic you want to in your GrandEconomyEntrypoint's init function
  3. Add your entrypoint class to the grandeconomy entrypoint in your fabric.mod.json

Example entrypoint

"entrypoints": {
    "main": [
        ...
    ],
    "grandeconomy": [
        "your.package.YourEntrypointClass"
    ]
},

Adding an adapter for Grand Economy to read your mod's currency

  1. Create your entrypoint
  2. Create an adapter class which implements dev.the_fireplace.grandeconomy.api.interfaces.Economy. The names of the methods and parameters should be fairly self explanatory, but javadocs are present in case more explanation is needed.
  3. Within the entrypoint, call economyRegistry.registerEconomyHandler for your custom adapter.

Using currency from Grand Economy or its selected adapter

If you're looking to do this as a quick one-time solution, you can do DIContainer.get().getInstance(CurrencyAPI.class) to grab the currency API and use it for your needs. For a more in depth explanation of how the interfaces in the injectables API package work and how to properly use that throughout a mod, check out Fireplace Lib's API explanation.