SeasonForge logoSeasonForge

Developer API

Feeding SeasonForge quests from your own plugin, reading Battle Pass state, and listening to its events.

SeasonForge has a small public API so another plugin can add quest types, push progress, read a player's Battle Pass state and react to what happens. Everything lives in cc.arrowtan.seasonforge.api and cc.arrowtan.seasonforge.api.event. Nothing else in the jar is meant to be touched.

Setup

Compile against the SeasonForge jar as a provided (Maven) or compileOnly (Gradle) dependency, it is not published to a repository. Then add it to your plugin.yml:

softdepend: [SeasonForge]

Get the API once SeasonForge is enabled:

import cc.arrowtan.seasonforge.api.SeasonForgeAPI;
import cc.arrowtan.seasonforge.api.SeasonForgeProvider;

if (SeasonForgeProvider.available()) {
    SeasonForgeAPI api = SeasonForgeProvider.get();
}

SeasonForgeProvider.get() throws IllegalStateException while SeasonForge is not enabled. Use available() to check first.

Adding quest types

Register your objectives in onEnable. Objectives must be namespaced (myplugin:boss_kill), otherwise registerObjective throws IllegalArgumentException. Registered objectives show up in tab completion and server owners can use them as a quest type:.

api.registerObjective(this, "myplugin:boss_kill", false);   // adds up
api.registerObjective(this, "myplugin:best_wave", true);    // keeps the highest value
api.registerObjectives(this, "myplugin", List.of("win", "participate"));

The highest flag decides how progress is kept: false adds every report to the total, true keeps the highest value reported (for "reach wave 30" style quests, where amount is the value to reach).

Then report progress whenever it happens:

api.progress(player, "myplugin:boss_kill", 1, "dragon");
api.progressHighest(player, "myplugin:best_wave", 17);
api.progressCurrent(player, "myplugin:rating", 1450);

progressCurrent sets the quest to the value reported, even when it is lower than before, for ratings and other values that can drop. A completed quest stays completed.

The trailing context strings are matched against each quest's target, case-insensitive and with a minecraft: prefix ignored. A quest with no target accepts any context. For ItemsAdder content pass itemsadder:namespace:id as one of the values.

# a server owner's quests.yml
dragon_hunter:
  type: myplugin:boss_kill
  target: dragon
  amount: 3
  battlepass-xp: 1500
  reset: WEEKLY

Progress calls are safe from any thread, they are moved to the main thread. They do nothing while no season runs, while a season is switching, or while the player's data is still loading. Premium only quests are skipped for players without premium, and completed quests stop counting until they reset.

Quests using an objective nobody registered still load and still move through /battlepass admin progress, so registering is recommended but not required.

Reading state

MethodReturns
Optional<String> activeSeason()The running season's id
int level(Player)Current level, 0 when not loaded
int maxLevel()The running season's max level
long xp(Player)XP into the current level
long xpRequired(Player)XP the next level needs, 0 at max level
boolean premium(Player)Owns premium, by any source
double questProgress(Player, String questId)Progress on a quest in its current period
boolean questCompleted(Player, String questId)Completed in its current period
int unclaimedRewards(Player)Rewards waiting on both tracks
void giveXp(Player, long amount, String source)Gives Battle Pass XP, with level ups. Fires BattlePassXpGainEvent.

The read methods only see online players.

Events

All in cc.arrowtan.seasonforge.api.event, fired on the main thread.

EventWhenGives you
BattlePassXpGainEventBefore a player gains Battle Pass XP. Cancellable, amount editable.getPlayer(), getAmount(), setAmount(long), getSource()
BattlePassLevelUpEventOnce per level gainedgetPlayer(), getOldLevel(), getNewLevel()
QuestCompleteEventA quest is completedgetPlayer(), getQuestId(), getObjective(), getSeasonId()
RewardClaimEventOnce per reward claimed, after it is givengetPlayer(), getLevel(), isPremium(), getSeasonId()
PremiumUnlockEventA player unlocks premiumgetPlayer(), getSource() (purchase or command), getSeasonId()
SeasonStartEventA season startsgetSeasonId()
SeasonEndEventA season endsgetSeasonId()

getSource() on BattlePassXpGainEvent is quest:<quest id> for quest XP, reward for XP from a reward or shop item, command for /battlepass admin xp give, or whatever your plugin passed to giveXp (api when null).

A double XP weekend in a few lines:

@EventHandler
public void onXp(BattlePassXpGainEvent event) {
    if (doubleXp) {
        event.setAmount(event.getAmount() * 2);
    }
}

BattlePassLevelUpEvent fires once for every level, so a jump from 3 to 6 fires three times (3 to 4, 4 to 5, 5 to 6). Levels set by /battlepass admin level set fire no event.

On this page