diff --git a/Changelog.txt b/Changelog.txt
index 57d4ec17b..5258dc435 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -6,6 +6,11 @@ Key:
= Fix
! Change
- Removal
+Version 2.1.7
+ (API) Added addXpFromBlocks to ExperienceAPI to help make adding XP for a player easier
+ (API) Added addXpFromBlocksBySkill to ExperienceAPI to help make adding XP for a player easier
+ (API) Added addXpFromBlock to ExperienceAPI to help make adding XP for a player easier
+ (API) Added addXpFromBlockBySkill to ExperienceAPI to help make adding XP for a player easier
Version 2.1.6
Fixed a bug where Arcane Salvage could never fail
diff --git a/pom.xml b/pom.xml
index 4275f438f..79c570030 100755
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
com.gmail.nossr50.mcMMO
mcMMO
- 2.1.6
+ 2.1.7-SNAPSHOT
mcMMO
https://github.com/mcMMO-Dev/mcMMO
diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java
index 7eca726c1..5b2f6f3c4 100644
--- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java
+++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java
@@ -11,9 +11,12 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree;
+import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.player.UserManager;
+import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
+import java.util.ArrayList;
import java.util.Set;
import java.util.UUID;
@@ -1010,6 +1013,74 @@ public final class ExperienceAPI {
return mcMMO.getFormulaManager().getCachedXpToLevel(level, getFormulaType(formulaType));
}
+ /**
+ * Will add the appropriate type of XP from the block to the player based on the material of the blocks given
+ * @param blockStates the blocks to reward XP for
+ * @param mcMMOPlayer the target player
+ */
+ public static void addXpFromBlocks(ArrayList blockStates, McMMOPlayer mcMMOPlayer)
+ {
+ for(BlockState bs : blockStates)
+ {
+ for(PrimarySkillType skillType : PrimarySkillType.values())
+ {
+ if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0)
+ {
+ mcMMOPlayer.addXp(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()));
+ }
+ }
+ }
+ }
+
+ /**
+ * Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType
+ * @param blockStates the blocks to reward XP for
+ * @param mcMMOPlayer the target player
+ * @param skillType target primary skill
+ */
+ public static void addXpFromBlocksBySkill(ArrayList blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType)
+ {
+ for(BlockState bs : blockStates)
+ {
+ if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0)
+ {
+ mcMMOPlayer.addXp(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()));
+ }
+ }
+ }
+
+ /**
+ * Will add the appropriate type of XP from the block to the player based on the material of the blocks given
+ * @param blockState The target blockstate
+ * @param mcMMOPlayer The target player
+ */
+ public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer)
+ {
+ for(PrimarySkillType skillType : PrimarySkillType.values())
+ {
+ if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0)
+ {
+ mcMMOPlayer.addXp(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()));
+ }
+ }
+ }
+
+ /**
+ * Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType
+ * @param blockState The target blockstate
+ * @param mcMMOPlayer The target player
+ * @param skillType target primary skill
+ */
+ public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType)
+ {
+ if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0)
+ {
+ mcMMOPlayer.addXp(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()));
+ }
+ }
+
+
+
// Utility methods follow.
private static void addOfflineXP(UUID playerUniqueId, PrimarySkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerUniqueId);