Added a few requested functions to the ExperienceAPI

This commit is contained in:
GJ 2012-06-26 08:02:31 -04:00
parent dd94343d92
commit 3d9c03c0c8
3 changed files with 45 additions and 0 deletions

View File

@ -135,4 +135,43 @@ public final class ExperienceAPI {
public static int getPowerLevel(Player player) {
return Users.getProfile(player).getPowerLevel();
}
/**
* Sets the level of a player in a specific skill type.
* </br>
* This function is designed for API usage.
*
* @param player The player to set the level of
* @param skillType The skill to set the level for
* @param skillLevel The value to set the level to
*/
public static void setLevel(Player player, SkillType skillType, int skillLevel) {
Users.getProfile(player).modifySkill(skillType, skillLevel);
}
/**
* Sets the XP of a player in a specific skill type.
* </br>
* This function is designed for API usage.
*
* @param player The player to set the XP of
* @param skillType The skill to set the XP for
* @param newValue The value to set the XP to
*/
public static void setXP(Player player, SkillType skillType, int newValue) {
Users.getProfile(player).setSkillXPLevel(skillType, newValue);
}
/**
* Sets the XP of a player in a specific skill type.
* </br>
* This function is designed for API usage.
*
* @param player The player to change the XP of
* @param skillType The skill to change the XP for
* @param xp The amount of XP to remove
*/
public static void removeXP(Player player, SkillType skillType, int xp) {
Users.getProfile(player).removeXP(skillType, xp);
}
}

View File

@ -934,6 +934,10 @@ public class PlayerProfile {
return skillsXp.get(skillType);
}
public void setSkillXPLevel(SkillType skillType, int newValue) {
skillsXp.put(skillType, newValue);
}
public void skillUp(SkillType skillType, int newValue) {
skills.put(skillType, skills.get(skillType) + newValue);
}

View File

@ -181,6 +181,7 @@ public class EntityListener implements Listener {
*/
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplosionPrime(ExplosionPrimeEvent event) {
System.out.println("ExplosionPrimeEvent fired!" + System.currentTimeMillis());
Entity entity = event.getEntity();
if (entity instanceof TNTPrimed) {
@ -203,6 +204,7 @@ public class EntityListener implements Listener {
*/
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEnitityExplode(EntityExplodeEvent event) {
System.out.println("ExplosionPrimeEvent fired!" + System.currentTimeMillis());
Entity entity = event.getEntity();
if (event.getEntity() instanceof TNTPrimed) {