For the complete documentation index, see llms.txt. This page is also available as Markdown.

Developer API

The plugin exposes a small API for other plugins: you can add your own objective triggers, reward types, register quests from code, listen to leveling events and modify per-player limits. This page assumes you're comfortable writing a Bukkit plugin.

Setup

And depend on the plugin in your plugin.yml so it loads first:

The entry point is a static accessor, available from onLoad() onward:

The API at a glance

Custom objective triggers

This is the most useful extension point: it lets quest creators use your plugin's actions in quests.yml, just like the built-in triggers.

A trigger has two halves — an ObjectiveHandler that knows how to match and count an action, and a call to api.trigger(...) that fires when the action happens.

1. Implement the handler

  • trigger() — the trigger's ID. It's what quest creators write in the trigger: field (IDs are lowercased automatically).

  • matches(target, context) — decides whether this event counts for an objective with the given target. The context is whatever object you pass to api.trigger(...); a small record is the usual pattern.

  • progress(context) — how much progress the event is worth. Return 1 for count-based objectives, or an amount (damage, money, items) for total-based ones.

2. Register it and fire it

3. Use it in quests.yml

How a trigger call flows

api.trigger(player, trigger, context) only affects the given player, and only their active quests. For each active quest, every objective whose trigger: matches the trigger ID is tested with matches(...); on a match, progress(...) is added (capped at required). Progress messages, objective/quest completion and rewards are all handled for you.

Custom rewards

A RewardHandler adds a new type: for the rewards: section:

The value arrives as the raw string from the config — parsing (amounts, : separators) is up to you.

Custom conditions

The ConditionHandler interface mirrors rewards — type() plus a check(player, value) that returns whether the player may accept the quest:

Registering quests from code

registerQuest(...) adds a quest built with QuestDefinition.builder() — the same model the YAML loader produces:

Note that acceptExpire/activeExpire are milliseconds here (-1 = no limit), unlike the seconds used in quests.yml.

To hand a quest to a player programmatically:

This goes through the same pipeline as clicking the quest board — limits and conditions are checked, so it can fail silently. For unconditional grants, mirror the /quests force give admin command instead.

Events

Two Bukkit events cover the leveling system:

PlayerXpGainEvent

Fires before quest XP is applied. Cancellable, and the amount is mutable — this is the hook for custom XP boosters:

Getters: getPlayer(), getAmount() / setAmount(double), getOriginalAmount(), getLevel(), getCurrentXp().

PlayerLevelUpEvent

Fires once per level gained (a big XP grant can fire it several times in a row). Not cancellable — it's a notification:

Getters: getPlayer(), getOldLevel(), getNewLevel().

Per-player stat modifiers

A QuestUserModifier lets you adjust a player's computed limits and multipliers — the same numbers the level bonuses and premium pass feed into:

The MutableQuestUser exposes maxAccepted, maxActive, dailyBoardSize, xpMultiplier and rewardMultiplier. Modifiers run after the base + per-level values are computed; premium bonuses are applied on top of the result.

The computed user object is cached. If your modifier's inputs change at runtime (a rank purchase, a toggled booster), call McQuests.getInstance().getQuestUserService().invalidate(player) to force a rebuild.

Built-in trigger constants

All built-in trigger IDs are available as constants in com.mongenscave.mcquests.api.trigger.Triggers (Triggers.BLOCK_BREAK, Triggers.KILL_MYTHIC_MOB, ...). Use them instead of constructing ObjectiveTrigger by hand when firing or comparing built-in triggers — see How to Create a Quest for the full list and their semantics.

Last updated