API Reference
Complete reference for all SigmaTools API methods.
SigmaToolsAPI Interface
Tool Identification
boolean isSigmaTool(ItemStack item)
Checks if an item is a SigmaTool.
Parameters:
item- The item to check
Returns:
trueif the item is a SigmaToolfalseotherwise
Example:
if (api.isSigmaTool(itemStack)) {
// Item is a SigmaTool
}
Optional<String> getToolType(ItemStack item)
Gets the tool type of a SigmaTool item.
Parameters:
item- The SigmaTool item
Returns:
Optional<String>containing the tool type:"pickaxe","axe","bucket", or"hoe"Optional.empty()if the item is not a SigmaTool
Example:
Optional<String> toolType = api.getToolType(itemStack);
if (toolType.isPresent()) {
String type = toolType.get();
// type is "pickaxe", "axe", "bucket", or "hoe"
}
Optional<String> getToolId(ItemStack item)
Gets the tool ID of a SigmaTool item (currently same as tool type).
Parameters:
item- The SigmaTool item
Returns:
Optional<String>containing the tool IDOptional.empty()if the item is not a SigmaTool
Example:
Optional<String> toolId = api.getToolId(itemStack);
Usage and Protection
boolean canUseHere(Player player, Location location)
Checks if a player can use tools at a location (protection check).
Parameters:
player- The playerlocation- The location to check
Returns:
trueif the player can use tools at the locationfalseif protected or otherwise restricted
Example:
if (api.canUseHere(player, location)) {
// Player can use tools here
}
Economy
String getActiveCurrency()
Gets the active economy currency.
Returns:
"vault"if using Vault economy"coins"if using CoinsEngine- Default currency if economy is disabled
Example:
String currency = api.getActiveCurrency();
if (currency.equals("vault")) {
// Using Vault economy
}
EconomyResult getBalance(Player player)
Gets a player's economy balance.
Parameters:
player- The player
Returns:
EconomyResultwith balance information
Example:
EconomyResult result = api.getBalance(player);
if (result.success()) {
double balance = result.balanceAfter();
String currency = result.currency();
}
EconomyResult deduct(Player player, double amount)
Deducts currency from a player.
Parameters:
player- The playeramount- Amount to deduct
Returns:
EconomyResultindicating success or failure
Example:
EconomyResult result = api.deduct(player, 10.0);
if (result.success()) {
// Deduction successful
double newBalance = result.balanceAfter();
} else {
// Insufficient funds
String message = result.message(); // "insufficient"
}
EconomyResult reward(Player player, double amount)
Gives currency to a player.
Parameters:
player- The playeramount- Amount to give
Returns:
EconomyResultindicating success or failure
Example:
EconomyResult result = api.reward(player, 5.0);
if (result.success()) {
// Reward given
double newBalance = result.balanceAfter();
}
Introspection
Set<String> getAvailableToolTypes()
Gets all available tool types.
Returns:
Set<String>containing available tool types:["pickaxe", "axe", "bucket", "hoe"]
Example:
Set<String> toolTypes = api.getAvailableToolTypes();
for (String type : toolTypes) {
// Process each tool type
}
Map<String, Object> getToolConfig(String toolType)
Gets tool configuration.
Parameters:
toolType- Tool type:"pickaxe","axe","bucket", or"hoe"
Returns:
Map<String, Object>containing tool configuration- Empty map if tool type is invalid
Example:
Map<String, Object> config = api.getToolConfig("pickaxe");
Object enabled = config.get("enabled");
Map<String, Object> cooldown = (Map<String, Object>) config.get("cooldown");
Integer maxCharges = (Integer) cooldown.get("max-charges");
String getVersion()
Gets SigmaTools version.
Returns:
- Version string (e.g.,
"1.0.3")
Example:
String version = api.getVersion();
getLogger().info("SigmaTools version: " + version);
EconomyResult Class
Immutable result for economy operations.
Methods
boolean success()
Returns whether the operation was successful.
double amount()
Returns the amount involved in the operation.
double balanceBefore()
Returns the balance before the operation.
double balanceAfter()
Returns the balance after the operation.
String currency()
Returns the currency used.
String message()
Returns a message describing the result:
"ok"- Success"insufficient"- Insufficient funds"economy unavailable"- Economy plugin not available"failed"- Operation failed
Example
EconomyResult result = api.deduct(player, 10.0);
if (result.success()) {
getLogger().info("Deducted " + result.amount() + " " + result.currency());
getLogger().info("Balance: " + result.balanceBefore() + " -> " + result.balanceAfter());
} else {
getLogger().warning("Failed: " + result.message());
}
Error Handling
The API methods handle errors gracefully:
- Null parameters - Methods return safe defaults (empty Optional, false, etc.)
- Invalid tool types - Returns empty Optional or empty map
- Economy unavailable - Returns EconomyResult with
success() = false - Plugin not loaded -
Bukkit.getServicesManager().load()returnsnull
Always check for null API instances and handle Optional returns properly.
Next Steps
- API Overview - Getting started with the API
- Events Documentation - Event details
- Examples - Code examples