Objectives
On this page(8)
SnDungeons announces what each player did, at the moment it really happened. Examples are a stage bought, a mob killed, an enchant level bought and a pouch opened. The hunts module counts these objectives, and other plugins can too. You can also turn an event of another plugin into an objective, with no code.
| Files | objectives/custom-events.yml (an owner file: created once, then yours) |
| Used by | The Hunts module, and other plugins through the Developer API |
| Admin commands | /dungeons admin objectives types|custom |
| Switch | None: a type nobody counts costs nothing |
How it works
Each objective is "player Z did X of type T, here". It is announced only once the action is final: a purchase after it was paid, a kill after its rewards. A cancelled or refunded action never counts.
Whoever counts objectives asks only for the types it needs. A hunt of kills makes the plugin
announce kills while that hunt is held, and nothing else.
What never counts:
- Admin commands and API writes (except a
custom:type). - The kills, damage, procs and currency of the AFK clones and the heroes.
- An AFK session started by an admin, and auras stepped by an admin.
Automatic purchases (an automatic level-up, an automatic stage) do count.
The objective types
/dungeons admin objectives types lists the types that exist right now. A module's types exist only
while that module is on.
The context keys are what a hunt can filter on, such as filters: { zone: [barn] }. A value
ending in * matches by prefix.
| Type | Counts | Context keys | Owner |
|---|---|---|---|
swings | Each swing of the sword at a zone mob | zone, stage | zones |
kills | Each zone mob killed | zone, stage, rarity, mob (the entity type, lowercase) | zones |
damage | The damage dealt to zone mobs | zone | zones |
stages | The stages unlocked | zone | zones |
enchant-procs | Each enchant proc | enchant, trigger | sword |
sword-tiers | The sword tiers bought | sword | |
enchant-levels | The enchant levels bought | enchant | sword |
enchant-prestige | The enchant prestiges | enchant | sword |
level-up | The levels gained (command, rebirth, automatic) | track | core |
leveling-upgrades | The leveling upgrade levels bought in the menu | track, upgrade | core |
currency-earned | The currency earned from mobs and enchants, after boosters | currency, cause | core |
currency-spent | The currency a player spent on their own purchases | currency, cause | core |
pouches | The pouches opened | currency, pouch | core |
shop-purchases | The units bought in a currency shop | shop, entry | core |
boosters-used | The boosters started from the backpack (by hand or automatic) | type | core |
playtime | The minutes online | core | |
contest-points | The contest points scored | variant | contests |
contest-place | A contest ended by its time, with the player placed | variant, place | contests |
perk-rolls | The perk rolls | rarity, perk | perks |
totem-boxes | The totem boxes opened | tier | totems |
totem-merges | The totem merges | tier (of the result) | totems |
crystal-boxes | The crystal boxes opened | tier | crystals |
crystal-applies | The crystals applied | type | crystals |
armor-levels | The armor levels gained by swinging | armors | |
aura-steps | The aura milestones reached | type | auras |
aura-upgrades | The aura upgrade levels bought | upgrade | auras |
companion-eggs | The paid eggs opened | zone, stage | companions |
companion-upgrades | The companion upgrade levels bought | upgrade | companions |
hero-upgrades | The hero upgrade and Hero Enchant levels bought | hero, upgrade (enchant:<id> for an enchant) | heroes |
afk-upgrades | The AFK upgrade levels bought | upgrade | afk |
afk-minutes | The minutes of AFK clones | afk | |
autofighter-upgrades | The autofighter upgrade levels bought | upgrade | autofighter |
autofighter-minutes | The minutes of autofighter | autofighter | |
milestones-claimed | The milestones claimed (a click or Claim All) | category | milestones |
Events of other plugins
objectives/custom-events.yml turns an event of another plugin into the type custom:<id>. A hunt
then counts it with objective: custom:<id>. The file ships with one disabled example that counts
NuVotifier votes.
objectives/custom-events.yml
example-vote:
enabled: false
plugin: Votifier
event: 'com.vexsoftware.votifier.model.VotifierEvent'
priority: MONITOR
ignore-cancelled: true
player: 'getVote.getUsername'
context:
site: 'getVote.getServiceName'
max-failures: 20The entry id (example-vote) is lowercase letters, digits and -, at most 48 characters.
| Key | Default | What it does |
|---|---|---|
enabled | true | false switches the entry off: it has no type |
plugin | The plugin that owns the event. While it is not enabled, the entry waits for it | |
event | The full class name of the event (a Bukkit event) | |
priority | MONITOR | LOWEST, LOW, NORMAL, HIGH, HIGHEST or MONITOR |
ignore-cancelled | true | true = a cancelled event counts nothing |
player | A chain of methods of the event, separated by ., that returns a Player, an OfflinePlayer, a UUID or a player name | |
amount | Optional: a chain that returns a number. Without it, each event adds 1. Zero or less adds nothing | |
filters | Optional: chain -> accepted values (text, case ignored). The event counts only when every chain reads one of its values | |
context | Optional: context key -> chain. The hunts filter on these keys. At most 8 keys | |
max-failures | 20 | 1 to 1000. After that many failures in a row, the entry switches off until the next reload |
How a chain works
A chain is a list of public methods with no arguments, called one after another. For example,
getVote.getUsername calls getVote() on the event, then getUsername() on the result. Nothing is
ever written: the plugin only reads.
- A name as
playercounts only for a player who is online when the event fires. - A chain that fails is one console warning per entry, until it works again. It fails when it throws, or reads nothing where a value is needed.
- The events are read only while something counts the type: a hunt holding it, or another plugin's subscription. Then every event of that class is read, so pick events that fire once per action, never once per tick or movement.
The file is yours: the plugin never changes it, and /dungeons reload reads it again.
/dungeons admin objectives custom shows each entry with its state: active, waiting for its
plugin, error or disabled. It also shows how many times it counted since the last reload, the
last player and the last amount.
Scale formulas
The targets and rewards of the hunts can grow with the player, through a formula. A formula is computed for one player, with numbers of any size.
- Operators:
+ - * / ^and parentheses. - Functions:
min(a, b, ...),max(...),floor(x),ceil(x),round(x).
| Variable | Value |
|---|---|
{stage} | The global index (from 1) of the player's highest unlocked stage, counting every stage of every zone in order |
{stage-reward:<currency>} | What a mob of that stage pays in that currency (no boosters, no rarity bonus) |
{stage-cost} | The price of the next stage (at the last stage, the price of the last one) |
{level:<track>} | The player's level in that leveling track |
modules/hunts/hunts/earn-money.yml (part)
target: '{stage-reward:money} * 300'With the zones module off, the stage variables read 0, with one console warning. See Hunts for where formulas go.
Commands
| Command | Permission | Description |
|---|---|---|
/dungeons admin objectives types | sndungeons.admin.objectives.types | The objective types that exist right now, their context keys and owner |
/dungeons admin objectives custom | sndungeons.admin.objectives.custom | The entries of objectives/custom-events.yml, their state and last notice |
See Commands for the full list.
Tips
- Run
/dungeons admin objectives typesafter enabling a module, to see which types it brings. - Test a custom entry with a hunt of its type, then watch
/dungeons admin objectives custom. - The debug category
objectiveslogs every decision./dungeons admin inspect player <player>shows the types someone counts.
Default objectives/custom-events.yml
# Custom objective events: each entry listens to an event of ANOTHER plugin and turns it into
# progress of the objective type custom:<id> (a hunt counts it with "objective: custom:<id>";
# another plugin subscribes to it through the API).
#
# This file is yours: it is created once while it does not exist and never changed by the plugin.
# /dungeons reload reads it again. /dungeons admin objectives custom shows every entry: its state
# (active, waiting for its plugin, error, disabled), how many times it fired, the last player and
# the last amount.
#
# Keys of an entry (the entry id is lowercase letters, digits and -, at most 48):
# enabled true or false (default true). An entry switched off has no type.
# plugin the plugin that owns the event. While it is not enabled the entry waits for it.
# event the FULL class name of the event (a Bukkit event with a static getHandlerList).
# priority LOWEST, LOW, NORMAL, HIGH, HIGHEST or MONITOR (default MONITOR).
# ignore-cancelled true = a cancelled event counts nothing (default true).
# player a chain of public no-argument methods of the event, separated by '.', that
# returns a Player, an OfflinePlayer, a UUID, or a player name (a name counts only
# for a player online when it fires). A method that returns nothing is never called.
# amount optional chain returning a number (or a text holding one); without it every
# event adds 1. Zero or less adds nothing.
# filters optional: chain -> accepted values (compared as text, ignoring case). The event
# counts only when every chain reads one of its values.
# context optional: context key -> chain. The hunts filter on these keys
# (filters: { key: [values] } in a hunt file). At most 8 keys.
# max-failures 1..1000 (default 20): a chain that fails (throws, or reads nothing where a value
# is needed) that many times in a row switches the entry off until the next reload.
#
# The events are read only while something counts the type (a hunt holding it, another plugin's
# subscription); then every event of the class is read (the chains run on the thread of the event), so
# prefer events that fire a few times per action, never once per tick or per movement.
#
# The example below counts NuVotifier votes (custom:example-vote), with the vote site as context.
# Set enabled: true to use it.
example-vote:
enabled: false
plugin: Votifier
event: 'com.vexsoftware.votifier.model.VotifierEvent'
priority: MONITOR
ignore-cancelled: true
player: 'getVote.getUsername'
context:
site: 'getVote.getServiceName'
max-failures: 20