mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 05:06:45 +01:00
Added 4 new API methods for adding XP to a player based on blocks
This commit is contained in:
parent
c839837d7a
commit
14e5998aa0
@ -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
|
||||
|
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.6</version>
|
||||
<version>2.1.7-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
|
@ -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<BlockState> 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<BlockState> 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);
|
||||
|
Loading…
Reference in New Issue
Block a user