-
Notifications
You must be signed in to change notification settings - Fork 4
Developers
The PBQ code allows developers to easily add new quest executors, tasks, or rewards, since they all are CatalogTypes.
You need to add PBQ to your workspace, you can do it by using jitpack:
dependencies {
...
compile 'com.github.Eufranio:PixelBuilt-Quests:api7-SNAPSHOT'
}
repositories {
...
maven { url 'https://jitpack.io' }
}
Quests executors, tasks and rewards are registered in almost the same way, so we'll be using a new task registration as example.
First, we'll start extending the base class of the type, BaseTask<OurTask>
in this case, so class OurTask extends BaseTask<OurTask>
.
You must annotate this class with @ConfigSerializable
, because it will be used to generate the default object config. Since it's a @ConfigSerializable
class, you can add default fields and annotate them with @Setting
so they're saved and loaded from the configs.
There are 2 methods on BaseTask
, and you must implement both to check if the player can complete the task, and complete the task itself. Take a look at the default implementations if you're not sure what they do. The same goes for the other type implementations.
Each supported type has it's CatalogType representation. So BaseTask
has TaskType
, BaseReward
has RewardType
and etc. You must now register a new catalog entry of the type that you're creating. Since we created a BaseTask, we need to register a new TaskType
on Sponge with our content.
You can do it listening by the generic register event on your plugin, and then registering a new Type for the object that we just made, like:
@Listener
public void onRegister(GameRegistryEvent.Register<TaskType> event) {
event.register(new TaskType("our_task", "Our Custom Task", OurTask.class));
}
If registering multiple types (like reward and tasks for example), make sure to have 1 listener for each type!
If you did everything correctly, your objects should appear inside their respective folder (pbq/tasks/our_task.conf
for example) and the content should be ready for use!