Research API

The interface is static. To access the research api is as simple as

TechManager.functionName();

Tech addPoints(Player player, int points)

Tech addPoints(String playerName, int points)

Add research points to that player. If the sum is greater than the current research cost then the research is learned and applied automatically. Returns technology learned, null if not. The learned tech is persisted.

boolean setPoints(Player player, int points)

Manually set the research points of a player. If the sum is greater than the current research cost then the research is learned and applied automatically. Returns true if a technology is learned, false if not. The learned tech is persisted.

void applyLearnedTech(Player player, Tech tech)

Applies the effect of learning a tech, but does not persist it.

void addTech(Player player, Tech tech)

void addTech(Player player, Tech tech)**

Manually add, implement, and persist a given technology.

void setTech(Player player, Tech[] techs)

Replaces a player's learned tech with a given list. The new tech is applies appropriately. Useful for situations where a player joins a town.

boolean startResearch(Player player, String techName)

boolean startResearch(Player player, Tech tech)**

Primary method for starting new research. If there is current research then all progress is lost. Returns true if the research started successfully.

boolean canResearch(Player player, Tech tech)

Returns boolean if the technology is available to the player.

ArrayList<Tech> getAvailableTech(Player player)

returns an ArrayList<Tech> of technology that is available to the player based on their current research.

ArrayList<Tech> getResearched(Player player)

Returns a list of technology the player has already learned.

int getPoints(Player player)

A player's current research point

Tech getCurrentResearch(Player player)

A player's current research.

NOTE: The following functions are low level and probably not required for your plugin. They are available on the off chance you are trying to do something fancy.

initPlayer(Player player)

Initializes permissions for a player. This is called onPlayerJoin if the player has the permission node "research." At the moment this needs to be called manually if the permission is given while the player is online.

unloadPlayer(Player player)

Disables tech tree mechanics on a player and unloaded them from memory. Called automatically on playerquit events.

getSQLPlayer(Player player)

getSQLPlayer(String playerName)

Returns the low level persistence object.


Comments

Posts Quoted:
Reply
Clear All Quotes