mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Let's do this the right way.
This commit is contained in:
parent
59f545d5ce
commit
6bfc1b84de
@ -1,9 +1,11 @@
|
|||||||
package com.gmail.nossr50.skills.archery;
|
package com.gmail.nossr50.skills.archery;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
@ -15,6 +17,7 @@ import com.gmail.nossr50.skills.SkillManager;
|
|||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class ArcheryManager extends SkillManager {
|
public class ArcheryManager extends SkillManager {
|
||||||
@ -68,26 +71,26 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public double dazeCheck(Player defender, double damage) {
|
public void daze(Player defender, Arrow arrow) {
|
||||||
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
|
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
|
||||||
Location dazedLocation = defender.getLocation();
|
return;
|
||||||
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
|
|
||||||
|
|
||||||
defender.teleport(dazedLocation);
|
|
||||||
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
|
|
||||||
|
|
||||||
if (UserManager.getPlayer(defender).useChatNotifications()) {
|
|
||||||
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mcMMOPlayer.useChatNotifications()) {
|
|
||||||
getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return damage + Archery.dazeModifier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return damage;
|
Location dazedLocation = defender.getLocation();
|
||||||
|
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
|
||||||
|
|
||||||
|
defender.teleport(dazedLocation);
|
||||||
|
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
|
||||||
|
|
||||||
|
if (UserManager.getPlayer(defender).useChatNotifications()) {
|
||||||
|
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
|
||||||
|
}
|
||||||
|
|
||||||
|
CombatUtils.dealDamage(defender, Archery.dazeModifier, DamageCause.PROJECTILE, arrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,10 +99,10 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
* @return the modified event damage
|
* @return the modified event damage
|
||||||
*/
|
*/
|
||||||
public double skillShotCheck(double damage) {
|
public void skillShot(LivingEntity target, double damage, Arrow arrow) {
|
||||||
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
|
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
|
||||||
double archeryBonus = damage * damageBonusPercent;
|
double archeryBonus = damage * damageBonusPercent;
|
||||||
|
|
||||||
return damage + archeryBonus;
|
CombatUtils.dealDamage(target, archeryBonus, DamageCause.PROJECTILE, arrow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,10 +55,10 @@ public class AxesManager extends SkillManager {
|
|||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
* @return the modified event damage
|
* @return the modified event damage
|
||||||
*/
|
*/
|
||||||
public double axeMasteryCheck(double damage) {
|
public void axeMastery(LivingEntity target) {
|
||||||
double axeBonus = Math.min(getSkillLevel() / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus);
|
double axeBonus = Math.min(getSkillLevel() / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus);
|
||||||
|
|
||||||
return damage + axeBonus;
|
CombatUtils.dealDamage(target, axeBonus, getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,20 +68,25 @@ public class AxesManager extends SkillManager {
|
|||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public double criticalHitCheck(LivingEntity target, double damage) {
|
public void criticalHit(LivingEntity target, double damage) {
|
||||||
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) {
|
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) {
|
||||||
getPlayer().sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
return;
|
||||||
|
|
||||||
if (target instanceof Player) {
|
|
||||||
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
|
||||||
|
|
||||||
return damage * Axes.criticalHitPVPModifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
return damage * Axes.criticalHitPVEModifier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return damage;
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
||||||
|
|
||||||
|
if (target instanceof Player) {
|
||||||
|
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||||
|
|
||||||
|
damage = (damage * Axes.criticalHitPVPModifier) - damage;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
damage = (damage * Axes.criticalHitPVEModifier) - damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
CombatUtils.dealDamage(target, damage, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,29 +116,29 @@ public class AxesManager extends SkillManager {
|
|||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
* @return the modified event damage if the ability was successful, the original event damage otherwise
|
||||||
*/
|
*/
|
||||||
public double greaterImpactCheck(LivingEntity target, double damage) {
|
public void greaterImpact(LivingEntity target) {
|
||||||
if (Axes.greaterImpactChance > Misc.getRandom().nextInt(getActivationChance())) {
|
if (!(Axes.greaterImpactChance > Misc.getRandom().nextInt(getActivationChance()))) {
|
||||||
Player player = getPlayer();
|
return;
|
||||||
|
|
||||||
ParticleEffectUtils.playGreaterImpactEffect(target);
|
|
||||||
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
|
|
||||||
|
|
||||||
if (mcMMOPlayer.useChatNotifications()) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target instanceof Player) {
|
|
||||||
Player defender = (Player) target;
|
|
||||||
|
|
||||||
if (UserManager.getPlayer(defender).useChatNotifications()) {
|
|
||||||
defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return damage + Axes.greaterImpactBonusDamage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return damage;
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
ParticleEffectUtils.playGreaterImpactEffect(target);
|
||||||
|
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
|
||||||
|
|
||||||
|
if (mcMMOPlayer.useChatNotifications()) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target instanceof Player) {
|
||||||
|
Player defender = (Player) target;
|
||||||
|
|
||||||
|
if (UserManager.getPlayer(defender).useChatNotifications()) {
|
||||||
|
defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CombatUtils.dealDamage(target, Axes.greaterImpactBonusDamage, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ import com.gmail.nossr50.skills.SkillManager;
|
|||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class TamingManager extends SkillManager {
|
public class TamingManager extends SkillManager {
|
||||||
@ -103,19 +104,25 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param target The LivingEntity to apply Gore on
|
* @param target The LivingEntity to apply Gore on
|
||||||
* @param damage The initial damage
|
* @param damage The initial damage
|
||||||
*/
|
*/
|
||||||
public double gore(LivingEntity target, double damage) {
|
public void gore(LivingEntity target, double damage, Wolf wolf) {
|
||||||
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Taming.goreMaxChance, Taming.goreMaxBonusLevel)) {
|
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Taming.goreMaxChance, Taming.goreMaxBonusLevel)) {
|
||||||
BleedTimerTask.add(target, Taming.goreBleedTicks);
|
return;
|
||||||
|
|
||||||
if (target instanceof Player) {
|
|
||||||
((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
|
||||||
}
|
|
||||||
|
|
||||||
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
|
||||||
return damage * Taming.goreModifier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return damage;
|
BleedTimerTask.add(target, Taming.goreBleedTicks);
|
||||||
|
|
||||||
|
if (target instanceof Player) {
|
||||||
|
((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||||
|
|
||||||
|
damage = (damage * Taming.goreModifier) - damage;
|
||||||
|
CombatUtils.dealDamage(target, damage, wolf);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sharpenedClaws(LivingEntity target, Wolf wolf) {
|
||||||
|
CombatUtils.dealDamage(target, Taming.sharpenedClawsBonusDamage, wolf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class UnarmedManager extends SkillManager {
|
public class UnarmedManager extends SkillManager {
|
||||||
@ -95,8 +96,10 @@ public class UnarmedManager extends SkillManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double berserkDamage(double damage) {
|
public void berserkDamage(LivingEntity target, double damage) {
|
||||||
return damage * Unarmed.berserkDamageModifier;
|
damage = (damage * Unarmed.berserkDamageModifier) - damage;
|
||||||
|
|
||||||
|
CombatUtils.dealDamage(target, damage, getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,10 +108,10 @@ public class UnarmedManager extends SkillManager {
|
|||||||
* @param damage The amount of damage initially dealt by the event
|
* @param damage The amount of damage initially dealt by the event
|
||||||
* @return the modified event damage
|
* @return the modified event damage
|
||||||
*/
|
*/
|
||||||
public double ironArmCheck(double damage) {
|
public void ironArm(LivingEntity target) {
|
||||||
int unarmedBonus = Math.min(Unarmed.ironArmMinBonusDamage + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
int unarmedBonus = Math.min(Unarmed.ironArmMinBonusDamage + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
|
||||||
|
|
||||||
return damage + unarmedBonus;
|
CombatUtils.dealDamage(target, unarmedBonus, getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,6 @@ import com.gmail.nossr50.skills.archery.ArcheryManager;
|
|||||||
import com.gmail.nossr50.skills.axes.AxesManager;
|
import com.gmail.nossr50.skills.axes.AxesManager;
|
||||||
import com.gmail.nossr50.skills.swords.Swords;
|
import com.gmail.nossr50.skills.swords.Swords;
|
||||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||||
import com.gmail.nossr50.skills.taming.Taming;
|
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
@ -75,18 +74,18 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (axesManager.canUseAxeMastery()) {
|
if (axesManager.canUseAxeMastery()) {
|
||||||
dealDamage(target, axesManager.axeMasteryCheck(event.getDamage()), player);
|
axesManager.axeMastery(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (axesManager.canCriticalHit(target)) {
|
if (axesManager.canCriticalHit(target)) {
|
||||||
dealDamage(target, axesManager.criticalHitCheck(target, event.getDamage()), player);
|
axesManager.criticalHit(target, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (axesManager.canImpact(target)) {
|
if (axesManager.canImpact(target)) {
|
||||||
axesManager.impactCheck(target);
|
axesManager.impactCheck(target);
|
||||||
}
|
}
|
||||||
else if (axesManager.canGreaterImpact(target)) {
|
else if (axesManager.canGreaterImpact(target)) {
|
||||||
dealDamage(target, axesManager.greaterImpactCheck(target, event.getDamage()), player);
|
axesManager.greaterImpact(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (axesManager.canUseSkullSplitter(target)) {
|
if (axesManager.canUseSkullSplitter(target)) {
|
||||||
@ -105,11 +104,11 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (unarmedManager.canUseIronArm()) {
|
if (unarmedManager.canUseIronArm()) {
|
||||||
dealDamage(target, unarmedManager.ironArmCheck(event.getDamage()), player);
|
unarmedManager.ironArm(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unarmedManager.canUseBerserk()) {
|
if (unarmedManager.canUseBerserk()) {
|
||||||
dealDamage(target, unarmedManager.berserkDamage(event.getDamage()), player);
|
unarmedManager.berserkDamage(target, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unarmedManager.canDisarm(target)) {
|
if (unarmedManager.canDisarm(target)) {
|
||||||
@ -128,22 +127,22 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tamingManager.canUseSharpenedClaws()) {
|
if (tamingManager.canUseSharpenedClaws()) {
|
||||||
dealDamage(target, Taming.sharpenedClawsBonusDamage, master);
|
tamingManager.sharpenedClaws(target, wolf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tamingManager.canUseGore()) {
|
if (tamingManager.canUseGore()) {
|
||||||
dealDamage(target, tamingManager.gore(target, event.getDamage()), master);
|
tamingManager.gore(target, event.getDamage(), wolf);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGainXp(mcMMOPlayer, target, SkillType.TAMING);
|
startGainXp(mcMMOPlayer, target, SkillType.TAMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Entity arrow) {
|
private static void processArcheryCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event, Arrow arrow) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
||||||
|
|
||||||
if (archeryManager.canSkillShot()) {
|
if (archeryManager.canSkillShot()) {
|
||||||
dealDamage(target, archeryManager.skillShotCheck(event.getDamage()), player);
|
archeryManager.skillShot(target, event.getDamage(), arrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target instanceof Player && SkillType.UNARMED.getPVPEnabled()) {
|
if (target instanceof Player && SkillType.UNARMED.getPVPEnabled()) {
|
||||||
@ -159,7 +158,7 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (archeryManager.canDaze(target)) {
|
if (archeryManager.canDaze(target)) {
|
||||||
dealDamage(target, archeryManager.dazeCheck((Player) target, event.getDamage()), player);
|
archeryManager.daze((Player) target, arrow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canTrackArrows()) {
|
if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canTrackArrows()) {
|
||||||
@ -251,13 +250,14 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (damager.getType() == EntityType.ARROW) {
|
else if (damager.getType() == EntityType.ARROW) {
|
||||||
LivingEntity shooter = ((Arrow) damager).getShooter();
|
Arrow arrow = (Arrow) damager;
|
||||||
|
LivingEntity shooter = arrow.getShooter();
|
||||||
|
|
||||||
if (shooter != null && shooter instanceof Player && shouldProcessSkill(target, SkillType.ARCHERY)) {
|
if (shooter != null && shooter instanceof Player && shouldProcessSkill(target, SkillType.ARCHERY)) {
|
||||||
Player player = (Player) shooter;
|
Player player = (Player) shooter;
|
||||||
|
|
||||||
if (!Misc.isNPCEntity(player) && Permissions.skillEnabled(player, SkillType.ARCHERY)) {
|
if (!Misc.isNPCEntity(player) && Permissions.skillEnabled(player, SkillType.ARCHERY)) {
|
||||||
processArcheryCombat(target, player, event, damager);
|
processArcheryCombat(target, player, event, arrow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,56 +345,54 @@ public final class CombatUtils {
|
|||||||
* Attempt to damage target for value dmg with reason CUSTOM
|
* Attempt to damage target for value dmg with reason CUSTOM
|
||||||
*
|
*
|
||||||
* @param target LivingEntity which to attempt to damage
|
* @param target LivingEntity which to attempt to damage
|
||||||
* @param dmg Amount of damage to attempt to do
|
* @param damage Amount of damage to attempt to do
|
||||||
*/
|
*/
|
||||||
public static void dealDamage(LivingEntity target, double dmg) {
|
public static void dealDamage(LivingEntity target, double damage) {
|
||||||
dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempt to damage target for value dmg with reason cause
|
|
||||||
*
|
|
||||||
* @param target LivingEntity which to attempt to damage
|
|
||||||
* @param dmg Amount of damage to attempt to do
|
|
||||||
* @param cause DamageCause to pass to damage event
|
|
||||||
*/
|
|
||||||
private static void dealDamage(LivingEntity target, double dmg, DamageCause cause) {
|
|
||||||
if (Config.getInstance().getEventCallbackEnabled()) {
|
if (Config.getInstance().getEventCallbackEnabled()) {
|
||||||
EntityDamageEvent ede = new FakeEntityDamageEvent(target, cause, dmg);
|
EntityDamageEvent ede = new FakeEntityDamageEvent(target, DamageCause.CUSTOM, damage);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
||||||
|
|
||||||
if (ede.isCancelled()) {
|
if (ede.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.damage(ede.getDamage());
|
damage = ede.getDamage();
|
||||||
}
|
|
||||||
else {
|
|
||||||
target.damage(dmg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target.damage(damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
||||||
*
|
*
|
||||||
* @param target LivingEntity which to attempt to damage
|
* @param target LivingEntity which to attempt to damage
|
||||||
* @param dmg Amount of damage to attempt to do
|
* @param damage Amount of damage to attempt to do
|
||||||
* @param attacker Player to pass to event as damager
|
* @param attacker Player to pass to event as damager
|
||||||
*/
|
*/
|
||||||
private static void dealDamage(LivingEntity target, double dmg, Player attacker) {
|
public static void dealDamage(LivingEntity target, double damage, LivingEntity attacker) {
|
||||||
|
dealDamage(target, damage, DamageCause.ENTITY_ATTACK, attacker);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
|
||||||
|
*
|
||||||
|
* @param target LivingEntity which to attempt to damage
|
||||||
|
* @param damage Amount of damage to attempt to do
|
||||||
|
* @param attacker Player to pass to event as damager
|
||||||
|
*/
|
||||||
|
public static void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker) {
|
||||||
if (Config.getInstance().getEventCallbackEnabled()) {
|
if (Config.getInstance().getEventCallbackEnabled()) {
|
||||||
EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(attacker, target, cause, damage);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
||||||
|
|
||||||
if (ede.isCancelled()) {
|
if (ede.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.damage(ede.getDamage());
|
damage = ede.getDamage();
|
||||||
}
|
|
||||||
else {
|
|
||||||
target.damage(dmg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target.damage(damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user