Developer API
On this page(33)
SnDungeons exposes a public developer API for other plugins. It offers custom Bukkit events, a
query and write service with one sub-facade per feature, and extension points. The extension
points shape the values the game decides. The API lives in the com.sn.dungeons.api package
inside the plugin jar. There is no separate artifact.
Only com.sn.dungeons.api is a stable, kept contract. Everything else in the jar is obfuscated
and internal. Do not call it.
Getting the jar
-
Download the latest release jar.
-
Install it into your local Maven repository:
mvn install:install-file -Dfile=SnDungeons-<version>.jar -DgroupId=com.sn \ -DartifactId=SnDungeons -Dversion=<version> -Dpackaging=jar -
Depend on it with
providedscope. Never shade it.
<dependency>
<groupId>com.sn</groupId>
<artifactId>SnDungeons</artifactId>
<version><!-- the version you installed --></version>
<scope>provided</scope>
</dependency>Quick start
Declare the dependency in your plugin.yml:
depend: [SnDungeons] # or softdepend if optionalResolve the API when you need it:
import com.sn.dungeons.api.SnDungeonsAPI;
import com.sn.dungeons.api.SnDungeonsProvider;
SnDungeonsAPI api = SnDungeonsProvider.get();
if (api != null) {
api.economy().balance(player.getUniqueId(), "coins")
.ifPresent(balance -> player.sendMessage("Coins: " + api.economy().format("coins", balance)));
}SnDungeons registers the facade with the Bukkit services manager at the end of its enable.
SnDungeonsProvider.get() returns null before that, and while SnDungeons disables or is
disabled. SnDungeonsProvider.isAvailable() is a boolean shortcut for the same check.
Resolve the reference when you need it. Do not cache it across a SnDungeons reload.
The provider class ships inside the SnDungeons jar. With softdepend, check
Bukkit.getPluginManager().isPluginEnabled("SnDungeons") before you touch any SnDungeons class.
Amounts of currency are com.sn.dungeons.api.number.BigNum values. Build one with
BigNum.of(double) or BigNum.parse(String). Most writes take a short cause, logged as
api:<cause> in the transaction log.
Run /dungeons admin api in game to list every sub-facade, read its methods and call them live.
It is the fastest way to explore the surface below.
Master switch
API events can be disabled by the server owner with api-events.enabled: false in
config.yml. It is re-read on /dungeons reload, and eventsEnabled() tells you its current
value. While it is false no event fires, and cancellable events behave as if nobody cancelled
them. The query service and the extension point stay available either way.
Events
All events live in com.sn.dungeons.api.event. They extend org.bukkit.event.Event, carry the
usual static getHandlerList() and always fire on the main thread. SnDungeons builds an event
only while a listener for it exists, so an event nobody listens to costs nothing.
Cancellable events fire before the action. Cancelling aborts it. SnDungeons sends no message of its own for a cancelled action: your plugin tells the player.
| Event | Fired when | Cancel effect |
|---|---|---|
AfkCloneHitEvent | A clone of an afk player is about to hit one of the player's zone mobs | This hit does not happen |
AfkStartEvent | A player is about to go afk | The player stays without clones |
AfkUpgradeEvent | A player is about to buy levels of an afk upgrade | Nothing is bought and nothing is charged |
AnticheatActionEvent | Before the action lines of a crossed anticheat threshold run | Those lines do not run |
AnticheatFlagEvent | The anticheat module is about to count a failed check of a player | The flag is not counted, stored or alerted |
ArmorExpGainEvent | One counted swing is about to add armor experience to a player | This swing adds none |
ArmorLevelUpEvent | A player's armor experience filled their level and the armor level is about to go up | The level stays until the next gain tries again |
ArmorSetBoostEvent | A Set Multi Boost or Skin Multi Boost of a player is about to start | It does not start |
ArmorSkinSelectEvent | The armor skin a player has selected is about to change | The selection stays |
ArmorSkinUnlockEvent | An armor skin is about to be unlocked for a player | It is not unlocked and a redeemed item stays in the player's hand |
ArmorUpgradePurchaseEvent | A player is about to buy levels of an armor upgrade | Nothing is bought |
ArmorVisualEvent | A viewer is about to start seeing a player's armor set (once per viewer) | That viewer sees the player's real armor |
AttributeResolveEvent | A player's sword attributes were resolved, before their boosters are pushed | The attribute level and boosters stay as they were |
AuraEquipEvent | A player is about to equip an aura in a free slot or take one off | Nothing changes |
AuraMilestoneEvent | A player reaches an aura milestone, before any aura rolls | Nothing happens (the counter stays, so the next counted swing asks again) |
AuraStepEvent | An equipped aura won its milestone roll and is about to step up | That aura stays where it is (the other auras of the milestone still roll) |
AuraSwingProgressEvent | One swing is about to count toward a player's aura milestone | This swing does not count toward the next milestone |
AuraUpgradePurchaseEvent | A player is about to buy levels of an aura upgrade | Nothing is bought |
AutoPurchaseEvent | An automatic purchase a player switched on in /settings is about to run | This automatic purchase does not run now |
AutofighterModeEvent | A player is about to change the target mode of their autofighter | The mode stays |
AutofighterStartEvent | A player is about to spawn their autofighter | The autofighter does not start |
AutofighterTargetEvent | A player's autofighter is about to pick the zone mob it walks to and fights next | That mob is skipped; the next one in order is offered |
AutofighterTimeConsumeEvent | Every second an autofighter runs, before that second is charged | That second costs nothing |
AutofighterUpgradePurchaseEvent | A player is about to buy levels of an autofighter upgrade | Nothing is bought |
BackpackActivateEvent | A booster of a player's booster backpack is about to start | That type does not start |
BackpackDeactivateEvent | The running (or paused) backpack booster of a type is about to be ended by hand | The booster keeps running |
BackpackWithdrawEvent | Time is about to leave a backpack entry to become a booster item | Nothing is taken |
BoosterAddEvent | A booster is about to be given to a player, whatever gives it | The booster is not added (an API future completes false) |
BoosterRedeemEvent | Boosters are about to be stored in a player's booster backpack, whatever stores them | Nothing is stored (an item goes back to the player) |
CompanionEggChargeEvent | A player is about to pay for companion eggs of SnDungeons | Nothing is charged and nothing hatches |
CompanionUpgradeEvent | A player is about to buy levels of a companion chance upgrade | Nothing is bought and nothing is charged |
ContestCatchEvent | A player is about to catch one of their contest targets with their own click | The click does nothing; the target stays alive |
ContestCheckFailEvent | A player's click on one of their contest targets failed a check | The click counts as a normal catch and no alert is sent |
ContestStartEvent | A contest is about to start | No contest starts; a scheduled one is skipped |
ContestTargetSpawnEvent | A target of a contest is about to appear for a player | This target never appears |
CookieConsumeEvent | A player is about to eat a cookie item | The item stays in the hand and nothing changes |
CrystalApplyEvent | A player is about to apply a storage crystal to their sword | Nothing is rolled and the crystal stays in the storage |
CrystalBoxOpenEvent | A player opens a Crystal Box, after its crystal was rolled | That box is not used up and its crystal is not added |
CrystalDepositEvent | A player is about to store the crystal item they hold | The item stays in the player's hand |
CrystalFilterEvent | A player is about to filter a crystal type, or stop filtering it | The filter stays as it was |
CrystalRemoveEvent | A crystal is about to be destroyed: taken off the sword or deleted from storage | The crystal stays where it is |
CrystalWithdrawEvent | A player is about to take a storage crystal out as an item | The crystal stays in storage and no item is given |
EnchantActivateEvent | A sword enchant is about to proc for a player | The enchant does not proc: no cooldown, no actions |
EnchantPrestigeEvent | A player is about to prestige a sword enchant | The enchant keeps its level and stars and nothing is paid |
EnchantPurchaseEvent | A player is about to buy levels of a sword enchant (the enchants menus) | Nothing is bought |
GlobalBoostStartEvent | A global boost is about to start: a global event or a global booster item | It does not start; a global item stays in the hand |
GrindSummaryEvent | A player is about to receive the grind summary | This summary is not sent |
HeroEffectEvent | A Hero Enchant or a special upgrade of a hero is about to trigger | The effect does nothing this time |
HeroEnchantUpgradeEvent | A player is about to buy levels of a Hero Enchant | Nothing is bought |
HeroHitEvent | A player's hero is about to hit one of their zone mobs | That attack does nothing (no damage, no pay, no proc) |
HeroSleepEvent | A player's hero is about to fall asleep (health at 0, or stored from the menu) | The hero keeps fighting |
HeroSummonEvent | A player's hero is about to be summoned | The hero stays asleep |
HeroUpgradeEvent | A player is about to buy levels of an upgrade of one of their heroes | Nothing is bought |
HuntAssignEvent | A hunt is about to be assigned to a slot | The slot stays empty until the next window |
HuntBonusClaimEvent | The bonus of a window is about to be stored and paid | Nothing is stored or given |
HuntClaimEvent | A hunt claim is about to be stored and paid | Nothing is stored or given |
HuntProgressEvent | Progress is about to be added to a hunt | Nothing is added |
HuntRerollEvent | A hunt reroll is about to be bought | Nothing is charged or changed |
LevelGainEvent | A player is about to go up in a leveling track | The level stays |
LevelingPointsEvent | A real level-up of a leveling track with upgrades is about to give its points | The level-up gives no points (the level-up itself stays) |
LevelingUpgradeEvent | A player buys levels of a leveling upgrade with the track's points | Nothing is bought |
LuckProcEvent | A luck effect procced for a player, before the game applies it | The effect does not apply |
MilestoneClaimEvent | A player claims a milestone | The milestone stays claimable and nothing is given |
MilestoneReachEvent | A player reaches the requirement of a milestone during play | The chat lines, sound and title of that milestone are silenced |
MilestoneReminderEvent | The periodic reminder of unclaimed milestones is about to reach a player | That one reminder is skipped |
PerkBroadcastEvent | A perk roll is about to be announced to the online players | No one is told |
PerkChangeEvent | A player's perk is about to be set or cleared by something other than a roll | The perk stays as it is |
PerkConfirmEvent | A player's confirmation of a perk is about to change | The confirmation stays as it is |
PerkRollEvent | A player rolls a sword perk | Nothing happens (a Roll Max chain stops) |
PerkRollMaxStartEvent | A Roll Max chain is about to start | No roll at all |
PerkTicketPurchaseEvent | A player buys perk tickets with a button of the Tool Perks menu | Nothing is bought |
PouchOpenEvent | A player opens currency pouches | No pouch leaves the inventory and no currency is given |
SettingSelectEvent | A player is about to change one of their own settings in /settings | That setting keeps its value |
ShopPurchaseEvent | A player buys an entry of a currency shop | Nothing is bought |
StagePurchaseEvent | A player is about to buy the next stage of the zones | This stage is not bought |
SwordPurchaseEvent | A player is about to buy the next sword tier | This tier is not bought |
SwordSwingEvent | The zone mob fight is about to make one automatic swing of a player's sword at their target | This swing does not hit, rolls no enchant and does not count as a swing |
TotemAddEvent | A totem is about to join a player's totem storage | The totem is not added (a box or an item is not used up) |
TotemEquipEvent | A player equips a totem in a slot, or takes one back to storage | The totem stays where it is |
TotemFilterEvent | A player is about to filter a totem type, or stop filtering it | The filter stays as it was |
TotemMergeEvent | For each merge of a player's storage totems | That merge is cancelled; Merge All goes on without it |
TotemRemoveEvent | A totem is about to leave a player's storage | The totem stays |
TotemSkinEvent | A player's totem skins are about to change: added, applied, taken off, deleted or withdrawn | Nothing changes |
TotemUpgradeEvent | A player buys levels of a totem upgrade | Nothing is bought |
VisibilitySelectEvent | A player is about to change their zone visibility mode (the visibility menu) | The mode stays |
ZoneMobHitEvent | A zone mob of a player is about to take a hit, whatever its source | The hit does nothing (no damage, no stats, no hologram, no death) |
ZoneMobTargetEvent | A player's click is about to make a zone mob their fight target | The fight stays as it was |
ZoneTeleportEvent | A player is about to be teleported to the spawn of a zone stage | The player is not moved (and the stage they stand at does not change) |
ZoneVisitEvent | A player is about to visit another player's fight (/zone visit or /zone spectate) | No visit starts (the visitor is not moved, their own fight goes on) |
Notification events fire after the fact. They cannot be cancelled.
| Event | Fired when | Thread |
|---|---|---|
AfkStopEvent | After a player's afk ended | Main |
AfkUpgradedEvent | After a player bought levels of an afk upgrade | Main |
AnticheatViolationEvent | After the anticheat module counted a failed check of a player | Main |
ArmorSetUnlockEvent | After a player's armor level reached a new armor set, which they wear now | Main |
AttributeLevelChangeEvent | After the sword attribute level of a player changed | Main |
AuraEquipChangeEvent | After a player equipped an aura or took one off | Main |
AuraMilestoneReachedEvent | After an aura milestone of a player ran | Main |
AuraStepChangeEvent | After one of a player's auras stepped up at an aura milestone | Main |
AuraUpgradeEvent | After a player bought levels of an aura upgrade and their price was taken | Main |
AutofighterStopEvent | After a player's autofighter stood down | Main |
AutofighterUpgradeEvent | After a player bought levels of an autofighter upgrade and their price was taken | Main |
BackpackChangeEvent | After a player's booster backpack changed and the change was stored | Main |
BoostChangeEvent | After SnDungeons stored the new booster total of one target of an online player | Main |
CompanionEggOpenedEvent | After companion eggs of SnDungeons were really opened through SnCompanions | Main |
CompanionUpgradedEvent | After a player bought levels of a companion chance upgrade | Main |
ContestEndEvent | A contest ends, before the top is announced and the rewards are stored | Main |
ContestRecordEvent | After a contest set a new record of its variant | Main |
CookieExpireEvent | After a player's active cookie ended | Main |
CrystalAppliedEvent | After a player's apply roll was written: applied, or failed and destroyed | Main |
CurrencyChangeEvent | After a SnDungeons balance changed | Main |
EnchantPrestigeChangeEvent | After the prestige stars of a player's sword enchant changed | Main |
EnchantProcEvent | A sword enchant procs for a player | Main |
EnchantUpgradeEvent | After a player bought levels of a sword enchant | Main |
GlobalBoostEndEvent | After a global boost of the server ended | Main |
HeroEnchantUpgradedEvent | After a player bought levels of a Hero Enchant | Main |
HeroSleptEvent | After a player's hero fell asleep and despawned, whatever the reason | Main |
HeroUpgradedEvent | After a player bought levels of an upgrade of one of their heroes | Main |
HuntBonusClaimedEvent | After the bonus of a window was stored and its rewards ran | Main |
HuntClaimedEvent | After a hunt claim was stored and its rewards ran | Main |
HuntCompleteEvent | After a hunt reached its target and was marked completed on the loaded player | Main |
LevelUnlockEvent | After a level-up reached levels listed in the track's unlocks: block | Main |
LevelUpEvent | After a player's level in a SnDungeons leveling track went UP | Main |
LevelingUpgradedEvent | After a player bought levels of a leveling upgrade | Main |
MilestoneClaimedEvent | After a claimed milestone was stored and its rewards ran | Main |
ModuleDisabledEvent | After a SnDungeons module disabled | Main |
ModuleEnabledEvent | After a SnDungeons module enabled | Main |
PerkRollMaxEndEvent | Once when a Roll Max chain ended, whatever the reason, with its summary | Main |
PerkRolledEvent | After a player rolled a sword perk | Main |
PlayerDataLoadedEvent | The SnDungeons data of a player is loaded after they joined | Main |
PouchOpenedEvent | After opened currency pouches paid the player | Main |
SettingChangeEvent | After the value a player uses for a per-player setting changed | Main |
ShopPurchasedEvent | After a player bought an entry of a currency shop | Main |
StageUnlockEvent | After a player bought a stage of a SnDungeons zone | Main |
SwordUpgradeEvent | After a player bought a tier of their SnDungeons sword | Main |
TotemLevelUpEvent | After an equipped totem gained one or more levels from its owner's kills | Main |
TotemMergedEvent | After a merge or a Merge All of a player's storage totems was written | Main |
VisibilityChangeEvent | After a player chose another visibility mode for the isolated zone worlds | Main |
ZoneMobKillEvent | One of a player's zone mobs died | Main |
ZoneVisitEndEvent | After a zone visit or spectate ended | Main |
Listen like any Bukkit event:
@EventHandler
public void on(StagePurchaseEvent event) {
// read the payload; cancellable events support event.setCancelled(true)
}Event payloads are read-only. To influence values, use the extension points below instead of looking for setters.
Query service
The facade SnDungeonsAPI answers module and player questions directly, and hands out one
sub-facade per feature. Every sub-facade lives in its own package, such as
com.sn.dungeons.api.zones for zones().
Synchronous methods read in-memory state. Call them on the main thread: most sub-facades throw
IllegalStateException on any other thread. A player read answers empty until that player's
data is loaded after the join (isPlayerLoaded, PlayerDataLoadedEvent).
Asynchronous methods return CompletableFuture. Most writes are asynchronous. The javadoc of
each write says which events it fires.
SnDungeons futures complete on the main thread once the change is stored. Consume them with
thenAccept(...). A join() or get() of a pending future on the main thread throws
IllegalStateException, because waiting there would freeze the server.
Most features belong to a module that the server owner can switch off. While a module is
disabled, its sub-facade stays reachable: reads answer empty, and writes complete with false
or fail.
Facade
SnDungeonsAPI, from SnDungeonsProvider.get(). Each getter returns a sub-facade, never null.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
getModules() | List<ModuleView> | Every module SnDungeons knows, enabled or not, in enable order |
getModule(id) | Optional<ModuleView> | One module by its id |
isModuleEnabled(id) | boolean | True when the module exists and its last enable completed |
isPlayerLoaded(player) | boolean | True while the player's SnDungeons data is loaded after the join |
eventsEnabled() | boolean | The value of api-events.enabled |
economy() | Economy | Currencies: balances, changes, formatting, pouches and shops |
leveling() | Leveling | Leveling tracks: levels, unlocks and leveling upgrades |
zones() | Zones | Zones and stages, player progress, visibility mode and visits (module zones) |
sword() | Sword | Sword tiers, enchants, prestige, momentum and cooldowns (module sword) |
boosters() | Boosters | Boost totals, named boosters, the backpack and global boosts |
modifiers() | Modifiers | The registry of DungeonsModifier extensions |
stats() | Stats | Stat counters: swings, damage, kills, earnings and peak levels |
settings() | Settings | Per-player settings of /settings, and settings of other plugins |
perks() | Perks | Sword perks, pity, confirmations and rolls (module perks) |
auras() | Auras | Auras, equipped slots, milestone progress and upgrades (module auras) |
milestones() | Milestones | Milestone categories, player states and claims (module milestones) |
totems() | Totems | Totems, skins, slots, upgrades and filters (module totems) |
attributes() | Attributes | The sword attribute ladder and player levels (module attributes) |
crystals() | Crystals | Crystals, slots, boxes and filters (module crystals) |
armors() | Armors | Armor level, experience, sets, skins and upgrades (module armors) |
autofighter() | Autofighter | Autofighter time, daily limit, target mode and upgrades (module autofighter) |
afk() | Afk | Afk state, clones, upgrades and session earnings (module afk) |
heroes() | Heroes | Heroes, their state, health, upgrades and Hero Enchants (module heroes) |
contests() | Contests | The running contest, ranking, schedule and records (module contests) |
companions() | Companions | Companion content for SnCompanions and chance upgrades (module companions) |
objectives() | Objectives | The objective bus: types, subscriptions and custom progress |
hunts() | Hunts | Hunt slots, rerolls, bonus state and pool (module hunts) |
luck() | Luck | Luck points, luck effects, their chances and plugin bonuses |
cookies() | Cookies | Active cookies and cookie types (module cookies) |
anticheat() | Anticheat | Violation levels, stored flags and staff alerts (module anticheat) |
getApiVersion() | String | Semantic version of the API contract, independent of the plugin version |
Economy
economy() reads and changes the owner-defined currencies, online or offline. Its nested pouches() and shops() reach the currency pouches and shops. Every balance change fires CurrencyChangeEvent.
Economy
Synchronous:
| Method | Returns | Notes |
|---|---|---|
currencies() | Collection<String> | The ids of the currencies defined right now, in file name order |
currency(currency) | Optional<CurrencyView> | One currency by its id |
format(currency, amount) | String | Writes an amount with the owner's suffix ladder (1.5K, 2.2e40) |
balance(player, currency) | Optional<BigNum> | The balance of a loaded player |
has(player, currency, amount) | boolean | Whether a loaded player holds at least an amount |
pouches() | Pouches | The currency pouches: items that give a random amount when opened |
shops() | Shops | The currency shops: entries, rotation and purchases |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
give(player, currency, amount, cause) | CompletableFuture<BigNum> | Adds an amount, up to the currency's max-value |
take(player, currency, amount, cause) | CompletableFuture<BigNum> | Removes an amount, stopping at zero |
set(player, currency, amount, cause) | CompletableFuture<BigNum> | Sets the balance, kept between zero and the currency's max-value |
reset(player, currency, cause) | CompletableFuture<BigNum> | Sets the balance back to the currency's starting value |
Pouches
Synchronous:
| Method | Returns | Notes |
|---|---|---|
ids(currency) | List<String> | The pouch ids of a currency, in file order |
pouch(currency, pouch) | Optional<PouchView> | One pouch |
itemStack(currency, pouch, amount) | ItemStack | Builds pouch items, as an admin give makes them |
give(player, currency, pouch, amount) | boolean | Gives pouch items to an online player, in stacks of 64 |
Shops
Synchronous:
| Method | Returns | Notes |
|---|---|---|
ids() | Collection<String> | The ids of the shops |
entries(shop) | List<ShopEntryView> | What a shop sells now |
pool(shop) | List<ShopEntryView> | Every entry of a shop's rotating pool, offered now or not |
rotation(shop) | List<String> | The pool entries the current window offers, in rotating slot order |
window(shop) | OptionalLong | The number of the current rotation window, or empty for an unknown shop |
rotatesIn(shop) | OptionalLong | The milliseconds before the shop rotates, or empty for an unknown shop |
purchased(player, shop, entry) | OptionalInt | The units a player bought of an entry in the current window |
price(player, shop, entry) | Optional<BigNum> | The price of the next unit of an entry for a player |
open(player, shop) | boolean | Opens a shop's menu for an online player |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
buy(player, shop, entry, amount, cause) | CompletableFuture<Integer> | Buys units of an entry for a loaded player, in their order |
Leveling
leveling() reads and changes the levels of the owner-defined leveling tracks. Its nested upgrades() reaches the upgrades each track sells for its points.
Leveling
Synchronous:
| Method | Returns | Notes |
|---|---|---|
trackIds() | Collection<String> | The ids of the tracks defined right now, in file name order |
track(id) | Optional<LevelingTrackView> | One track by its id |
costLeveling(track) | Optional<String> | The track whose level pays this track, for a cost of type level (a rebirth) |
level(player, track) | OptionalInt | The level of a loaded player |
unlocks(track) | List<LevelUnlockView> | What the levels of a track unlock, from its unlocks: block |
nextUnlock(player, track) | Optional<LevelUnlockView> | The next level above a loaded player's level that unlocks something |
upgrades() | LevelingUpgrades | The leveling upgrades bought with the points of a track |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
set(player, track, level, cause) | CompletableFuture<Integer> | Sets a player's level, kept between the track's starting level and its max level |
add(player, track, levels, cause) | CompletableFuture<Integer> | Adds levels, or removes them with a negative count |
LevelingUpgrades
Synchronous:
| Method | Returns | Notes |
|---|---|---|
trackIds() | Collection<String> | The ids of the tracks with upgrades read now, immutable |
enabled(track) | boolean | True when the track has upgrades read now |
pointsCurrency(track) | Optional<String> | The id of the currency that is the track's points |
ids(track) | Collection<String> | The upgrade ids of the track in slot order, immutable |
upgrade(track, upgrade) | Optional<LevelingUpgradeView> | The upgrade, empty when the track does not have it |
level(player, track, upgrade) | OptionalInt | The player's level of the upgrade |
value(player, track, upgrade) | OptionalDouble | The bonus the upgrade's booster gives the player now |
refresh(player) | boolean | Pushes a loaded player's upgrade boosters again after your modifier changed |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
set(player, track, upgrade, level, cause) | CompletableFuture<Integer> | Sets a player's level of an upgrade, kept between 0 and its max level |
buy(player, track, upgrade, amount, cause) | CompletableFuture<UpgradeBuyResult> | Buys up to amount levels of an upgrade for an online player |
buyMax(player, track, upgrade, cause) | CompletableFuture<UpgradeBuyResult> | Buys as many levels of an upgrade as an online player's points pay |
Zones
zones() belongs to the zones module. It reads the zones, their stages and each player's progress, visibility mode and visits.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
zones() | List<ZoneView> | The zones loaded right now, in progression order |
zone(id) | Optional<ZoneView> | One zone by its id |
progress(player) | Optional<ZoneProgressView> | The progress of a loaded player |
standing(player) | Optional<ZoneProgressView> | The stage a loaded player stands at, never above their progress |
visibilityMode(player) | Optional<VisibilityMode> | The visibility mode a loaded player chose for the isolated zone worlds |
visiting(player) | Optional<UUID> | The player whose fight this player visits right now |
visitors(player) | Set<UUID> | The players who visit a player's fight right now, spectators included |
spectating(player) | boolean | Whether the visit is a spectate (/zone spectate) |
stageModel(zone, stage) | Optional<String> | The model id the mob of a stage shows instead of its vanilla look |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
unlockNext(player, cause) | CompletableFuture<Boolean> | Buys the next stage like /zone buy, charging its price |
setProgress(player, zone, stage, cause) | CompletableFuture<Void> | Sets a player's progress to one stage of a loaded zone |
Sword
sword() belongs to the sword module. It reads the tiers and enchants, and changes enchant levels, prestige, momentum and cooldowns.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
tiers() | List<SwordTierView> | The tiers loaded right now, in tier number order |
tier(number) | Optional<SwordTierView> | One tier by its number |
tier(player) | OptionalInt | The tier of a loaded player |
multiplier(player) | OptionalDouble | The damage multiplier of a loaded player |
swingsPerSecond(player) | OptionalDouble | The swings per second of a loaded player's sword on zone mobs |
enchants() | List<EnchantView> | The enchants loaded right now, by id |
enchant(id) | Optional<EnchantView> | One enchant by its id |
enchantLevel(player, enchantId) | OptionalInt | A loaded player's level in an enchant (0 without it) |
swingDamage(player) | OptionalDouble | The damage of one swing, before the modifiers and mob debuffs |
enchantPrestige(player, enchantId) | OptionalInt | A loaded player's prestige stars in an enchant |
prestige(enchantId) | Optional<EnchantPrestigeView> | The prestige settings of an enchant |
momentum(player, enchantId) | Optional<MomentumView> | The momentum of an online player in a momentum enchant |
enchantCooldown(player, enchantId) | OptionalInt | The cooldown left of an enchant for an online player |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
upgrade(player, cause) | CompletableFuture<Boolean> | Buys the next tier like /sword upgrade, charging its price |
setEnchantLevel(player, enchantId, level, cause) | CompletableFuture<Boolean> | Sets a player's enchant level for free, online or offline |
setEnchantPrestige(player, enchantId, stars, cause) | CompletableFuture<Boolean> | Sets the prestige stars of a loaded player's enchant for free |
prestigeEnchant(player, enchantId, cause) | CompletableFuture<Boolean> | Prestiges an enchant like the Prestige button, paying its price |
setMomentum(player, enchantId, value, cause) | CompletableFuture<Boolean> | Sets the momentum, clamped to the cap of their level (0 ends the run) |
addMomentum(player, enchantId, amount, cause) | CompletableFuture<Boolean> | Adds to the momentum (a negative amount takes from it) |
maxMomentum(player, enchantId, cause) | CompletableFuture<Boolean> | Sets the momentum of an online player to the cap of their level |
clearMomentum(player, enchantId, cause) | CompletableFuture<Boolean> | Ends the momentum run of an online player: a setMomentum of 0 |
setEnchantCooldown(player, enchantId, ticks, cause) | CompletableFuture<Boolean> | Sets the cooldown of an enchant in ticks (0 makes it ready now) |
resetEnchantCooldown(player, enchantId, cause) | CompletableFuture<Boolean> | Makes an enchant ready now |
Boosters
boosters() reads boost totals and gives or takes named boosters. Its nested backpack() reaches the booster backpack, and globals() the server-wide boosts.
Boosters
Synchronous:
| Method | Returns | Notes |
|---|---|---|
targets() | List<BoostTargetView> | The active booster targets, in the order of boosters.yml |
total(player, target) | OptionalDouble | A player's total on a target: base x multi (1.0 without boosts) |
base(player, target) | OptionalDouble | A player's base on a target: 1 + the sum of their ADDITIVE bonuses |
multi(player, target) | OptionalDouble | A player's multi on a target: the sum of their MULTIPLICATIVE factors |
breakdown(player, target) | List<BoostGroupView> | One entry per live booster of a player on a target, oldest first |
stacking(player, boosterId) | Optional<BoostStacking> | How a player's live booster with that id counts |
boosters(player) | List<BoosterView> | A player's live boosters on every target, oldest first |
boosters(player, type) | List<BoosterView> | A player's live boosters on one target, oldest first |
booster(player, boosterId) | Optional<BoosterView> | A player's live booster with that id |
existsBooster(player, boosterId) | boolean | True when the player is loaded and has a live booster with that id |
claimMemoryPrefix(owner, prefix) | boolean | Claims a memory booster id prefix, so a SnDungeons clear never takes them |
releaseMemoryPrefix(owner, prefix) | boolean | Gives back a prefix of claimMemoryPrefix: a clear takes its boosters again |
memoryPrefixes() | Map<String, String> | Every claimed memory prefix and its owner |
removeMemoryBooster(player, boosterId) | boolean | Takes one memory booster of a player, without database work |
backpack() | Backpack | The booster backpack of every player |
globals() | GlobalBoosts | The global boosts of the server |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
addBooster(player, boosterId, boosterName, type, multiplier, durationMillis, persistent) | CompletableFuture<Boolean> | Gives an ADDITIVE booster, replacing one with the same id |
addBooster(player, boosterId, boosterName, type, multiplier, durationMillis, persistent, stacking) | CompletableFuture<Boolean> | Gives a booster of either kind, replacing one with the same id |
removeBooster(player, boosterId) | CompletableFuture<Boolean> | Takes one booster of a player by id |
Backpack
Synchronous:
| Method | Returns | Notes |
|---|---|---|
entries(player) | List<BackpackEntryView> | The stored entries of a loaded player |
active(player, type) | Optional<BoosterView> | A player's running (or paused) backpack booster of a type |
item(type, multiplier, durationMillis, amount) | ItemStack | Builds booster items that a right click stores in the backpack |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
read(player) | CompletableFuture<List<BackpackEntryView>> | The stored entries of a player, online or not, read from the database when needed |
deposit(player, type, multiplier, durationMillis, amount) | CompletableFuture<Boolean> | Stores boosters in the backpack (fires BoosterRedeemEvent) |
start(player, type) | CompletableFuture<Boolean> | Starts the stored entry of the highest multiplier of a type |
end(player, type) | CompletableFuture<Boolean> | Ends the backpack booster of a type; its time left goes back to storage |
startAll(player) | CompletableFuture<Integer> | Starts every active type of the player that has something stored and none running |
endAll(player) | CompletableFuture<Integer> | Ends every backpack booster of the player: their time goes back to the storage |
GlobalBoosts
Synchronous:
| Method | Returns | Notes |
|---|---|---|
event() | Optional<GlobalBoostView> | The running global event |
nextEvent() | Optional<GlobalBoostView> | The next automatic global event, rolled and waiting |
item() | Optional<GlobalBoostView> | The running global booster item |
startEvent(type, multiplier, durationMillis) | boolean | Starts a global event now |
stopEvent() | boolean | Ends the running global event now |
stopItem() | boolean | Ends the running global booster item now |
itemStack(type, multiplier, durationMillis, amount) | ItemStack | Builds global booster items: a right click starts the booster for everyone online |
Modifiers
modifiers() registers your DungeonsModifier implementations (see Extension points).
Synchronous:
| Method | Returns | Notes |
|---|---|---|
register(owner, modifier) | void | Registers a modifier after the ones already there |
unregister(modifier) | boolean | Removes a modifier |
unregisterAll(owner) | int | Removes every modifier of a plugin |
registered() | List<String> | The registered modifiers, in order |
Stats
stats() reads the stat counters of each loaded player.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
swings(player) | OptionalLong | The swings of a loaded player that hit a zone mob |
damage(player) | Optional<BigNum> | The damage a loaded player dealt to zone mobs, from every source |
kills(player) | OptionalLong | The zone mobs a loaded player killed |
earned(player, currency) | Optional<BigNum> | What a loaded player earned of a currency by playing (never gives or admin changes) |
peak(player, track) | OptionalInt | The highest level a loaded player reached in a track (a rebirth never lowers it) |
Settings
settings() reads and changes the per-player settings of /settings, and registers settings of other plugins.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
definitions() | List<SettingView> | Every setting registered right now, in registration order |
definition(id) | Optional<SettingView> | One setting registered right now |
enabled(player, id) | boolean | The value a player uses for a setting: their choice, otherwise the default |
permission(id) | Optional<String> | The permission a setting needs, from settings.yml |
permitted(player, id) | boolean | Whether a player may change a setting, as last checked |
register(owner, id, category, defaultValue) | SettingView | Registers a setting of your plugin |
unregisterAll(owner) | int | Removes every setting a plugin registered (also done when that plugin disables) |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
set(player, id, value) | CompletableFuture<Boolean> | Stores a player's value of a setting; its owner applies it at once |
reset(player, id) | CompletableFuture<Boolean> | Removes a player's stored value of a setting: they follow its default again |
Perks
perks() belongs to the perks module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
perks() | List<PerkView> | The perks loaded right now, by rarity (most common first) then id |
perk(perkId) | Optional<PerkView> | One perk by its id |
rarities() | List<PerkRarityView> | The rarities of the perks config, most common first |
player(player) | Optional<PlayerPerkView> | The perk of a loaded player |
pityThreshold() | OptionalInt | The rolls that make the next one come from the pity rarity |
pityRarity() | Optional<String> | The rarity the pity gives |
confirmFrom(player, perkId) | OptionalInt | The lowest level of a perk that asks before a roll replaces it (0 = never) |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
setPerk(player, perkId, level, cause) | CompletableFuture<Boolean> | Sets a loaded player's perk for free (fires PerkChangeEvent) |
clearPerk(player, cause) | CompletableFuture<Boolean> | Takes a loaded player's perk away |
setPity(player, pity, cause) | CompletableFuture<Boolean> | Sets a loaded player's pity counter |
setConfirmFrom(player, perkId, fromLevel, cause) | CompletableFuture<Boolean> | Sets a loaded player's confirmation of one perk |
roll(player, times, cause) | CompletableFuture<Integer> | Rolls with the player's tickets: one roll or a Roll Max chain |
Auras
auras() belongs to the auras module. Its writes act on online loaded players.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
types() | List<AuraTypeView> | The aura types loaded right now, in menu order |
type(id) | Optional<AuraTypeView> | One loaded aura type |
rarities() | List<String> | The rarity ids of every tier, in progress order (rarity step 1 first) |
aura(player, type) | Optional<AuraView> | A loaded player's aura of a loaded type |
auras(player) | List<AuraView> | Every aura of a loaded player, one per loaded type, in menu order |
equipped(player) | List<String> | The aura types a loaded player has equipped, in slot order |
slots(player) | OptionalInt | The aura slots of an online loaded player |
swings(player) | OptionalLong | The swings a loaded player counted toward their next aura milestone |
requiredSwings(player) | OptionalLong | The swings a loaded player's next aura milestone needs |
chance(player) | OptionalDouble | Each equipped aura's chance to step up at a milestone, before modifiers |
upgradeLevel(player, upgrade) | OptionalInt | A loaded player's level of an aura upgrade |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
equip(player, type, cause) | CompletableFuture<Boolean> | Equips an aura in the lowest free slot |
unequip(player, type, cause) | CompletableFuture<Boolean> | Takes an aura off |
setAura(player, type, tier, rarity, cause) | CompletableFuture<Boolean> | Sets the tier and rarity step of an aura |
addSwings(player, swings, cause) | CompletableFuture<Boolean> | Adds swings to the aura milestone counter |
milestone(player, cause) | CompletableFuture<Boolean> | Forces an aura milestone: every equipped aura rolls |
Milestones
milestones() belongs to the milestones module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
categories() | List<MilestoneCategoryView> | Every category, in tab order |
category(category) | Optional<MilestoneCategoryView> | One category by its id |
state(player, category, key) | Optional<MilestoneState> | Where a loaded player stands with a milestone |
progress(player, category) | Optional<BigNum> | The value of a category's source for a loaded player (what its requirements compare) |
completed(player) | OptionalInt | How many milestones a loaded player reached in every category (claimed or not) |
claimable(player) | OptionalInt | How many milestones a loaded player reached and has not claimed |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
claim(player, category, key, cause) | CompletableFuture<Boolean> | Claims a milestone the way a click does: stored first, then the rewards run |
reset(player, category, cause) | CompletableFuture<Boolean> | Removes claims of a player, loaded or not |
Totems
totems() belongs to the totems module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
types() | List<String> | The loaded totem types |
skins() | List<String> | The loaded skins |
upgrades() | List<String> | The four upgrade ids: level-cap, max-star, double-exp, multiplier |
totems(player) | List<TotemView> | Every totem of a loaded player, the equipped ones first |
equipped(player) | List<TotemView> | The equipped totems of a loaded player, by slot |
skinsOf(player) | List<TotemSkinView> | Every totem skin of a loaded player |
slots(player) | OptionalInt | The totem slots a loaded player can use now |
upgradeLevel(player, upgrade) | OptionalInt | A loaded player's level of an upgrade |
giveBox(player, tier, amount) | boolean | Gives an online player Totem Box items of a tier |
giveSkinBox(player, amount) | boolean | Gives an online player Totem Skin Box items, like giveBox |
filters(player) | Set<String> | The totem types a loaded player filters out of Totem Box rolls |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
giveTotem(player, type, tier, stars, cause) | CompletableFuture<Optional<TotemView>> | Gives a totem straight into storage, online or offline, its value rolled |
giveSkin(player, skin, cause) | CompletableFuture<Optional<TotemSkinView>> | Gives a skin straight into the skin storage, online or offline |
equip(player, totem) | CompletableFuture<Boolean> | Equips a storage totem of a loaded player in their first free slot |
unequip(player, totem) | CompletableFuture<Boolean> | Takes an equipped totem of a loaded player back to their storage |
setUpgrade(player, upgrade, level, cause) | CompletableFuture<Boolean> | Sets a player's upgrade level for free, online or offline |
setFilter(player, type, filtered, cause) | CompletableFuture<Boolean> | Filters a totem type, or stops filtering it |
Attributes
attributes() belongs to the attributes module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
leveling() | Optional<String> | The id of the leveling whose level unlocks the attribute levels |
levels() | List<AttributeLevelView> | Every attribute level, in ladder order (sorted by requirement) |
level(number) | Optional<AttributeLevelView> | One attribute level by its number |
playerLevel(player) | OptionalInt | The attribute level of a loaded player, after the modifiers |
boosts(player) | Map<String, Double> | The boosts a loaded player gets from their attributes right now |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
refresh(player, cause) | CompletableFuture<Boolean> | Resolves the attributes of a loaded player again, after your modifier changed |
Crystals
crystals() belongs to the crystals module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
types() | List<String> | The loaded crystal types |
tiers() | List<Integer> | The loaded Crystal Box tiers |
storage(player) | List<CrystalView> | The storage crystals of a loaded player, best first (tier, then value) |
applied(player) | List<CrystalView> | The crystals applied to a loaded player's sword, by slot |
slots(player) | OptionalInt | The crystal slots a loaded player has now |
maxSlots() | int | The most crystal slots a player can have |
giveBox(player, tier, amount) | boolean | Gives an online player Crystal Box items of a tier |
filters(player) | Set<String> | The crystal types a loaded player filters out of Crystal Box rolls |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
giveCrystal(player, type, tier, cause) | CompletableFuture<Optional<CrystalView>> | Gives a crystal straight into storage, online or offline, its numbers rolled |
giveCrystal(player, type, tier, value, chance, cause) | CompletableFuture<Optional<CrystalView>> | Gives a crystal of exact numbers straight into storage |
apply(player, crystal) | CompletableFuture<CrystalApplyResult> | Applies a storage crystal like the menu: it is applied or destroyed |
remove(player, crystal) | CompletableFuture<Boolean> | Takes a crystal off the sword: it is destroyed |
setFilter(player, type, filtered, cause) | CompletableFuture<Boolean> | Filters a crystal type, or stops filtering it |
Armors
armors() belongs to the armors module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
sets() | List<ArmorSetView> | The armor sets loaded right now, in progression order |
set(id) | Optional<ArmorSetView> | One loaded armor set |
skins() | List<ArmorSkinView> | The armor skins loaded right now, in menu order |
skin(id) | Optional<ArmorSkinView> | One loaded armor skin |
upgrades() | List<String> | The armor upgrade ids: exp-multi, double-exp, set-boost, double-level, skin-boost |
maxLevel() | int | The highest armor level: the last set's last level |
level(player) | OptionalInt | A loaded player's armor level |
exp(player) | OptionalLong | The armor experience a loaded player gathered toward their next level |
expNeeded(player) | OptionalLong | The armor experience a loaded player's next level needs |
currentSet(player) | Optional<ArmorSetView> | The armor set a loaded player wears (the set of their level) |
pieces(player) | Map<EquipmentSlot, ItemStack> | Copies of the armor pieces a loaded player shows to others |
selectedSkin(player) | Optional<String> | The armor skin a loaded player has selected |
unlockedSkins(player) | Set<String> | The armor skins a loaded player has unlocked |
upgradeLevel(player, upgrade) | OptionalInt | A loaded player's level of an armor upgrade |
boosts(player) | Map<String, Double> | The additive bonus a loaded player's armor level gives each booster target |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
addExp(player, exp, cause) | CompletableFuture<Boolean> | Adds armor experience as counted swings do, level-ups included |
setLevel(player, level, cause) | CompletableFuture<Boolean> | Sets the armor level; experience goes back to 0 |
unlockSkin(player, skin, cause) | CompletableFuture<Boolean> | Unlocks an armor skin for an online loaded player |
selectSkin(player, skin, cause) | CompletableFuture<Boolean> | Selects an unlocked armor skin, or takes the selected one off |
Autofighter
autofighter() belongs to the autofighter module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
upgrades() | List<String> | The upgrade ids: target, daily, speed |
balance(player) | OptionalLong | A loaded player's time balance |
usedToday(player) | OptionalLong | The autofighter time a loaded player used since the last daily reset |
dailyLimit(player) | OptionalLong | The daily limit of an online loaded player |
resetsIn() | OptionalLong | How long until the next daily reset |
active(player) | boolean | Whether a player's autofighter runs right now |
targetMode(player) | Optional<AutofighterTargetMode> | The target mode a loaded player's autofighter picks mobs by |
upgradeLevel(player, upgrade) | OptionalInt | A loaded player's level of an autofighter upgrade |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
addTime(player, millis, cause) | CompletableFuture<Long> | Adds time to a player's balance, online or not |
takeTime(player, millis, cause) | CompletableFuture<Long> | Takes time from a player's balance, online or not (never below 0) |
setTime(player, millis, cause) | CompletableFuture<Long> | Sets a player's balance, online or not |
resetDaily(player, cause) | CompletableFuture<Boolean> | Resets a player's use of today to 0, online or not |
setUpgrade(player, upgrade, level, cause) | CompletableFuture<Boolean> | Sets a player's upgrade level for free, online or not |
start(player, cause) | CompletableFuture<Boolean> | Starts an online player's autofighter with every requirement of the menu |
stop(player, cause) | CompletableFuture<Boolean> | Stops a player's autofighter (SnDungeons sends no message) |
Afk
afk() belongs to the afk module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
upgrades() | List<String> | The upgrade ids: speed, swings, count |
active(player) | boolean | Whether a player is afk right now (their clones are out) |
clones(player) | int | How many clones a player has out right now |
cloneCount(player) | OptionalInt | How many clones a loaded player gets when they go afk |
swingsPerSecond(player) | OptionalDouble | How many times per second each clone of a loaded player swings |
speed(player) | OptionalDouble | How fast the clones of a loaded player walk between mobs |
upgradeLevel(player, upgrade) | OptionalInt | A loaded player's level of an afk upgrade |
sessionEarned(player) | Map<String, BigNum> | What a player's clones earned since they last went afk, by currency |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
setUpgrade(player, upgrade, level, cause) | CompletableFuture<Boolean> | Sets a player's afk upgrade level for free, online or not |
start(player, cause) | CompletableFuture<Boolean> | Puts an online loaded player afk now, skipping only the idle time |
stop(player, cause) | CompletableFuture<Boolean> | Ends a player's afk now (SnDungeons sends no message) |
Heroes
heroes() belongs to the heroes module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
heroes() | List<String> | The heroes loaded from the owner folder, in menu order |
enchants() | List<String> | The Hero Enchants loaded from the owner folder, in menu order |
upgrades(hero) | List<String> | The upgrades of a hero: four stat upgrades and its specials |
unlocked(player, hero) | boolean | Whether a loaded player has a hero unlocked |
state(player, hero) | Optional<HeroState> | Where a loaded player's hero stands |
health(player, hero) | OptionalDouble | A loaded player's hero health right now |
maxHealth(player, hero) | OptionalDouble | A loaded player's hero max health |
healTime(player, hero) | OptionalLong | How long a loaded player's sleeping hero needs to heal fully |
active(player) | Set<String> | The heroes of a player fighting right now |
upgradeLevel(player, hero, upgrade) | OptionalInt | A loaded player's level of an upgrade of one of their heroes |
enchantLevel(player, enchant) | OptionalInt | A loaded player's level of a Hero Enchant |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
setUnlocked(player, hero, unlocked, cause) | CompletableFuture<Boolean> | Unlocks a hero for a loaded player, or takes the admin unlock back |
heal(player, hero, cause) | CompletableFuture<Boolean> | Heals a loaded player's hero to its max health |
summon(player, hero, cause) | CompletableFuture<Boolean> | Summons a hero with every requirement of the menu |
store(player, hero, cause) | CompletableFuture<Boolean> | Puts an active hero to sleep (SnDungeons sends no message) |
setUpgrade(player, hero, upgrade, level, cause) | CompletableFuture<Boolean> | Sets a hero upgrade level for free |
setEnchant(player, enchant, level, cause) | CompletableFuture<Boolean> | Sets a Hero Enchant level for free |
Contests
contests() belongs to the contests module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
variants() | List<String> | The contest variants loaded from modules/contests/variants/ |
running() | boolean | Whether a contest runs right now |
current() | Optional<String> | The variant of the contest running right now |
timeLeft() | OptionalLong | The time the running contest has left |
ranking(limit) | List<ContestEntry> | The ranking of the running contest, highest score first |
score(player) | OptionalDouble | A player's score in the running contest |
rank(player) | OptionalInt | A player's place in the running contest |
nextStart() | OptionalLong | When the next scheduled contest starts |
nextVariant() | Optional<String> | The variant the next scheduled contest takes |
record(variant) | Optional<ContestRecord> | The best score ever of a variant |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
start(variant, cause) | CompletableFuture<Boolean> | Starts a contest of a variant now, like /dungeons admin contests start |
stop(reward, cause) | CompletableFuture<Boolean> | Ends the running contest now |
addScore(player, name, points, cause) | CompletableFuture<Boolean> | Adds points to a player's score (negative takes them away) |
Companions
companions() belongs to the companions module, which needs SnCompanions installed.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
hooked() | boolean | Whether SnCompanions has the SnDungeons content registered right now |
type(companionId) | Optional<CompanionTypeInfo> | One companion type of SnDungeons |
egg(zone, stage) | Optional<CompanionEggInfo> | The egg of one stage of a zone |
eggs() | List<CompanionEggInfo> | Every egg of the catalogue, in progression order |
upgrades() | List<String> | The chance upgrade ids: luck, then one per fusion state after the first |
upgradeLevels(player) | Map<String, Integer> | A loaded player's levels of the chance upgrades |
boosts(player) | Map<String, BigNum> | The bonuses the equipped companions give a player, by currency |
refresh(player) | boolean | Computes the companion boosters of an online loaded player again |
refreshCatalog() | boolean | Builds the catalogue again and registers it with SnCompanions |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
setUpgrade(player, upgrade, level, cause) | CompletableFuture<Boolean> | Sets a player's chance upgrade level for free, online or not |
Objectives
objectives() is the objective bus. The core and every module announce what a player really did, and your plugin subscribes to the types it counts. subscribe returns a Subscription, and your ObjectiveListener receives each notice with an ObjectiveContextView.
Objectives
Synchronous:
| Method | Returns | Notes |
|---|---|---|
types() | List<ObjectiveTypeView> | Every objective type that exists right now, in declaration order |
type(type) | Optional<ObjectiveTypeView> | One objective type |
hasType(type) | boolean | Whether a type exists right now |
subscribe(owner, type, listener) | Subscription | Subscribes to the notices of a type |
progress(player, type, amount, context) | boolean | Pushes progress of a custom: type for a player to every subscriber |
scale(player, formula) | BigNum | Evaluates a hunt scale formula for a player |
Subscription
Synchronous:
| Method | Returns | Notes |
|---|---|---|
type() | String | The type it receives |
active() | boolean | True until it ended |
cancel() | void | Ends it: no notice arrives afterwards |
ObjectiveListener
Synchronous:
| Method | Returns | Notes |
|---|---|---|
onObjective(player, type, amount, context) | void | Receives one notice: the player, the type, the amount and its context |
ObjectiveContextView
Synchronous:
| Method | Returns | Notes |
|---|---|---|
get(key) | String | The value of one context key |
keys() | Set<String> | Every key this notice carries |
Hunts
hunts() belongs to the hunts module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
slots(player) | OptionalInt | How many hunt slots the player has |
slot(player, slot) | Optional<HuntSlotView> | The hunt in one slot |
slotList(player) | List<HuntSlotView> | Every stored slot of the player, in slot order |
resetIn() | long | Milliseconds until the next reset (0 while the module is off) |
rerollsLeft(player) | int | The rerolls left in the current window |
bonusState(player) | Optional<HuntBonusState> | The state of the bonus of the current window |
pool() | List<HuntDefinitionView> | Every loaded hunt, in file order |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
complete(player, slot, cause) | CompletableFuture<Boolean> | Completes the hunt of a slot; it waits for its claim |
setProgress(player, slot, progress, cause) | CompletableFuture<Boolean> | Sets the progress of an ACTIVE hunt (reaching the target completes it) |
reset(player, cause) | CompletableFuture<Void> | Deletes the hunts of a player, except claimed ones still owed rewards |
addSlots(player, slots, cause) | CompletableFuture<Integer> | Adds slots to a player (negative takes them away) |
Luck
luck() is the luck core: Luck points, the effects every system rolls and the fixed bonuses of other plugins.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
luck(player) | int | The Luck points of a player (0 when not loaded) |
chance(player, key) | double | The chance of a luck effect for a player, in percent |
breakdown(player, key) | List<LuckPartView> | The parts of that chance: Luck first, then each fixed bonus |
effects() | List<LuckEffectView> | Every factory luck effect, in catalog order |
hasEffect(key) | boolean | True for a known effect key |
addBonus(owner, player, key, percent, displayName) | void | Adds or replaces a fixed bonus of your plugin on one effect of a player |
removeBonus(owner, player) | void | Removes every bonus your plugin added to a player |
removeBonus(owner, player, key) | void | Removes the bonus your plugin added to a player on one effect |
Cookies
cookies() belongs to the cookies module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
active(player) | Optional<ActiveCookieView> | The active cookie of a loaded player |
types() | List<CookieTypeView> | Every loaded cookie type, in file order |
type(id) | Optional<CookieTypeView> | One loaded cookie type |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
activate(player, id, durationMillis, cause) | CompletableFuture<Void> | Activates a cookie for a player, replacing any active one; no item is taken |
clear(player, cause) | CompletableFuture<Boolean> | Ends a player's cookie |
addTime(player, millis, cause) | CompletableFuture<Long> | Adds time to a player's active cookie |
setTime(player, millis, cause) | CompletableFuture<Long> | Sets the time left of a player's active cookie |
Anticheat
anticheat() belongs to the anticheat module.
Synchronous:
| Method | Returns | Notes |
|---|---|---|
checks() | List<String> | Every check id, in a stable order |
violations(player, check) | double | A player's violation level of one check now |
violations(player) | Map<String, Double> | Every non-zero violation level of a player now, by check |
exempt(player) | boolean | True while the player is never checked (bypass permission) |
alertsOn(staff) | boolean | True when a staff member has anticheat alerts on |
Asynchronous:
| Method | Returns | Notes |
|---|---|---|
history(player, limit) | CompletableFuture<List<AnticheatFlagView>> | The stored flags of a player, online or not, newest first |
reset(player, check, cause) | CompletableFuture<Void> | Clears the violation level of one check or all, and re-arms thresholds |
setAlerts(staff, on, cause) | CompletableFuture<Void> | Switches a staff member's anticheat alerts on or off |
Extension points
com.sn.dungeons.api.modifier.DungeonsModifier is the extension point. It shapes the values
SnDungeons decides: chances, cooldowns, damage, rates, gains, prices, rarities, health, rewards
and more. Every method is a default method that returns the value it received, so you override
only what you shape. Each method receives a read-only context record from the same package.
public final class DoubleCoins implements DungeonsModifier {
@Override
public BigNum gain(GainContext ctx) {
return ctx.currencyId().equals("coins") ? ctx.amount().multiply(2) : ctx.amount();
}
}
api.modifiers().register(this, new DoubleCoins());Register through api.modifiers().register(plugin, modifier). Modifiers chain in registration
order, and each one receives the value the one before it left. A modifier leaves with the plugin
that registered it, or through unregister and unregisterAll.
| Method | What it influences | Neutral return |
|---|---|---|
procChance(ProcChanceContext) | The chance of one enchant roll | ctx.chance() |
procCooldown(ProcCooldownContext) | The cooldown an enchant starts when it procs | ctx.cooldownTicks() |
hitDamage(HitDamageContext) | The damage of one hit on a zone mob, whatever its source | ctx.damage() |
swingsPerSecond(SwingRateContext) | A player's swings per second | ctx.rate() |
gain(GainContext) | One currency gain | ctx.amount() |
pouchAmount(PouchContext) | The total of one open of currency pouches, before it is given | ctx.amount() |
priceFactor(PriceContext) | A factor on a price a player is shown or charged (PurchaseKind tells which) | 1.0 |
mobRarity(MobRarityContext) | The rarity of a zone mob about to appear | ctx.rarity() |
mobMaxHealth(MobHealthContext) | The full health of a zone mob | ctx.maxHealth() |
eventMultiplier(EventRollContext) | The multiplier of an automatic global event when it is rolled | ctx.multiplier() |
eventDuration(EventRollContext) | How long an automatic global event lasts when it is rolled | ctx.durationMillis() |
eventInterval(EventRollContext) | The wait before an automatic global event starts when it is rolled | ctx.intervalMillis() |
autoKillSeconds(KillTimeContext) | The most seconds a kill may take for the automatic zone purchase | ctx.maxSeconds() |
perkRollCost(PerkRollContext) | What one sword perk roll spends of its currency | ctx.cost() |
perkPityIncrement(PerkRollContext) | How much one sword perk roll adds to the pity counter | ctx.pityIncrement() |
perkForcePity(PerkRollContext) | Whether a sword perk roll comes from the pity's rarity | ctx.forcedPity() |
perkWeight(PerkWeightContext) | The weight of one perk in a roll | ctx.weight() |
perkLevelWeight(PerkLevelContext) | The weight of one level of the perk a roll picked | ctx.weight() |
perkResult(PerkResultContext) | The result of a perk roll before it is written | ctx.pick() |
perkTicketAmount(PerkTicketContext) | The tickets one purchase of the Tool Perks menu gives | ctx.amount() |
perkRollMaxLimit(PerkRollMaxContext) | The most rolls of a Roll Max chain | ctx.maxRolls() |
auraSwingProgress(AuraSwingContext) | The swings one swing adds to a player's aura milestone counter | ctx.swings() |
auraMilestoneSwings(AuraRequirementContext) | The swings a player's next aura milestone needs | ctx.requirement() |
auraChance(AuraChanceContext) | The chance of one equipped aura to step up at an aura milestone | ctx.chance() |
auraBoost(AuraBoostContext) | The additive bonus an equipped aura gives its target | ctx.value() |
milestoneRewards(MilestoneRewardContext) | The reward lines a claimed milestone runs | ctx.rewards() |
totemRoll(TotemRollContext) | The base value a new totem rolls (it keeps it for its whole life) | ctx.value() |
totemXp(TotemXpContext) | The experience one equipped totem gains from one kill of its owner | ctx.xp() |
attributeLevel(AttributeLevelContext) | The sword attribute level a player gets | ctx.level() |
attributeBoost(AttributeBoostContext) | One additive boost of a player's sword attribute level | ctx.value() |
crystalRoll(CrystalRollContext) | The crystal one Crystal Box gives | ctx.roll() |
crystalApplyChance(CrystalApplyContext) | The chance an apply of a storage crystal is rolled against | ctx.chance() |
armorExp(ArmorExpContext) | The armor experience one counted swing adds to a player | ctx.exp() |
armorChance(ArmorChanceContext) | The chance of one armor roll (double-exp, double-level, set-boost, skin-boost) | ctx.chanceValue() |
armorBoost(ArmorBoostContext) | One additive bonus the armor level gives its target | ctx.value() |
armorMultiBoost(ArmorMultiBoostContext) | The multiplier of a Set Multi Boost or Skin Multi Boost about to start | ctx.multiplier() |
armorMultiBoostSeconds(ArmorMultiBoostContext) | How long a Set Multi Boost or Skin Multi Boost about to start lasts | ctx.seconds() |
autofighterTime(AutofighterTimeContext) | The time one second of a running autofighter takes from its owner's balance | ctx.millis() |
autofighterDailyLimit(AutofighterLimitContext) | A player's daily autofighter limit | ctx.limitMillis() |
autofighterSpeed(AutofighterSpeedContext) | How fast a player's autofighter walks between the zone mobs | ctx.speed() |
afkClones(AfkClonesContext) | How many clones a player gets when they go afk | ctx.clones() |
afkSwings(AfkSwingsContext) | How many times per second each clone of an afk player swings | ctx.swingsPerSecond() |
afkSpeed(AfkSpeedContext) | How fast the clones of an afk player walk between the zone mobs | ctx.speed() |
heroHitDamage(HeroHitContext) | The damage of one hit of a player's hero on a zone mob | ctx.damage() |
heroProcFactor(HeroProcContext) | The factor the player's enchant chances roll with on one hit of their hero | ctx.factor() |
afkProcFactor(AfkProcContext) | The factor the player's enchant chances roll with on one hit of an afk clone | ctx.factor() |
heroReviveHealth(HeroReviveContext) | The health a player's hero comes back with at 0 health (0 = it falls asleep) | ctx.health() |
heroEffectChance(HeroEffectContext) | The chance of one effect of a player's hero | ctx.chance() |
contestVariant(ContestStartContext) | The variant of a contest about to start | ctx.variant() |
contestDuration(ContestStartContext) | How long a contest about to start lasts | ctx.durationSeconds() |
contestSpawnInterval(ContestSpawnContext) | The seconds between two targets of a player in a contest | ctx.everySeconds() |
contestTargetPosition(ContestTargetContext) | Where a contest target appears for a player | ctx.point() |
contestCatchPoints(ContestCatchContext) | The points of one catch of a contest target | ctx.points() |
contestRanking(ContestRankingContext) | The final ranking of a contest, in the order the players place | the player ids of ctx.ranking(), in order |
contestRewards(ContestRewardContext) | The reward lines of one place of a contest, or of its participation reward | ctx.rewards() |
levelingPoints(LevelingPointsContext) | The points one real level-up of a leveling track with upgrades gives | ctx.points() |
levelingUpgradeBoost(LevelingUpgradeBoostContext) | The additive boost a booster upgrade of a leveling track gives a player | ctx.value() |
companionValue(CompanionValueContext) | The value of one companion type of SnDungeons | ctx.value() |
companionRoll(CompanionRollContext) | The result of one companion egg | ctx.rolled() |
companionBoost(CompanionBoostContext) | The bonus the equipped companions give a player in one currency | ctx.value() |
huntPick(HuntPickContext) | The hunt picked for a slot being assigned or rerolled | ctx.huntId() |
huntTarget(HuntTargetContext) | The target of a hunt being assigned (stored, never computed again) | ctx.target() |
huntValues(HuntValuesContext) | The named values of a hunt being assigned (stored; the reward lines read them) | ctx.values() |
huntProgress(HuntProgressContext) | The progress one objective notice adds to a hunt | ctx.amount() |
huntRewards(HuntRewardContext) | The reward lines a hunt claim (or the bonus) runs | ctx.rewards() |
luckChance(LuckChanceContext) | The chance of one luck effect roll | ctx.chance() |
cookieDuration(CookieDurationContext) | The time an eaten cookie adds | ctx.durationMillis() |
anticheatWeight(AnticheatWeightContext) | The violation level a failed anticheat check adds | ctx.weight() |
Providers must be fast; a provider that throws contributes the neutral value and never breaks gameplay. Every method runs on the main thread, several of them on every hit, swing or roll, so never do I/O there. A modifier that throws, or returns a refused value, is skipped for that call with one warning per plugin and method.
The API offers a few more ways to plug in, listed in the tables above:
settings().register(...)adds your own per-player setting to/settings.objectives().subscribe(...)receives what players really did;progress(...)pushes your owncustom:types.luck().addBonus(...)adds a fixed bonus to a luck effect of a player.boosters().claimMemoryPrefix(...)keeps your memory boosters safe from a SnDungeons booster clear.
Versioning
Call getApiVersion() for the API contract version. It is independent of the plugin version.
Additions bump the minor component. Existing members are never removed or changed; deprecated
members keep working.