Developer API

MyZ features a useful developer API that allows other plugins to access its internal methods. It consists of both events and an API interface.
Using the API Events
MyZ events can be found on the GitHub page and are rather self evident. An important event to take note of is the PlayerGetMyZAchievementEvent.
PlayerGetMyZAchievementEvent
MyZ allows you to create custom achievements in the achievements.yml configuration file. However, in order to ensure that these achievements are as customizable as possible, they are interfaced with the PlayerGetMyZAchievementEvent. Here's an example.
thirsty:
name: Staying Hydrated
description: drink 20 bottles of water
requirements:
kills:
zombie: 0
pigman: 0
player: 0
giant: 0
heals:
self:
bleeding: 0
infection: 0
other: 0
drinks: 20
revive:
other: 0
self: 0
deaths: 0
deathstate:
zombie: 0
ghost: 0
friends: 0
This entry represents a MyZAchievement named 'Staying Hydrated'. It is obtained as soon as a player has consumed 20 bottles of water. Upon fulfilling this goal, a PlayerGetMyZAchievementEvent will be fired. However, on its own, this will be the only effect. In order to give a reward for completing this event, a Listener must be set up to listen for this event. For instance, MyZ is setup with a Listener for this event. Upon receiving it, it makes a call to MyZAPI.getStartingKitManager() to add a water bottle to the players spawn kit.
The possibilities are endless as to what effects a MyZAchievement has using the MyZGetAchievementEvent.
MyZAPI
The MyZAPI provides basic access to the rest of the MyZ interfacing methods. It needn't be constructed - it can simply be referenced statically. In order to gain access to the API calls, add the latest MyZ JAR as a required library and make a static call to obtain whatever Manager you need access to. For instance:
MyZAPI.getVisibilityManager().overloadVisibility(<Player>, <VisibilityCause>);
Using the MyZ API is really quite simple and provides tremendous access to a large array of key MyZ calls.
Comments