Developer API & Addon Guide
Java 21 Developer API for Steal-A-Block. Access domain services, register calculation modifiers, write steal rules, add custom content, and listen to 26 events.
Steal-A-Block
$19.99Tycoon meets base raiding, with conveyor lines, block mutations, and Java + Bedrock support.
Steal-A-Block ships a standalone Java 21 API at dev.yowsef.stealablock.api. It exposes the plugin's gameplay systems to external plugins without reflection, NMS imports, or internal package access.
The core plugin is closed source. The public repository contains the API and an example addon. Addons compile against the stealablock-api artifact and run against the installed StealABlock jar, which bundles the API classes.
Browse the interactive Javadocs, or download the v1.3.2 JitPack Javadoc Archive.
1. Dependency setup
Add JitPack and the Paper repository. The API exposes Bukkit and Paper types, so paper-api is required for compilation. provided dependencies are not transitive.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.Yow-sef</groupId>
<artifactId>StealABlock-API</artifactId>
<version>v1.3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Local builds use dev.yowsef:stealablock-api:1.3.2 after mvn install. Replace the JitPack coordinates if you publish from a fork.
Plugin descriptor
name: MyStealAddon
version: 1.0.0
main: com.example.addon.MyStealAddon
api-version: '1.21'
depend:
- stealablock
Use the exact lowercase name stealablock. Paper's dependency resolver treats StealABlock as a different plugin and your addon will not load.
2. Obtaining the API
import dev.yowsef.stealablock.api.ApiVersion;
import dev.yowsef.stealablock.api.StealABlockAPI;
import dev.yowsef.stealablock.api.StealABlockProvider;
import org.bukkit.Bukkit;
StealABlockAPI api = StealABlockProvider.get(); // throws if the API is not loaded
StealABlockProvider.getIfAvailable().ifPresent(sab -> {}); // safe lookup
StealABlockAPI serviceApi = Bukkit.getServicesManager().load(StealABlockAPI.class);
ApiVersion version = api.getApiVersion();
if (version.isAtLeast(1, 3)) {
// v1.3 features are available
}
getApiVersion() reports the API contract. getPluginVersion() reports the installed plugin jar. Check isAtLeast(...) before calling a method added in a newer API, and use ApiVersion#isCompatibleWith when you require the same major version.
StealABlockProvider.get() throws IllegalStateException when the plugin is disabled or failed license verification. A plugin that declares depend: [stealablock] is enabled after StealABlock, so get() is safe in onEnable.
3. Addon lifecycle
Implement StealABlockAddon on your plugin main class, then register the addon in onEnable:
package com.example.addon;
import dev.yowsef.stealablock.api.StealABlockAPI;
import dev.yowsef.stealablock.api.StealABlockProvider;
import dev.yowsef.stealablock.api.addon.StealABlockAddon;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
public final class MyStealAddon extends JavaPlugin implements StealABlockAddon {
@Override
public void onEnable() {
StealABlockProvider.get().addons().register(this, this);
}
@Override
public void onApiReady(@NotNull StealABlockAPI api) {
getLogger().info("StealABlock API " + api.getApiVersion() + " is ready");
// Register modifiers, rules, events, mutations, placeholders...
}
@Override
public void onStealABlockReload(@NotNull StealABlockAPI api) {
// Re-read your own config after /sab reload
}
}
onApiReady runs once per addon. It is called immediately when the API is already loaded, which covers addons enabled after StealABlock and addons enabled later through a plugin manager. onStealABlockReload runs after /sab reload.
Every registration returns a Registration handle:
Registration registration = api.modifiers().register(this, ModifierType.INCOME, modifier);
registration.unregister(); // or registration.close()
Registrations are also removed automatically when the owning plugin disables. That cleanup covers modifiers, steal rules, mutations, game event types, gear abilities, milestone reward handlers, placeholders, and custom block providers.
If your addon can load without StealABlock, use the optional lookup:
StealABlockProvider.getIfAvailable().ifPresentOrElse(
api -> api.addons().register(this, this),
() -> getLogger().warning("StealABlock is not installed")
);
4. Modifier pipeline
Each ModifierType pipeline evaluates in four passes, in this order:
ADDadds to the base value.MULTIPLYmultiplies the running total.MINandMAXclamp the result.SEToverrides the result. The last activeSETwins.
priority() orders modifiers inside the same pass, not across passes. Lower values run earlier.
Wired pipeline types
ModifierType |
Base value | Applied to |
|---|---|---|
INCOME |
1.0 multiplier | Anvil income per second |
SELL_PRICE |
Block sell value | Stored-block sales |
STEAL_DURATION |
Seconds | Steal countdown (minimum 1 second) |
FUSION_SUCCESS |
0.0 to 1.0 chance | Real fusion roll and FusionOdds |
CONVEYOR_SPEED |
1.0 multiplier | Conveyor movement |
RARITY_WEIGHT |
Base spawn weight | Normal conveyor spawn selection |
REBIRTH_COST |
Money | Rebirth checks, GUI, Bedrock form, placeholders, execution |
PRESTIGE_COST |
Money | Prestige checks, GUI, Bedrock form, event payload, execution |
GEAR_PRICE |
Money | Gear shop price display and purchase |
Return the identity value to skip a modifier for one evaluation: 0.0 for ADD, 1.0 for MULTIPLY, or Double.NaN for any operation.
Modifier results must be finite. Non-finite values are ignored and logged. INCOME, SELL_PRICE, REBIRTH_COST, and PRESTIGE_COST are also clamped at zero.
Example: guild income boost
package com.example.addon.modifiers;
import dev.yowsef.stealablock.api.StealABlockAPI;
import dev.yowsef.stealablock.api.modifier.Modifier;
import dev.yowsef.stealablock.api.modifier.ModifierContext.StandardContext;
import dev.yowsef.stealablock.api.modifier.ModifierType;
import dev.yowsef.stealablock.api.modifier.Operation;
import net.kyori.adventure.key.Key;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
public final class GuildIncomeModifier {
public static void register(@NotNull Plugin plugin, @NotNull StealABlockAPI api) {
api.modifiers().register(plugin, ModifierType.INCOME, new Modifier<StandardContext>() {
@Override
public @NotNull Key key() {
return Key.key("myaddon", "guild_income_boost");
}
@Override
public int priority() {
return 100;
}
@Override
public @NotNull Operation operation() {
return Operation.MULTIPLY;
}
@Override
public double evaluate(@NotNull StandardContext ctx) {
return hasGuildPerk(ctx.playerId()) ? 1.5 : 1.0;
}
@Override
public @Nullable String displayTag(@NotNull StandardContext ctx) {
return hasGuildPerk(ctx.playerId()) ? "7FF55[1.5x GUILD]" : null;
}
});
}
private static boolean hasGuildPerk(UUID playerId) {
// Query your guild system
return false;
}
}
displayTag is optional. When the modifier contributes, the tag appears on rate holograms and in /sab api breakdowns.
Inspecting a breakdown
import dev.yowsef.stealablock.api.modifier.Breakdown;
import dev.yowsef.stealablock.api.modifier.ModifierType;
Breakdown breakdown = api.modifiers().evaluate(
ModifierType.INCOME,
StandardContext.ofPlayerSubject(100.0, player.getUniqueId(), "diamond_block")
);
double finalRate = breakdown.finalValue();
double multiplier = breakdown.totalMultiplier();
List<String> tags = breakdown.activeDisplayTags();
Breakdown exposes baseValue(), finalValue(), steps(), totalMultiplier(), and activeDisplayTags(). Every Step records the modifier key, owning plugin, operation, operand, and value after the step.
5. Steal rules
Rules run in priority order before a steal countdown starts. The first denial stops evaluation and returns its message to the thief.
import dev.yowsef.stealablock.api.steal.RuleVerdict;
import net.kyori.adventure.key.Key;
api.steals().registerRule(this, Key.key("myaddon", "pvp_truce"), 10, ctx -> {
if (areAllies(ctx.thief().getUniqueId(), ctx.victimId())) {
return RuleVerdict.deny("&#FF5555You cannot steal from a clan ally!");
}
return RuleVerdict.allow();
});
StealContext provides thief(), victimId(), targetBlock(), arenaId(), and plotNumber().
startSteal runs the rule arbiter. forceInstantSteal intentionally bypasses it.
6. Domain services
StealABlockAPI exposes 22 domain services:
| Accessor | Interface | Purpose |
|---|---|---|
api.players() |
PlayerService |
Profile snapshots, arena checks, Bedrock state, tutorial state |
api.money() |
MoneyService |
Atomic deposit, withdraw, and set-balance operations |
api.credits() |
CreditsService |
Atomic credit transactions |
api.boosts() |
BoostService |
Personal money boost and server luck |
api.blocks() |
BlockRegistry |
Block definitions, weighted rolls, item snapshots |
api.storage() |
StorageService |
Anvil blocks, sales, income collection, upgrades |
api.steals() |
StealService |
Active sessions, rules, start and cancel |
api.plots() |
PlotService |
Plot lookup, assignment, location checks |
api.gates() |
GateService |
Gate state and open, close, lock |
api.arenas() |
ArenaService |
Arena queries and validation |
api.conveyors() |
ConveyorService |
Conveyor control and moving blocks |
api.fusion() |
FusionService |
Eligibility, odds, and fusion start |
api.rebirth() |
RebirthService |
Levels, costs, multipliers, execution |
api.prestige() |
PrestigeService |
Requirements and execution |
api.milestones() |
MilestoneService |
Discoveries, claims, reward handlers |
api.contracts() |
ContractService |
Heist board state, progress, rerolls |
api.gameEvents() |
GameEventService |
Built-in and custom server events |
api.gear() |
GearService |
Catalog, grants, ability hooks |
api.cosmetics() |
CosmeticService |
Armor trims and name colors |
api.settings() |
SettingsService |
HUD and notification preferences |
api.leaderboards() |
LeaderboardService |
Sync getTop and async getTopAsync |
api.menus() |
MenuService |
Opens Java or Bedrock menus |
Money and credit changes go through api.money() and api.credits(). Core gameplay, Vault calls, and API calls all fire BalanceChangeEvent or CreditsChangeEvent when listeners are registered.
import dev.yowsef.stealablock.api.cause.Cause;
api.money().deposit(player.getUniqueId(), 250.0, Cause.plugin(this, "heist_bonus"));
Pass a Cause on every mutation so other plugins can identify the source plugin and reason in their listeners.
7. Events
All events extend StealABlockEvent and carry a Cause with type(), pluginName(), and detail().
Event catalog (26)
- Lifecycle:
StealABlockReadyEvent,StealABlockReloadEvent - Economy:
BalanceChangeEvent,CreditsChangeEvent - Storage:
BlockDepositEvent,BlockSellEvent,IncomeTickEvent,IncomeCollectEvent,MysteryBlockUnboxEvent - Conveyor:
ConveyorBlockSpawnEvent,ConveyorBlockClaimEvent - Steal:
StealAttemptEvent,StealCompleteEvent,StealCancelEvent - Fusion:
FusionStartEvent,FusionResultEvent - Progression:
PlayerRebirthEvent,PlayerPrestigeEvent,MilestoneClaimEvent,ContractProgressEvent - Plot and defense:
PlotAssignEvent,PlotUnassignEvent,GateToggleEvent,TrapDeployEvent - Server events:
GameEventStartEvent,GameEventEndEvent
Listener example
import dev.yowsef.stealablock.api.event.economy.BalanceChangeEvent;
import dev.yowsef.stealablock.api.event.gameevent.GameEventStartEvent;
import dev.yowsef.stealablock.api.event.steal.StealCompleteEvent;
import dev.yowsef.stealablock.api.event.storage.BlockDepositEvent;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public final class StealEventListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockDeposit(BlockDepositEvent event) {
Bukkit.getLogger().info(event.getOwnerId() + " deposited " + event.getBlockType().id());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onStealComplete(StealCompleteEvent event) {
Bukkit.getLogger().info(event.getThief().getName()
+ " stole " + event.getStolenBlock().id()
+ " from " + event.getVictimId());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBalanceChange(BalanceChangeEvent event) {
Bukkit.getLogger().info("Balance delta: " + event.getDelta());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onGameEventStart(GameEventStartEvent event) {
Bukkit.broadcastMessage("Server event started: " + event.getEventKey().asString());
}
}
Value validation
Financial setters on BlockSellEvent, IncomeTickEvent, IncomeCollectEvent, and BalanceChangeEvent reject non-finite or negative values with IllegalArgumentException. Duration setters clamp to at least one second. Bukkit isolates listener exceptions, but addon code should still avoid throwing.
8. Extension registries
Custom block providers
api.registerBlockProvider(this, new CustomBlockProvider() {
@Override
public @NotNull String providerId() {
return "oraxen";
}
@Override
public boolean isAvailable() {
return true;
}
@Override
public boolean isValidBlock(@NotNull String customId) {
return customId.startsWith("myblock_");
}
@Override
public @Nullable BlockData resolveBlockData(@NotNull String customId) {
return null;
}
@Override
public @Nullable ItemStack resolveItemStack(@NotNull String customId) {
return null;
}
});
Registering a provider triggers a block reload. In blocks.yml, set provider: oraxen and custom-id: <id>. The built-in VANILLA, ITEMSADDER, and NEXO providers remain available.
Custom mutations
api.mutations().register(this, new Mutation(
"cosmic",
"cosmic_",
"Cosmic",
"&#AA00AA",
20.0,
0.01,
4,
null
));
A custom tier is used by detect, BlockRegistry.base, BlockRegistry.mutated, and fusion chains. The built-in mystery-unbox and spawn-weight rules still use the normal, golden, diamond, and rainbow definitions, so a custom tier needs matching block entries in blocks.yml (for example cosmic_diamond_block) before it can spawn.
The ids normal, golden, diamond, and rainbow and the stealablock and minecraft key namespaces are reserved.
Custom game events
Key goldRush = Key.key("myaddon", "gold_rush");
api.gameEvents().registerEventType(this, new GameEventType(
goldRush,
"&#FFD700Gold Rush",
"&#FFAA00Golden blocks earn bonus cash!",
Material.GOLD_BLOCK,
180,
new GameEventType.LifecycleHandler() {
@Override
public void onStart(int durationSeconds) { }
@Override
public void onTick(int secondsRemaining) { }
@Override
public void onStop() { }
}
));
api.gameEvents().startEvent(goldRush, 180);
startEvent and stopActiveEvent drive the lifecycle callbacks, fire GameEventStartEvent and GameEventEndEvent, and report the correct time remaining. Custom and built-in events are mutually exclusive.
Use GameEventType.simple(...) when you do not need callbacks.
Gear abilities
api.gear().registerAbility(this, new GearService.GearAbility() {
@Override
public @NotNull Key key() {
return Key.key("myaddon", "blink_strike");
}
@Override
public void onUse(@NotNull Player player) {
// Right-click
}
@Override
public void onAttack(@NotNull Player attacker, @NotNull Player target) {
// Player-versus-player damage
}
});
Abilities are global hooks. They are not tied to a gear id, so check ownership in the handler if the ability belongs to a specific item.
Milestone reward handlers
api.milestones().registerRewardHandler(
this,
Key.key("myaddon", "cosmetic_crate"),
(player, milestoneId, argument) -> {
// Grant the reward
}
);
In milestones.yml:
reward-handler: myaddon:cosmetic_crate
reward-argument: some-value
Placeholders
api.placeholders().register(this, "myaddon_status", (player, params) -> {
return player == null ? "Offline" : "Online";
});
This exposes %stealablock_myaddon_status%. Built-in placeholder prefixes are reserved.
Custom contract types
Custom contract types are not part of v1.3. Use the built-in heist board types (STEAL, EARN, DEPOSIT, FUSE) and report progress with recordProgress:
api.contracts().recordProgress(player.getUniqueId(), "STEAL", 1);
9. Threading and errors
- Methods annotated
@MainThreadmust run on the primary server thread. They throwIllegalStateExceptionon any other thread. loadProfileAsyncschedules its snapshot on the primary thread and returns aCompletableFuture. It is safe to call from any thread.- Read-only snapshot records (
PlayerProfile,PlotView,StoredBlockView,ArenaView,BlockType, and similar) are defensive copies and can be read from any thread. - Registry registration is thread-safe, but register during
onEnableoronApiReadyon the main thread. - Exceptions from modifiers, rules, placeholders, gear abilities, milestone handlers, and game event callbacks are caught and logged. A broken modifier cannot take down income calculation.
10. Vault and /sab api
When Vault is installed and vault.provide-economy: true is set in config.yml, StealABlock registers VaultEconomyHook. Vault balance changes use the same atomic economy path and fire BalanceChangeEvent.
Run /sab api to inspect:
- API version and plugin version
- Vault bridge state
- Active addons
- Modifier, rule, mutation, game event, and placeholder counts
- Live rate breakdowns with modifier display tags
Was this page helpful?
Tell us what to fix, or ask in Discord.