API Reference
Complete reference for the SigmaToolsAPI interface.
SigmaToolsAPI Methodsโ
| Method | Returns | Description |
|---|---|---|
isSigmaTool(ItemStack item) | boolean | Checks if an item is a SigmaTool |
getToolType(ItemStack item) | Optional<String> | Tool type: "pickaxe", "axe", "bucket", "hoe"; empty if not a SigmaTool |
getToolId(ItemStack item) | Optional<String> | Tool ID (currently same as tool type) |
canUseHere(Player player, Location location) | boolean | Protection check - can the player use tools at this location |
getActiveCurrency() | String | "vault", "coins", or default currency if economy disabled |
getBalance(Player player) | EconomyResult | Player's economy balance |
deduct(Player player, double amount) | EconomyResult | Deducts currency; success()=false with message()="insufficient" if funds are short |
reward(Player player, double amount) | EconomyResult | Gives currency to a player |
getAvailableToolTypes() | Set<String> | ["pickaxe", "axe", "bucket", "hoe"] |
getToolConfig(String toolType) | Map<String, Object> | Tool's config section; empty map if toolType is invalid |
getVersion() | String | SigmaTools version, e.g. "1.0.3" |
Optional<String> toolType = api.getToolType(itemStack);
EconomyResult result = api.deduct(player, 10.0);
if (result.success()) {
double newBalance = result.balanceAfter();
} else {
String reason = result.message(); // "insufficient"
}
Map<String, Object> config = api.getToolConfig("pickaxe");
Integer maxCharges = (Integer) ((Map<String, Object>) config.get("cooldown")).get("max-charges");
EconomyResultโ
Immutable result object returned by all economy methods.
| Method | Returns | Description |
|---|---|---|
success() | boolean | Whether the operation succeeded |
amount() | double | Amount involved in the operation |
balanceBefore() | double | Balance before the operation |
balanceAfter() | double | Balance after the operation |
currency() | String | Currency used |
message() | String | "ok", "insufficient", "economy unavailable", or "failed" |
Error Handlingโ
- Null/invalid parameters return safe defaults (empty
Optional,false, empty map) - never throw. - Economy unavailable returns
EconomyResultwithsuccess() = false. - Plugin not loaded:
Bukkit.getServicesManager().load()returnsnull- always null-check before use.