Skip to content

Registering a Stat

Aelithron edited this page Jun 1, 2025 · 6 revisions

For Server Owners

Server owners can open the stats.yml file in the plugin configuration directory and use one of the two provided methods.

1. Using PlaceholderAPI (Preferred)

This method requires that the PlaceholderAPI plugin is installed on your server. If so, add the following configuration:

balance: # Stat ID, pick any unique value.
  check: "online" # Determines what type of players to check, "all" or "online".
  source: "placeholderapi" # This tells AxionBridge to use a placeholder.
  placeholder: "%essentials_balance%" # What placeholder to pull the stat data from.

2. Direct Stat Registration

To do this method, make sure the developer of the plugin you want to pull from has registered a method with the AxionBridge API. If not, this method will fail! Once you have verified this, use the following configuration:

inventory: # Stat ID, pick any unique value.
  check: "online" # For checking inventories, this cannot be set to all.
  source: "registered" # This tells AxionBridge to use the internal registry.
  call: "Base:ExperienceLevels" # This is the registered method's ID, which should be provided by the plugin you want to pull from. "Base:ExperienceLevels" is a built-in method.

For Developers

As a plugin developer, you can simply integrate your plugin with AxionBridge in either of two ways.

1. PlaceholderAPI (Preferred)

Create a Placeholder Expansion using the steps from their docs. This will work with AxionBridge, no extra work needed!

2. Direct Registration

If you want to use this method, make sure to add AxionBridge as a dependency in your project. From there, extend the RegisteredStatProvider class and override the methods. An example on how to do this is provided below.

package com.example.exampleintegration;

import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import net.axionspire.axionbridge.RegisteredStatProvider;

public class IsOpStat extends RegisteredStatProvider {

    @Override
    public String pullStats(OfflinePlayer player) {
        return player.isOp() ? "Yes" : "No";
    }

    @Override
    public @NotNull String getMethodID() {
        return "PluginName:OpStatus";
    }
}

From there, call APIStatManager.getInstance().registerStatProvider(new IsOpStat()); from your main class's onEnable(), making sure to substitute IsOpStat() for the actual stat provider class. Also, note that the method ID cannot use "Base" before the colon, as that is a reserved namespace for stats built into AxionBridge.