Skip to content
Aria edited this page Sep 23, 2020 · 5 revisions

The TechTree API

Currently the API allows you to register your own Rewards and Requirements. Unique Events will also be implemented at a later date and will end up being documented here.

A few examples of Rewards and Requirements can be found here.

Custom Rewards & Requirements

To create a custom Reward or Requirement you'll need to create a new class which implements TechReward or TechRequirement respectively.
You'll need to overwrite different methods to define how the reward/requirement will work:

Rewards

reward(Player) runs when the entry in context is unlocked
setup(TechEntry, LineConfig) is called when loading the reward from config.
(This is usually where you load the different arguments from the Line Configuration)

Requirements

met(TechEntry, Player) returns true if the requirements are met and false if they don't.
display(TechEntry, Player, boolean) returns the string to represent the requirement in the entry lore.
It's recommended to use FormatManager.get().getFormat(key).getFormat(boolean) to use the locked/unlocked formatting feature.
fulfill(TechEntry, Player) runs when the entry in context is unlocked. Used to withdraw money or to take required items, etc.
setup(TechEntry, LineConfig) is called when loading the requirement from config.
(This is usually where you load the different arguments from the Line Configuration)

Registering Rewards & Requirements

To register your Rewards and Requirements, call APIManager.get().addRequirement() and APIManager.get().addReward() respectively. It's recommended to register your rewards and requirements in the onLoad() method.

Clone this wiki locally