Creating expansions

Here you can view examples and details on how the expansion system works in Player Auctions.

In Player Auctions you can create expansions that will hook into the plugin to either add more functionality or to modify how the plugin works.

Registering Expansions

There are two types of ways how you can register the expansions, you can either have it external or internal.

External

Internal expansion is where you register the expansion in a plugin of your own. You can extend the necessary expansion type in a class and then using the ExpansionRegistry to register your expansion.

Here is an example to register your expansion internally, instance is your expansions' instance.

PlayerAuctionsAPI.getInstance().getExpansionRegistry().registerExpansion(instance);

Integrated

External expansions is where you can create a jar file that contains a class extending a necessary expansion type and the plugin will automatically find it as long as you put it into the expansions folder of the plugin. Make sure you do not have any constructors.

Examples

Here is an example of an expansion class, this is a plain expansion and will do nothing in functionality unless you program it to. If you wish to add actual functionality within the plugin that's already been programmed then you can look at next expansions type.

import com.olziedev.playerauctions.api.expansion.Expansion;

public class ExampleExpansion extends Expansion {

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public String getName() {
         return "Example Expansion";
    }

    @Override
    public void onLoad() {

    }
}

You will need to make sure that you provide an expansion name, this isn't really used much anywhere apart from just a unique identifier and used in console.

If isEnabled returns false then the onLoad method will not be called and the expansion will not be loaded into memory.

The expansion class actually contains a view public fields that you can use:

  • plugin - This is the instance of the PlayerAuctions plugin, this may be used to register events etc.

  • api - This is the API instance of Player Auctions.

  • registry - This is the Expansion Registry instance of Player Auctions.

  • expansionConfig - This is the expansion configuration that you can use to grab options from the expansions.yml.

  • config - This is the main configuration that you can also use to grab options from the config.yml

Last updated