Custom requirements
A worked example: a tiktok_follow requirement that only passes when the player follows
a given TikTok account.
-
Implement a
Section titled “Implement a Requirement”RequirementRequirement.check(...)returns aCompletableFuture<RequirementResult>, so network calls — a social-follow check, a web API — run off the main thread. ReturnRequirementResult.satisfied(description)or.unsatisfied(description).import net.kyori.adventure.text.Componentimport zone.vao.claimo.requirement.Requirementimport zone.vao.claimo.requirement.RequirementContextimport zone.vao.claimo.requirement.RequirementResultimport java.util.concurrent.CompletableFutureclass TikTokFollowRequirement(private val account: String) : Requirement {override fun check(context: RequirementContext): CompletableFuture<RequirementResult> {return myTikTokClient.isFollowing(context.player.uniqueId, account).thenApply { follows ->val description = Component.text("Follow @$account on TikTok")if (follows) RequirementResult.satisfied(description)else RequirementResult.unsatisfied(description)}}} -
Register the type
Section titled “Register the type”From your plugin’s
onEnable:import zone.vao.claimo.ClaimoApiimport zone.vao.claimo.requirement.RequirementInputClaimoApi.registerRequirement("tiktok_follow",{ cfg -> TikTokFollowRequirement(cfg.getString("account")!!) },// Optional: makes the requirement appear (and be configurable) in /code create.listOf(RequirementInput.TextInput("account", "TikTok account")),)cfgis theRequirementConfigfor that entry; read your own parameters from it withgetString,getInt,getLong,getDouble,getBoolean,getStringListandhas. -
Use it in a voucher
Section titled “Use it in a voucher”vouchers/social_reward.yml cmd: "give %player% diamond 5"requirements:- type: tiktok_followaccount: vao.zone
Showing up in the creator
Section titled “Showing up in the creator”The optional inputs list tells the in-game creator what fields to render for your type
and which config keys to write:
| Descriptor | Renders |
|---|---|
RequirementInput.TextInput(key, label) |
A text field. |
RequirementInput.NumberInput(key, label) |
A number field. |
RequirementInput.BoolInput(key, label) |
An on/off toggle. |
Lazy resolution
Section titled “Lazy resolution”Requirements are resolved lazily on each redeem, so registering a type after Claimo
has already loaded its config — the normal case for addons — works fine. No load-order
gymnastics needed beyond depend: [Claimo].