EternalCore - Developer API

EternalCore Developer API#

As part of open-source community, we support developers who want to create their own plugins using our API. We provide a simple and easy to use API that allows you to create your own plugins using our API.

📚 Dependency Management#

To use our work in your plugin, You need to install correct artifact for your project. Our plugin supports Maven, Gradle Kotlin, Gradle Groovy and SBT. To use latest release check maven repository.

Add repository:#

maven("https://repo.eternalcode.pl/releases")

Add dependency:#

compileOnly("com.eternalcode:eternalcore-api:1.1.0")

You must also add dependency inside plugin.yml or paper-plugin.yml file, this is required to load our plugin before your plugin, so they can access our API.

depend: [EternalCore]

Warning Remember to add dependency inside plugin.yml or paper-plugin.yml file, otherwise your plugin will not work!

📝 Usage#

To use our API you need to create instance of EternalCoreAPI class. You can do it by using EternalCoreApiProvider.provide() method.

EternalCoreAPI eternalCoreAPI = EternalCoreApiProvider.provide();

After creating instance of api, the User gets access to various classes used in our plugin and methods. Our API includes:

ClassProvide method
AfkServicegetAfkService()
SpawnServicegetSpawnService()
CatboyServicegetCatboyService()
TeleportServicegetTeleportService()
RandomTeleportServicegetRandomTeleportService()

AfkService usage examples#

The User can then use the methods of the given classes to create their own use cases. Here is an example how to obtain instance of AfkService:

public class YourPlugin extends JavaPlugin {

    private EternalCoreApi eternalCoreApi; // [!code focus]
    private AfkService afkService; // [!code focus]
    
    @Override
    public onEnable() {
        this.eternalCoreApi = EternalCoreProvider.provide(); // [!code focus]
        this.afkService = eternalCoreApi.getAfkService(); // [!code focus]
        
    }
}

Then pass down the AfkService to your classes. After that You can use examples shown below.

Check if the player is Afk by using AfkService Example:

if (afkService.isAfk(player.getUniqueId())) {
    // checks if the players is marked as afk
}

Mark the player as afk if the player is not afk yet.

if (!afkService.isAfk(player.getUniqueId())) {
    Afk afkPlayer = afkService.markAfk(player.getUniqueId(), AfkReason.PLUGIN);
    // marks player as afk and creates afk instance
}

CatboyService usage example#

The User can get other classes from EternalCore and use them in their own use cases. Here is an example how to obtain instance of CatboyService:

public class YourPlugin extends JavaPlugin {

    private EternalCoreApi eternalCoreApi; // [!code focus]
    private CatboyService catboyService; // [!code focus]
    
    @Override
    public onEnable() {
        this.eternalCoreApi = EternalCoreProvider.provide(); // [!code focus]
        this.catboyService = eternalCoreApi.getCatboyService(); // [!code focus]
        
    }
}

Using the instance of CatboyService the User is able to mark players as catboys and give them unique feature provided by EternalCore.

if (player.getName().equals("Rollczi")) {
    catboyService.markAsCatboy(player, Cat.Type.BLACK); // [!code focus]
}