Skip to content

Getting Started with the API

James Harrell edited this page Jan 13, 2021 · 7 revisions

Page Updated v0.0.1.

Getting started with ModuCore API

The API is really easy to learn, so I am first going to explain the general layout of everything.

The API is laid out as follows:

  • API
    • Manager
      • method()

In practice, this would look something like this:

  • ModuCoreAPI
    • PlayerManager
      • getName(UUID)

you would then do moduCoreApi.playerManager.getName(uuid).

Getting an Instance

The Bukkit Service Manager

This is the Preferred Way! To use this method, you would want something similar to the following code:

import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

public class MyPlugin extends JavaPlugin {

    private ModuCoreAPI moduCore;

    public ModuCoreAPI getModuCore() {
        return moduCore;
    }

    @Override
    public void onEnable() {
        RegisteredServiceProvider<ModuCoreAPI> rsp = getServer().getServicesManager().getRegistration(ModuCoreAPI.class);
        if (rsp != null) {
            moduCore = rsp.getProvider();
        }
    }
}

The Static Singleton

Now that you know how the API is laid out, you need to get an instance of the API. You can do this with ModuCoreAPI#getInstance().

Next Steps

From here, you are all set to start using the API. The next place you should go is the documentation found at docs.jaims.dev. If you have any questions, please join the discord below!

Clone this wiki locally