Skip to main content

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:

  • true if the item is a SigmaTool
  • false otherwise

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 ID
  • Optional.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 player
  • location - The location to check

Returns:

  • true if the player can use tools at the location
  • false if 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:

  • EconomyResult with 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 player
  • amount - Amount to deduct

Returns:

  • EconomyResult indicating 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 player
  • amount - Amount to give

Returns:

  • EconomyResult indicating 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() returns null

Always check for null API instances and handle Optional returns properly.


Next Stepsโ€‹