mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Fixed issues with combat abilities not checking cooldowns in last few
dev builds.
This commit is contained in:
parent
a4aebdc643
commit
c4ec9a6df9
@ -42,6 +42,7 @@ import com.gmail.nossr50.skills.unarmed.Unarmed;
|
|||||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||||
import com.gmail.nossr50.util.ItemChecks;
|
import com.gmail.nossr50.util.ItemChecks;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class Combat {
|
public class Combat {
|
||||||
@ -76,13 +77,25 @@ public class Combat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.abilityCheck(player, SkillType.SWORDS);
|
if (Permissions.swords(player)) {
|
||||||
|
SwordsManager swordsManager = new SwordsManager(player);
|
||||||
|
PlayerProfile profile = swordsManager.getProfile();
|
||||||
|
boolean canSerratedStrike = Permissions.serratedStrikes(player); //So we don't have to check the same permission twice
|
||||||
|
|
||||||
SwordsManager swordsManager = new SwordsManager(player);
|
if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) {
|
||||||
swordsManager.bleedCheck(target);
|
Skills.abilityCheck(player, SkillType.SWORDS);
|
||||||
swordsManager.serratedStrikes(target, event.getDamage());
|
}
|
||||||
|
|
||||||
startGainXp(player, swordsManager.getProfile(), target, SkillType.SWORDS);
|
if (Permissions.swordsBleed(player) && shouldBeAffected(player, target)) {
|
||||||
|
swordsManager.bleedCheck(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profile.getAbilityMode(AbilityType.SERRATED_STRIKES) && canSerratedStrike) {
|
||||||
|
swordsManager.serratedStrikes(target, event.getDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
startGainXp(player, profile, target, SkillType.SWORDS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (ItemChecks.isAxe(heldItem)) {
|
else if (ItemChecks.isAxe(heldItem)) {
|
||||||
if (targetIsPlayer || targetIsTamedPet) {
|
if (targetIsPlayer || targetIsTamedPet) {
|
||||||
@ -94,15 +107,32 @@ public class Combat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.abilityCheck(player, SkillType.AXES);
|
if (Permissions.axes(player)) {
|
||||||
|
AxeManager axeManager = new AxeManager(player);
|
||||||
|
PlayerProfile profile = axeManager.getProfile();
|
||||||
|
boolean canSkullSplit = Permissions.skullSplitter(player); //So we don't have to check the same permission twice
|
||||||
|
if (profile.getToolPreparationMode(ToolType.AXE) && canSkullSplit) {
|
||||||
|
Skills.abilityCheck(player, SkillType.AXES);
|
||||||
|
}
|
||||||
|
|
||||||
AxeManager axeManager = new AxeManager(player);
|
if (Permissions.axeBonus(player)) {
|
||||||
axeManager.bonusDamage(event);
|
axeManager.bonusDamage(event);
|
||||||
axeManager.criticalHitCheck(event, target);
|
}
|
||||||
axeManager.impact(event, target);
|
|
||||||
axeManager.skullSplitter(target, event.getDamage());
|
|
||||||
|
|
||||||
startGainXp(player, axeManager.getProfile(), target, SkillType.AXES);
|
if (!target.isDead() && Permissions.criticalHit(player) && shouldBeAffected(player, target)) {
|
||||||
|
axeManager.criticalHitCheck(event, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target.isDead() && Permissions.impact(player)) {
|
||||||
|
axeManager.impact(event, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target.isDead() && profile.getAbilityMode(AbilityType.SKULL_SPLIITER) && canSkullSplit) {
|
||||||
|
axeManager.skullSplitter(target, event.getDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
startGainXp(player, profile, target, SkillType.AXES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (heldItemType == Material.AIR) {
|
else if (heldItemType == Material.AIR) {
|
||||||
if (targetIsPlayer || targetIsTamedPet) {
|
if (targetIsPlayer || targetIsTamedPet) {
|
||||||
@ -114,16 +144,31 @@ public class Combat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
if (Permissions.unarmed(player)) {
|
||||||
|
UnarmedManager unarmedManager = new UnarmedManager(player);
|
||||||
|
PlayerProfile profile = unarmedManager.getProfile();
|
||||||
|
boolean canBerserk = Permissions.berserk(player); //So we don't have to check the same permission twice
|
||||||
|
|
||||||
UnarmedManager unarmedManager = new UnarmedManager(player);
|
if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) {
|
||||||
unarmedManager.bonusDamage(event);
|
Skills.abilityCheck(player, SkillType.UNARMED);
|
||||||
unarmedManager.berserkDamage(event);
|
}
|
||||||
unarmedManager.disarmCheck(target);
|
|
||||||
|
|
||||||
startGainXp(player, unarmedManager.getProfile(), target, SkillType.UNARMED);
|
if (Permissions.unarmedBonus(player)) {
|
||||||
|
unarmedManager.bonusDamage(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profile.getAbilityMode(AbilityType.BERSERK) && canBerserk) {
|
||||||
|
unarmedManager.berserkDamage(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target instanceof Player && Permissions.disarm(player)) {
|
||||||
|
unarmedManager.disarmCheck(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
startGainXp(player, unarmedManager.getProfile(), target, SkillType.UNARMED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (heldItemType == Material.BONE && target instanceof Tameable) {
|
else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player)) {
|
||||||
TamingManager tamingManager = new TamingManager(player);
|
TamingManager tamingManager = new TamingManager(player);
|
||||||
tamingManager.beastLore(target);
|
tamingManager.beastLore(target);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -139,6 +184,10 @@ public class Combat {
|
|||||||
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
|
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
|
||||||
Player master = (Player) wolf.getOwner();
|
Player master = (Player) wolf.getOwner();
|
||||||
|
|
||||||
|
if (Misc.isNPCPlayer(master)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (targetIsPlayer || targetIsTamedPet) {
|
if (targetIsPlayer || targetIsTamedPet) {
|
||||||
if (!Taming.pvpEnabled) {
|
if (!Taming.pvpEnabled) {
|
||||||
return;
|
return;
|
||||||
@ -148,12 +197,26 @@ public class Combat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TamingManager tamingManager = new TamingManager(master);
|
if (Permissions.taming(master)) {
|
||||||
tamingManager.fastFoodService(wolf, event.getDamage());
|
TamingManager tamingManager = new TamingManager(master);
|
||||||
tamingManager.sharpenedClaws(event);
|
int skillLevel = tamingManager.getSkillLevel();
|
||||||
tamingManager.gore(event);
|
|
||||||
|
|
||||||
startGainXp(master, tamingManager.getProfile(), target, SkillType.TAMING);
|
if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) {
|
||||||
|
tamingManager.fastFoodService(wolf, event.getDamage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) {
|
||||||
|
tamingManager.sharpenedClaws(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Permissions.gore(master)) {
|
||||||
|
tamingManager.gore(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target != master) {
|
||||||
|
startGainXp(master, tamingManager.getProfile(), target, SkillType.TAMING);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -161,8 +224,8 @@ public class Combat {
|
|||||||
case ARROW:
|
case ARROW:
|
||||||
LivingEntity shooter = ((Arrow) damager).getShooter();
|
LivingEntity shooter = ((Arrow) damager).getShooter();
|
||||||
|
|
||||||
//TODO: Is there a reason we're breaking here instead of returning?
|
/* Break instead of return due to Dodge/Counter/Deflect abilities */
|
||||||
if (shooter == null || shooter.getType() != EntityType.PLAYER) {
|
if (shooter == null || !(shooter instanceof Player)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,33 +248,37 @@ public class Combat {
|
|||||||
if (targetIsPlayer) {
|
if (targetIsPlayer) {
|
||||||
Player player = (Player) target;
|
Player player = (Player) target;
|
||||||
|
|
||||||
|
if (Misc.isNPCPlayer(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
|
||||||
if (damager instanceof Player) {
|
if (damager instanceof Player) {
|
||||||
if (Swords.pvpEnabled) {
|
if (Swords.pvpEnabled && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) {
|
||||||
SwordsManager swordsManager = new SwordsManager(player);
|
SwordsManager swordsManager = new SwordsManager(player);
|
||||||
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Acrobatics.pvpEnabled) {
|
if (Acrobatics.pvpEnabled && Permissions.dodge(player)) {
|
||||||
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(player);
|
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(player);
|
||||||
acrobaticsManager.dodgeCheck(event);
|
acrobaticsManager.dodgeCheck(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Unarmed.pvpEnabled && player.getItemInHand().getType() == Material.AIR) {
|
if (Unarmed.pvpEnabled && heldItem.getType() == Material.AIR && Permissions.deflect(player)) {
|
||||||
UnarmedManager unarmedManager = new UnarmedManager(player);
|
UnarmedManager unarmedManager = new UnarmedManager(player);
|
||||||
unarmedManager.deflectCheck(event);
|
unarmedManager.deflectCheck(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Swords.pveEnabled && damager instanceof LivingEntity) {
|
if (Swords.pveEnabled && damager instanceof LivingEntity && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) {
|
||||||
SwordsManager swordsManager = new SwordsManager(player);
|
SwordsManager swordsManager = new SwordsManager(player);
|
||||||
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Acrobatics.pveEnabled) {
|
if (Acrobatics.pveEnabled && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled) && Permissions.dodge(player)) {
|
||||||
if (!(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) {
|
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(player);
|
||||||
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(player);
|
acrobaticsManager.dodgeCheck(event);
|
||||||
acrobaticsManager.dodgeCheck(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,24 +291,26 @@ public class Combat {
|
|||||||
* @param target The defending entity
|
* @param target The defending entity
|
||||||
* @param event The event to run the archery checks on.
|
* @param event The event to run the archery checks on.
|
||||||
*/
|
*/
|
||||||
public static void archeryCheck(Player shooter, LivingEntity target, EntityDamageByEntityEvent event) {
|
private static void archeryCheck(Player shooter, LivingEntity target, EntityDamageByEntityEvent event) {
|
||||||
if (Misc.isNPCPlayer(shooter)) {
|
if (Misc.isNPCPlayer(shooter)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArcheryManager archeryManager = new ArcheryManager(shooter);
|
if (Permissions.archery(shooter)) {
|
||||||
archeryManager.skillShot(event);
|
ArcheryManager archeryManager = new ArcheryManager(shooter);
|
||||||
|
archeryManager.skillShot(event);
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player && Permissions.daze(shooter)) {
|
||||||
archeryManager.dazeCheck((Player) target, event);
|
archeryManager.dazeCheck((Player) target, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(shooter.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE))) {
|
if (!(shooter.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.trackArrows(shooter)) {
|
||||||
archeryManager.trackArrows(target);
|
archeryManager.trackArrows(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target != shooter) {
|
if (target != shooter) {
|
||||||
startGainXp(shooter, archeryManager.getProfile(), target, SkillType.ARCHERY);
|
startGainXp(shooter, archeryManager.getProfile(), target, SkillType.ARCHERY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
|
|
||||||
public class AcrobaticsManager extends SkillManager {
|
public class AcrobaticsManager extends SkillManager {
|
||||||
public AcrobaticsManager (Player player) {
|
public AcrobaticsManager (Player player) {
|
||||||
@ -46,10 +45,6 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
* @param event The event to check
|
* @param event The event to check
|
||||||
*/
|
*/
|
||||||
public void dodgeCheck(EntityDamageEvent event) {
|
public void dodgeCheck(EntityDamageEvent event) {
|
||||||
if (Misc.isNPCPlayer(player) || !Permissions.dodge(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
|
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
|
||||||
|
|
||||||
double chance = (Acrobatics.dodgeMaxChance / Acrobatics.dodgeMaxBonusLevel) * eventHandler.skillModifier;
|
double chance = (Acrobatics.dodgeMaxChance / Acrobatics.dodgeMaxBonusLevel) * eventHandler.skillModifier;
|
||||||
|
@ -20,10 +20,6 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* @param livingEntity Entity damaged by the arrow
|
* @param livingEntity Entity damaged by the arrow
|
||||||
*/
|
*/
|
||||||
public void trackArrows(LivingEntity livingEntity) {
|
public void trackArrows(LivingEntity livingEntity) {
|
||||||
if (Misc.isNPCPlayer(player) || !Permissions.trackArrows(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity);
|
ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity);
|
||||||
|
|
||||||
double chance = (Archery.retrieveMaxChance / Archery.retrieveMaxBonusLevel) * eventHandler.skillModifier;
|
double chance = (Archery.retrieveMaxChance / Archery.retrieveMaxBonusLevel) * eventHandler.skillModifier;
|
||||||
@ -40,10 +36,6 @@ public class ArcheryManager extends SkillManager {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
public void dazeCheck(Player defender, EntityDamageEvent event) {
|
public void dazeCheck(Player defender, EntityDamageEvent event) {
|
||||||
if (Misc.isNPCPlayer(player) || !Permissions.daze(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
|
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
|
||||||
|
|
||||||
double chance = (Archery.dazeMaxBonus / Archery.dazeMaxBonusLevel) * eventHandler.skillModifier;
|
double chance = (Archery.dazeMaxBonus / Archery.dazeMaxBonusLevel) * eventHandler.skillModifier;
|
||||||
|
@ -2,14 +2,11 @@ package com.gmail.nossr50.skills.axes;
|
|||||||
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Tameable;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.skills.AbilityType;
|
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
|
|
||||||
public class AxeManager extends SkillManager {
|
public class AxeManager extends SkillManager {
|
||||||
public AxeManager(Player player) {
|
public AxeManager(Player player) {
|
||||||
@ -22,10 +19,6 @@ public class AxeManager extends SkillManager {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
public void bonusDamage(EntityDamageByEntityEvent event) {
|
public void bonusDamage(EntityDamageByEntityEvent event) {
|
||||||
if (!Permissions.axeBonus(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
AxeBonusDamageEventHandler eventHandler = new AxeBonusDamageEventHandler(this, event);
|
AxeBonusDamageEventHandler eventHandler = new AxeBonusDamageEventHandler(this, event);
|
||||||
|
|
||||||
eventHandler.calculateDamageBonus();
|
eventHandler.calculateDamageBonus();
|
||||||
@ -38,10 +31,6 @@ public class AxeManager extends SkillManager {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
public void criticalHitCheck(EntityDamageByEntityEvent event, LivingEntity target) {
|
public void criticalHitCheck(EntityDamageByEntityEvent event, LivingEntity target) {
|
||||||
if (target.isDead() || (target instanceof Tameable && Misc.isFriendlyPet(player, (Tameable) target)) || !Permissions.criticalHit(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CriticalHitEventHandler eventHandler = new CriticalHitEventHandler(this, event, target);
|
CriticalHitEventHandler eventHandler = new CriticalHitEventHandler(this, event, target);
|
||||||
|
|
||||||
double chance = (Axes.criticalHitMaxChance / Axes.criticalHitMaxBonusLevel) * eventHandler.skillModifier;
|
double chance = (Axes.criticalHitMaxChance / Axes.criticalHitMaxBonusLevel) * eventHandler.skillModifier;
|
||||||
@ -58,10 +47,6 @@ public class AxeManager extends SkillManager {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
public void impact(EntityDamageByEntityEvent event, LivingEntity target) {
|
public void impact(EntityDamageByEntityEvent event, LivingEntity target) {
|
||||||
if (target.isDead() || !Permissions.impact(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImpactEventHandler eventHandler = new ImpactEventHandler(this, event, target);
|
ImpactEventHandler eventHandler = new ImpactEventHandler(this, event, target);
|
||||||
|
|
||||||
if (Misc.hasArmor(target)) {
|
if (Misc.hasArmor(target)) {
|
||||||
@ -78,10 +63,6 @@ public class AxeManager extends SkillManager {
|
|||||||
* @param event The event to process
|
* @param event The event to process
|
||||||
*/
|
*/
|
||||||
public void skullSplitter(LivingEntity target, int damage) {
|
public void skullSplitter(LivingEntity target, int damage) {
|
||||||
if (target.isDead() || !profile.getAbilityMode(AbilityType.SKULL_SPLIITER) || !Permissions.skullSplitter(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SkullSplitterEventHandler eventHandler = new SkullSplitterEventHandler(player, damage, target);
|
SkullSplitterEventHandler eventHandler = new SkullSplitterEventHandler(player, damage, target);
|
||||||
eventHandler.applyAbilityEffects();
|
eventHandler.applyAbilityEffects();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.Combat;
|
import com.gmail.nossr50.skills.Combat;
|
||||||
import com.gmail.nossr50.util.ItemChecks;
|
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public class CounterAttackEventHandler {
|
public class CounterAttackEventHandler {
|
||||||
@ -23,13 +22,6 @@ public class CounterAttackEventHandler {
|
|||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isHoldingSword() {
|
|
||||||
if (player == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return ItemChecks.isSword(player.getItemInHand());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void calculateSkillModifier() {
|
protected void calculateSkillModifier() {
|
||||||
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Swords.counterAttackMaxBonusLevel);
|
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Swords.counterAttackMaxBonusLevel);
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,9 @@ package com.gmail.nossr50.skills.swords;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.skills.AbilityType;
|
|
||||||
import com.gmail.nossr50.skills.Combat;
|
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
|
|
||||||
public class SwordsManager extends SkillManager {
|
public class SwordsManager extends SkillManager {
|
||||||
public SwordsManager (Player player) {
|
public SwordsManager (Player player) {
|
||||||
@ -21,50 +18,32 @@ public class SwordsManager extends SkillManager {
|
|||||||
* @param defender The defending entity
|
* @param defender The defending entity
|
||||||
*/
|
*/
|
||||||
public void bleedCheck(LivingEntity defender) {
|
public void bleedCheck(LivingEntity defender) {
|
||||||
if (!Permissions.swordsBleed(player)) {
|
BleedEventHandler eventHandler = new BleedEventHandler(this, defender);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Combat.shouldBeAffected(player, defender)) {
|
float chance = (float) ((Swords.bleedMaxChance / Swords.bleedMaxBonusLevel) * skillLevel);
|
||||||
BleedEventHandler eventHandler = new BleedEventHandler(this, defender);
|
if (chance > Swords.bleedMaxChance) chance = (float) Swords.bleedMaxChance;
|
||||||
|
|
||||||
float chance = (float) ((Swords.bleedMaxChance / Swords.bleedMaxBonusLevel) * skillLevel);
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||||
if (chance > Swords.bleedMaxChance) chance = (float) Swords.bleedMaxChance;
|
eventHandler.addBleedTicks();
|
||||||
|
eventHandler.sendAbilityMessages();
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
|
||||||
eventHandler.addBleedTicks();
|
|
||||||
eventHandler.sendAbilityMessages();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void counterAttackChecks(LivingEntity attacker, int damage) {
|
public void counterAttackChecks(LivingEntity attacker, int damage) {
|
||||||
if (!Permissions.counterAttack(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage);
|
CounterAttackEventHandler eventHandler = new CounterAttackEventHandler(this, attacker, damage);
|
||||||
|
eventHandler.calculateSkillModifier();
|
||||||
|
|
||||||
if (eventHandler.isHoldingSword()) {
|
float chance = (float) ((Swords.counterAttackMaxChance / Swords.counterAttackMaxBonusLevel) * skillLevel);
|
||||||
eventHandler.calculateSkillModifier();
|
if (chance > Swords.counterAttackMaxChance) chance = (float) Swords.counterAttackMaxChance;
|
||||||
|
|
||||||
float chance = (float) ((Swords.counterAttackMaxChance / Swords.counterAttackMaxBonusLevel) * skillLevel);
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||||
if (chance > Swords.counterAttackMaxChance) chance = (float) Swords.counterAttackMaxChance;
|
eventHandler.dealDamage();
|
||||||
|
eventHandler.sendAbilityMessages();
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
|
||||||
eventHandler.dealDamage();
|
|
||||||
eventHandler.sendAbilityMessages();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serratedStrikes(LivingEntity target, int damage) {
|
public void serratedStrikes(LivingEntity target, int damage) {
|
||||||
if (!profile.getAbilityMode(AbilityType.SERRATED_STRIKES) || !Permissions.serratedStrikes(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SerratedStrikesEventHandler eventHandler = new SerratedStrikesEventHandler(this, target, damage);
|
SerratedStrikesEventHandler eventHandler = new SerratedStrikesEventHandler(this, target, damage);
|
||||||
|
|
||||||
eventHandler.applyAbilityEffects();
|
eventHandler.applyAbilityEffects();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,12 +56,10 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param damage The damage being absorbed by the wolf
|
* @param damage The damage being absorbed by the wolf
|
||||||
*/
|
*/
|
||||||
public void fastFoodService(Wolf wolf, int damage) {
|
public void fastFoodService(Wolf wolf, int damage) {
|
||||||
if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(player)) {
|
if (Misc.getRandom().nextInt(activationChance) < Taming.fastFoodServiceActivationChance) {
|
||||||
if (Misc.getRandom().nextInt(activationChance) < Taming.fastFoodServiceActivationChance) {
|
FastFoodServiceEventHandler eventHandler = new FastFoodServiceEventHandler(wolf);
|
||||||
FastFoodServiceEventHandler eventHandler = new FastFoodServiceEventHandler(wolf);
|
|
||||||
|
|
||||||
eventHandler.modifyHealth(damage);
|
eventHandler.modifyHealth(damage);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,11 +69,8 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
public void sharpenedClaws(EntityDamageEvent event) {
|
public void sharpenedClaws(EntityDamageEvent event) {
|
||||||
if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(player)) {
|
SharpenedClawsEventHandler eventHandler = new SharpenedClawsEventHandler(event);
|
||||||
SharpenedClawsEventHandler eventHandler = new SharpenedClawsEventHandler(event);
|
eventHandler.modifyEventDamage();
|
||||||
|
|
||||||
eventHandler.modifyEventDamage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,10 +79,6 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
public void gore(EntityDamageEvent event) {
|
public void gore(EntityDamageEvent event) {
|
||||||
if (!Permissions.gore(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
|
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
|
||||||
|
|
||||||
float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * skillLevel);
|
float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * skillLevel);
|
||||||
@ -153,10 +144,6 @@ public class TamingManager extends SkillManager {
|
|||||||
* @param livingEntity The entity to examine
|
* @param livingEntity The entity to examine
|
||||||
*/
|
*/
|
||||||
public void beastLore(LivingEntity livingEntity) {
|
public void beastLore(LivingEntity livingEntity) {
|
||||||
if (!Permissions.beastLore(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(player, livingEntity);
|
BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(player, livingEntity);
|
||||||
eventHandler.sendInspectMessage();
|
eventHandler.sendInspectMessage();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.skills.AbilityType;
|
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
@ -21,10 +20,6 @@ public class UnarmedManager extends SkillManager {
|
|||||||
* @param defender The defending player
|
* @param defender The defending player
|
||||||
*/
|
*/
|
||||||
public void disarmCheck(LivingEntity defender) {
|
public void disarmCheck(LivingEntity defender) {
|
||||||
if (!(defender instanceof Player) || !Permissions.disarm(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player defendingPlayer = (Player) defender;
|
Player defendingPlayer = (Player) defender;
|
||||||
DisarmEventHandler eventHandler = new DisarmEventHandler(this, defendingPlayer);
|
DisarmEventHandler eventHandler = new DisarmEventHandler(this, defendingPlayer);
|
||||||
|
|
||||||
@ -49,10 +44,6 @@ public class UnarmedManager extends SkillManager {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
public void deflectCheck(EntityDamageEvent event) {
|
public void deflectCheck(EntityDamageEvent event) {
|
||||||
if (!Permissions.deflect(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeflectEventHandler eventHandler = new DeflectEventHandler(this, event);
|
DeflectEventHandler eventHandler = new DeflectEventHandler(this, event);
|
||||||
|
|
||||||
float chance = (float) ((Unarmed.deflectMaxChance / Unarmed.deflectMaxBonusLevel) * skillLevel);
|
float chance = (float) ((Unarmed.deflectMaxChance / Unarmed.deflectMaxBonusLevel) * skillLevel);
|
||||||
@ -65,9 +56,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void berserkDamage(EntityDamageEvent event) {
|
public void berserkDamage(EntityDamageEvent event) {
|
||||||
if (!profile.getAbilityMode(AbilityType.BERSERK) || !Permissions.berserk(player)) {
|
event.setDamage((int) (event.getDamage() * Unarmed.berserkDamageModifier));
|
||||||
event.setDamage((int) (event.getDamage() * Unarmed.berserkDamageModifier));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,10 +65,6 @@ public class UnarmedManager extends SkillManager {
|
|||||||
* @param event The event to modify.
|
* @param event The event to modify.
|
||||||
*/
|
*/
|
||||||
public void bonusDamage(EntityDamageEvent event) {
|
public void bonusDamage(EntityDamageEvent event) {
|
||||||
if (!Permissions.unarmedBonus(player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UnarmedBonusDamageEventHandler eventHandler = new UnarmedBonusDamageEventHandler(this, event);
|
UnarmedBonusDamageEventHandler eventHandler = new UnarmedBonusDamageEventHandler(this, event);
|
||||||
|
|
||||||
eventHandler.calculateDamageBonus();
|
eventHandler.calculateDamageBonus();
|
||||||
|
Loading…
Reference in New Issue
Block a user