mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
parent
e7e62b8d40
commit
2b9b5df1ee
@ -28,6 +28,7 @@ Version 1.5.01-dev
|
||||
= Fixed bug with setting custom names and lore in treasures config
|
||||
= Fixed bug which would cause a NullPointerException with getFlowerAndGrassXp()
|
||||
! Changed SecondaryAbilityEvent to implement Cancellable and it now gets fired for damage related secondary abilities
|
||||
! Changed the way mcMMO handles bonus damage, updated for the new damage event API
|
||||
! Changed player data saving. Save tasks are now asynchronous
|
||||
! Vanished players no longer get hit by AoE effects
|
||||
! Changed Alchemy config option 'Prevent_Hopper_Transfer' renamed to 'Prevent_Hopper_Transfer_Ingredients'
|
||||
|
@ -65,7 +65,7 @@ public class ArcheryCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canDaze) {
|
||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
|
||||
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeBonusDamage)));
|
||||
}
|
||||
|
||||
if (canRetrieve) {
|
||||
|
@ -134,7 +134,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
reason.add("Skills.Acrobatics.Daze.MaxBonusLevel should be at least 1!");
|
||||
}
|
||||
|
||||
if (getDazeModifier() < 0) {
|
||||
if (getDazeBonusDamage() < 0) {
|
||||
reason.add("Skills.Acrobatics.Daze.BonusDamage should be at least 0!");
|
||||
}
|
||||
|
||||
@ -714,7 +714,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
||||
public double getSkillShotBonusMax() { return config.getDouble("Skills.Archery.SkillShot.MaxBonus", 2.0D); }
|
||||
public double getSkillShotDamageMax() { return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D); }
|
||||
|
||||
public double getDazeModifier() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }
|
||||
public double getDazeBonusDamage() { return config.getDouble("Skills.Archery.Daze.BonusDamage", 4.0D); }
|
||||
|
||||
public double getForceMultiplier() { return config.getDouble("Skills.Archery.ForceMultiplier", 2.0D); }
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class Archery {
|
||||
public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax();
|
||||
public static double skillShotMaxBonusDamage = AdvancedConfig.getInstance().getSkillShotDamageMax();
|
||||
|
||||
public static double dazeModifier = AdvancedConfig.getInstance().getDazeModifier();
|
||||
public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage();
|
||||
|
||||
public static final double DISTANCE_XP_MULTIPLIER = 0.025;
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
@ -18,7 +16,6 @@ import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class ArcheryManager extends SkillManager {
|
||||
@ -70,9 +67,8 @@ public class ArcheryManager extends SkillManager {
|
||||
* Handle the effects of the Daze ability
|
||||
*
|
||||
* @param defender The {@link Player} being affected by the ability
|
||||
* @param arrow The {@link Arrow} that was fired
|
||||
*/
|
||||
public double daze(Player defender, Arrow arrow) {
|
||||
public double daze(Player defender) {
|
||||
if (!SkillUtils.activationSuccessful(SecondaryAbility.DAZE, getPlayer(), getSkillLevel(), activationChance)) {
|
||||
return 0;
|
||||
}
|
||||
@ -91,24 +87,21 @@ public class ArcheryManager extends SkillManager {
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||
}
|
||||
|
||||
return CombatUtils.callFakeDamageEvent(arrow, defender, DamageCause.PROJECTILE, Archery.dazeModifier);
|
||||
return Archery.dazeBonusDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the effects of the Skill Shot ability
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
* @param arrow The {@link Arrow} that was fired
|
||||
*/
|
||||
public double skillShot(LivingEntity target, double damage, Arrow arrow) {
|
||||
public double skillShot(double damage) {
|
||||
if (!SkillUtils.activationSuccessful(SecondaryAbility.SKILL_SHOT, getPlayer())) {
|
||||
return damage;
|
||||
}
|
||||
|
||||
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
|
||||
double archeryBonus = Math.min(damage * damageBonusPercent, Archery.skillShotMaxBonusDamage);
|
||||
|
||||
return CombatUtils.callFakeDamageEvent(arrow, target, DamageCause.PROJECTILE, archeryBonus);
|
||||
return Math.min(damage * damageBonusPercent, Archery.skillShotMaxBonusDamage);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package com.gmail.nossr50.skills.axes;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@ -49,17 +52,13 @@ public class AxesManager extends SkillManager {
|
||||
|
||||
/**
|
||||
* Handle the effects of the Axe Mastery ability
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
*/
|
||||
public double axeMastery(LivingEntity target) {
|
||||
public double axeMastery() {
|
||||
if (!SkillUtils.activationSuccessful(SecondaryAbility.AXE_MASTERY, getPlayer())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double axeBonus = Math.min(getSkillLevel() / (Axes.axeMasteryMaxBonusLevel / Axes.axeMasteryMaxBonus), Axes.axeMasteryMaxBonus);
|
||||
|
||||
return CombatUtils.callFakeDamageEvent(getPlayer(), target, axeBonus);
|
||||
return Math.min(getSkillLevel() / (Axes.axeMasteryMaxBonusLevel / Axes.axeMasteryMaxBonus), Axes.axeMasteryMaxBonus);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +85,7 @@ public class AxesManager extends SkillManager {
|
||||
damage = (damage * Axes.criticalHitPVEModifier) - damage;
|
||||
}
|
||||
|
||||
return CombatUtils.callFakeDamageEvent(player, target, damage);
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,7 +132,7 @@ public class AxesManager extends SkillManager {
|
||||
}
|
||||
}
|
||||
|
||||
return CombatUtils.callFakeDamageEvent(player, target, Axes.greaterImpactBonusDamage);
|
||||
return Axes.greaterImpactBonusDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -142,7 +141,7 @@ public class AxesManager extends SkillManager {
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*/
|
||||
public void skullSplitterCheck(LivingEntity target, double damage) {
|
||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill);
|
||||
public void skullSplitterCheck(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
|
||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, modifiers, skill);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class TamingManager extends SkillManager {
|
||||
@ -113,9 +112,8 @@ public class TamingManager extends SkillManager {
|
||||
*
|
||||
* @param target The LivingEntity to apply Gore on
|
||||
* @param damage The initial damage
|
||||
* @param wolf The wolf using the ability
|
||||
*/
|
||||
public double gore(LivingEntity target, double damage, Wolf wolf) {
|
||||
public double gore(LivingEntity target, double damage) {
|
||||
if (!SkillUtils.activationSuccessful(SecondaryAbility.GORE, getPlayer(), getSkillLevel(), activationChance)) {
|
||||
return 0;
|
||||
}
|
||||
@ -129,11 +127,11 @@ public class TamingManager extends SkillManager {
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||
|
||||
damage = (damage * Taming.goreModifier) - damage;
|
||||
return CombatUtils.callFakeDamageEvent(wolf, target, damage);
|
||||
return damage;
|
||||
}
|
||||
|
||||
public double sharpenedClaws(LivingEntity target, Wolf wolf) {
|
||||
return CombatUtils.callFakeDamageEvent(wolf, target, Taming.sharpenedClawsBonusDamage);
|
||||
public double sharpenedClaws() {
|
||||
return Taming.sharpenedClawsBonusDamage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,13 +1,10 @@
|
||||
package com.gmail.nossr50.skills.unarmed;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.SmoothBrick;
|
||||
@ -25,7 +22,6 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class UnarmedManager extends SkillManager {
|
||||
@ -124,28 +120,23 @@ public class UnarmedManager extends SkillManager {
|
||||
/**
|
||||
* Handle the effects of the Berserk ability
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*/
|
||||
public double berserkDamage(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
|
||||
public double berserkDamage(double damage) {
|
||||
damage = (damage * Unarmed.berserkDamageModifier) - damage;
|
||||
|
||||
return CombatUtils.callFakeDamageEvent(getPlayer(), target, damage, modifiers);
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the effects of the Iron Arm ability
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
*/
|
||||
public double ironArm(LivingEntity target, Map<DamageModifier, Double> modifiers) {
|
||||
public double ironArm() {
|
||||
if (!SkillUtils.activationSuccessful(SecondaryAbility.IRON_ARM, getPlayer())) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double unarmedBonus = Math.min(Unarmed.ironArmMinBonusDamage + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
||||
|
||||
return CombatUtils.callFakeDamageEvent(getPlayer(), target, unarmedBonus, modifiers);
|
||||
return Math.min(Unarmed.ironArmMinBonusDamage + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
@ -78,6 +77,7 @@ public final class CombatUtils {
|
||||
private static void processAxeCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
|
||||
double initialDamage = event.getDamage();
|
||||
double finalDamage = initialDamage;
|
||||
Map<DamageModifier, Double> modifiers = getModifiers(event);
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
AxesManager axesManager = mcMMOPlayer.getAxesManager();
|
||||
@ -87,7 +87,7 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (axesManager.canUseAxeMastery()) {
|
||||
finalDamage += axesManager.axeMastery(target);
|
||||
finalDamage += axesManager.axeMastery();
|
||||
}
|
||||
|
||||
if (axesManager.canCriticalHit(target)) {
|
||||
@ -102,17 +102,16 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (axesManager.canUseSkullSplitter(target)) {
|
||||
axesManager.skullSplitterCheck(target, initialDamage);
|
||||
axesManager.skullSplitterCheck(target, initialDamage, modifiers);
|
||||
}
|
||||
|
||||
event.setDamage(finalDamage);
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
startGainXp(mcMMOPlayer, target, SkillType.AXES);
|
||||
}
|
||||
|
||||
private static void processUnarmedCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
|
||||
double initialDamage = event.getDamage();
|
||||
double finalDamage = initialDamage;
|
||||
Map<DamageModifier, Double> modifiers = getModifiers(event);
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||
@ -122,18 +121,18 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (unarmedManager.canUseIronArm()) {
|
||||
finalDamage += unarmedManager.ironArm(target, modifiers);
|
||||
finalDamage += unarmedManager.ironArm();
|
||||
}
|
||||
|
||||
if (unarmedManager.canUseBerserk()) {
|
||||
finalDamage += unarmedManager.berserkDamage(target, initialDamage, modifiers);
|
||||
finalDamage += unarmedManager.berserkDamage(initialDamage);
|
||||
}
|
||||
|
||||
if (unarmedManager.canDisarm(target)) {
|
||||
unarmedManager.disarmCheck((Player) target);
|
||||
}
|
||||
|
||||
event.setDamage(finalDamage);
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
|
||||
}
|
||||
|
||||
@ -149,14 +148,14 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (tamingManager.canUseSharpenedClaws()) {
|
||||
finalDamage += tamingManager.sharpenedClaws(target, wolf);
|
||||
finalDamage += tamingManager.sharpenedClaws();
|
||||
}
|
||||
|
||||
if (tamingManager.canUseGore()) {
|
||||
finalDamage += tamingManager.gore(target, initialDamage, wolf);
|
||||
finalDamage += tamingManager.gore(target, initialDamage);
|
||||
}
|
||||
|
||||
event.setDamage(finalDamage);
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
startGainXp(mcMMOPlayer, target, SkillType.TAMING);
|
||||
}
|
||||
|
||||
@ -180,11 +179,11 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (archeryManager.canSkillShot()) {
|
||||
finalDamage += archeryManager.skillShot(target, initialDamage, arrow);
|
||||
finalDamage += archeryManager.skillShot(initialDamage);
|
||||
}
|
||||
|
||||
if (archeryManager.canDaze(target)) {
|
||||
finalDamage += archeryManager.daze((Player) target, arrow);
|
||||
finalDamage += archeryManager.daze((Player) target);
|
||||
}
|
||||
|
||||
if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canRetrieveArrows()) {
|
||||
@ -193,7 +192,7 @@ public final class CombatUtils {
|
||||
|
||||
archeryManager.distanceXpBonus(target, arrow);
|
||||
|
||||
event.setDamage(finalDamage);
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY, arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble());
|
||||
}
|
||||
|
||||
@ -237,7 +236,7 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (SkillType.SWORDS.getPermissions(player)) {
|
||||
processSwordCombat(target, player, event.getDamage());
|
||||
processSwordCombat(target, player, event);
|
||||
}
|
||||
}
|
||||
else if (ItemUtils.isAxe(heldItem)) {
|
||||
@ -318,6 +317,7 @@ public final class CombatUtils {
|
||||
* @param target LivingEntity which to attempt to damage
|
||||
* @param damage Amount of damage to attempt to do
|
||||
*/
|
||||
@Deprecated
|
||||
public static void dealDamage(LivingEntity target, double damage) {
|
||||
dealDamage(target, damage, DamageCause.CUSTOM, null);
|
||||
}
|
||||
@ -357,6 +357,7 @@ public final class CombatUtils {
|
||||
* @param damage Amount of damage to attempt to do
|
||||
* @param attacker Player to pass to event as damager
|
||||
*/
|
||||
@Deprecated
|
||||
public static void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker) {
|
||||
if (target.isDead()) {
|
||||
return;
|
||||
@ -609,7 +610,7 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
public static double callFakeDamageEvent(Entity attacker, Entity target, double damage, Map<DamageModifier, Double> modifiers) {
|
||||
return callFakeDamageEvent(attacker, target, DamageCause.ENTITY_ATTACK, scaleModifiers(damage, modifiers));
|
||||
return callFakeDamageEvent(attacker, target, DamageCause.ENTITY_ATTACK, getScaledModifiers(damage, modifiers));
|
||||
}
|
||||
|
||||
public static double callFakeDamageEvent(Entity attacker, Entity target, DamageCause cause, Map<DamageModifier, Double> modifiers) {
|
||||
@ -623,7 +624,7 @@ public final class CombatUtils {
|
||||
return damageEvent.getFinalDamage();
|
||||
}
|
||||
|
||||
public static Map<DamageModifier, Double> getModifiers(EntityDamageEvent event) {
|
||||
private static Map<DamageModifier, Double> getModifiers(EntityDamageEvent event) {
|
||||
Map<DamageModifier, Double> modifiers = new HashMap<DamageModifier, Double>();
|
||||
for (DamageModifier modifier : DamageModifier.values()) {
|
||||
modifiers.put(modifier, event.getDamage(modifier));
|
||||
@ -632,7 +633,7 @@ public final class CombatUtils {
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
public static Map<DamageModifier, Double> scaleModifiers(double damage, Map<DamageModifier, Double> modifiers) {
|
||||
private static Map<DamageModifier, Double> getScaledModifiers(double damage, Map<DamageModifier, Double> modifiers) {
|
||||
Map<DamageModifier, Double> scaledModifiers = new HashMap<DamageModifier, Double>();
|
||||
|
||||
for (DamageModifier modifier : DamageModifier.values()) {
|
||||
@ -647,6 +648,28 @@ public final class CombatUtils {
|
||||
return scaledModifiers;
|
||||
}
|
||||
|
||||
public static EntityDamageByEntityEvent applyScaledModifiers(double initialDamage, double finalDamage, EntityDamageByEntityEvent event) {
|
||||
// No additional damage
|
||||
if (initialDamage == finalDamage) {
|
||||
return event;
|
||||
}
|
||||
|
||||
for (DamageModifier modifier : DamageModifier.values()) {
|
||||
if (!event.isApplicable(modifier)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (modifier == DamageModifier.BASE) {
|
||||
event.setDamage(modifier, finalDamage);
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setDamage(modifier, finalDamage / initialDamage * event.getDamage(modifier));
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upgrade tier of the item in hand.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user