From 3d9c03c0c8db607f62fcab3a21fd5f4bdef95611 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Jun 2012 08:02:31 -0400 Subject: [PATCH] Added a few requested functions to the ExperienceAPI --- .../com/gmail/nossr50/api/ExperienceAPI.java | 39 +++++++++++++++++++ .../nossr50/datatypes/PlayerProfile.java | 4 ++ .../nossr50/listeners/EntityListener.java | 2 + 3 files changed, 45 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index 4307ff18f..24f2666ff 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -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. + *
+ * 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. + *
+ * 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. + *
+ * 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); + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index 9e8573f52..e837a691d 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -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); } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 35a163ff0..e56c58d8f 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -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) {