mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Add ExperienceAPI::addCombatXP
This commit is contained in:
parent
15e4dbfd92
commit
fe2b7a8d61
@ -2,6 +2,7 @@ Version 2.1.128
|
|||||||
The first rank of Iron Arm for Unarmed now only gives 1.5 bonus damage instead of 4 (other ranks are the same as before)
|
The first rank of Iron Arm for Unarmed now only gives 1.5 bonus damage instead of 4 (other ranks are the same as before)
|
||||||
Blast Mining nerf reverted
|
Blast Mining nerf reverted
|
||||||
Fixed a few locale errors with commands
|
Fixed a few locale errors with commands
|
||||||
|
(API) Added ExperienceAPI::addCombatXP for adding combat XP to players, signature may change so its deprecated for now
|
||||||
|
|
||||||
Version 2.1.127
|
Version 2.1.127
|
||||||
Child Skills now have XP bars, they are hidden by default
|
Child Skills now have XP bars, they are hidden by default
|
||||||
|
@ -12,7 +12,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -35,6 +37,35 @@ public final class ExperienceAPI {
|
|||||||
return PrimarySkillType.getSkill(skillType) != null;
|
return PrimarySkillType.getSkill(skillType) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the task that gives combat XP.
|
||||||
|
* Processes combat XP like mcMMO normally would, so mcMMO will check whether or not the entity should reward XP when giving out the XP
|
||||||
|
*
|
||||||
|
* @param mcMMOPlayer The attacking player
|
||||||
|
* @param target The defending entity
|
||||||
|
* @param primarySkillType The skill being used
|
||||||
|
* @param multiplier final XP result will be multiplied by this
|
||||||
|
* @deprecated Draft API
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static void addCombatXP(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
|
||||||
|
CombatUtils.processCombatXP(mcMMOPlayer, target, primarySkillType, multiplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the task that gives combat XP.
|
||||||
|
* Processes combat XP like mcMMO normally would, so mcMMO will check whether or not the entity should reward XP when giving out the XP
|
||||||
|
*
|
||||||
|
* @param mcMMOPlayer The attacking player
|
||||||
|
* @param target The defending entity
|
||||||
|
* @param primarySkillType The skill being used
|
||||||
|
* @deprecated Draft API
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static void addCombatXP(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType) {
|
||||||
|
CombatUtils.processCombatXP(mcMMOPlayer, target, primarySkillType);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the given skill type string is both valid and not a
|
* Returns whether the given skill type string is both valid and not a
|
||||||
* child skill. (Child skills have no XP of their own, and their level is
|
* child skill. (Child skills have no XP of their own, and their level is
|
||||||
|
@ -87,7 +87,7 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||||
startGainXp(mcMMOPlayer, target, PrimarySkillType.SWORDS);
|
processCombatXP(mcMMOPlayer, target, PrimarySkillType.SWORDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static void strengthDebug(Player player) {
|
// public static void strengthDebug(Player player) {
|
||||||
@ -162,7 +162,7 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||||
startGainXp(mcMMOPlayer, target, PrimarySkillType.AXES);
|
processCombatXP(mcMMOPlayer, target, PrimarySkillType.AXES);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void processUnarmedCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
|
private static void processUnarmedCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
|
||||||
@ -205,7 +205,7 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||||
startGainXp(mcMMOPlayer, target, PrimarySkillType.UNARMED);
|
processCombatXP(mcMMOPlayer, target, PrimarySkillType.UNARMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void processTamingCombat(LivingEntity target, Player master, Wolf wolf, EntityDamageByEntityEvent event) {
|
private static void processTamingCombat(LivingEntity target, Player master, Wolf wolf, EntityDamageByEntityEvent event) {
|
||||||
@ -237,7 +237,7 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||||
startGainXp(mcMMOPlayer, target, PrimarySkillType.TAMING);
|
processCombatXP(mcMMOPlayer, target, PrimarySkillType.TAMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ public final class CombatUtils {
|
|||||||
forceMultiplier = arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble();
|
forceMultiplier = arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble();
|
||||||
|
|
||||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||||
startGainXp(mcMMOPlayer, target, PrimarySkillType.ARCHERY, forceMultiplier * distanceMultiplier);
|
processCombatXP(mcMMOPlayer, target, PrimarySkillType.ARCHERY, forceMultiplier * distanceMultiplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -688,8 +688,15 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType) {
|
/**
|
||||||
startGainXp(mcMMOPlayer, target, primarySkillType, 1.0);
|
* Start the task that gives combat XP.
|
||||||
|
*
|
||||||
|
* @param mcMMOPlayer The attacking player
|
||||||
|
* @param target The defending entity
|
||||||
|
* @param primarySkillType The skill being used
|
||||||
|
*/
|
||||||
|
public static void processCombatXP(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType) {
|
||||||
|
processCombatXP(mcMMOPlayer, target, primarySkillType, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -698,8 +705,9 @@ public final class CombatUtils {
|
|||||||
* @param mcMMOPlayer The attacking player
|
* @param mcMMOPlayer The attacking player
|
||||||
* @param target The defending entity
|
* @param target The defending entity
|
||||||
* @param primarySkillType The skill being used
|
* @param primarySkillType The skill being used
|
||||||
|
* @param multiplier final XP result will be multiplied by this
|
||||||
*/
|
*/
|
||||||
private static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
|
public static void processCombatXP(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
|
||||||
double baseXP = 0;
|
double baseXP = 0;
|
||||||
XPGainReason xpGainReason;
|
XPGainReason xpGainReason;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user