Skip to content

API & Integration

EmakiStrengthenApi

EmakiStrengthen exposes its API through Bukkit's ServicesManager, allowing other plugins to read and manipulate item enhancement states.

Getting the API Instance

java
RegisteredServiceProvider<EmakiStrengthenApi> provider =
    Bukkit.getServicesManager().getRegistration(EmakiStrengthenApi.class);

if (provider != null) {
    EmakiStrengthenApi api = provider.getProvider();
    // Use the API...
}

Tip

The API is registered during EmakiStrengthen's onEnable phase. If your plugin depends on this API, declare softdepend: [EmakiStrengthen] in your plugin.yml to ensure correct load order.

Reading Enhancement State

java
// Read the enhancement state of an item
StrengthenState state = api.readState(itemStack);

int currentStar = state.currentStar();       // Current star level
int temper = state.temperLevel();             // Temper level
int successCount = state.successCount();      // Total success count
int failureCount = state.failureCount();      // Total failure count
String recipeId = state.recipeId();           // Recipe ID used
boolean eligible = state.eligible();          // Whether the item can be enhanced

Reading Raw Data via PdcService

If you need to read raw audit data directly from PDC:

java
PdcService pdcService = EmakiServiceRegistry.get(PdcService.class);
Map<String, Object> auditMap = pdcService.readAuditMap(itemStack, "strengthen");

int currentStar = (int) auditMap.getOrDefault("current_star", 0);
int temper = (int) auditMap.getOrDefault("temper", 0);

PDC Data Structure

Enhancement data is stored on the item via PDC (PersistentDataContainer). Data travels with the item and does not depend on external databases.

FieldTypeDescription
recipe_idStringEnhancement recipe ID
current_starIntegerCurrent star level
crack_levelIntegerCrack level
temperIntegerCurrent temper level
success_countIntegerTotal success count
failure_countIntegerTotal failure count
first_reach_flagsMapFirst-reach flags for each star level
last_attempt_atLongTimestamp of last enhancement attempt
materials_signatureStringMaterial definition signature hash

Released under the GPL-3.0 License