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 enhancedReading 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.
| Field | Type | Description |
|---|---|---|
recipe_id | String | Enhancement recipe ID |
current_star | Integer | Current star level |
crack_level | Integer | Crack level |
temper | Integer | Current temper level |
success_count | Integer | Total success count |
failure_count | Integer | Total failure count |
first_reach_flags | Map | First-reach flags for each star level |
last_attempt_at | Long | Timestamp of last enhancement attempt |
materials_signature | String | Material definition signature hash |