This commit is contained in:
GJ 2012-05-21 09:33:21 -04:00
parent 73902d5f92
commit f66c6ab8fc
2 changed files with 18 additions and 27 deletions

View File

@ -7,9 +7,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@ -30,9 +28,8 @@ public class Swords {
*
* @param attacker The attacking player
* @param entity The defending entity
* @param plugin mcMMO plugin instance
*/
public static void bleedCheck(Player attacker, LivingEntity entity, mcMMO plugin) {
public static void bleedCheck(Player attacker, LivingEntity entity) {
if (entity instanceof Tameable) {
Tameable pet = (Tameable) entity;
@ -76,17 +73,11 @@ public class Swords {
*
* @param event The event to modify
*/
public static void counterAttackChecks(EntityDamageByEntityEvent event) {
Entity attacker = event.getDamager();
public static void counterAttackChecks(Entity attacker, Player defender, int damage) {
if (!(attacker instanceof LivingEntity)) {
return;
}
Entity target = event.getEntity();
if (target instanceof Player) {
Player defender = (Player) target;
PlayerProfile PPd = Users.getProfile(defender);
if (ItemChecks.isSword(defender.getItemInHand()) && Permissions.getInstance().counterAttack(defender)) {
@ -97,7 +88,7 @@ public class Swords {
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(2000) <= skillCheck) {
Combat.dealDamage((LivingEntity) attacker, event.getDamage() / COUNTER_ATTACK_MODIFIER);
Combat.dealDamage((LivingEntity) attacker, damage / COUNTER_ATTACK_MODIFIER);
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
if (attacker instanceof Player) {
@ -106,5 +97,4 @@ public class Swords {
}
}
}
}
}

View File

@ -77,7 +77,7 @@ public class Combat {
}
if (permInstance.swordsBleed(attacker)) {
Swords.bleedCheck(attacker, target, plugin);
Swords.bleedCheck(attacker, target);
}
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && permInstance.serratedStrikes(attacker)) {
@ -183,7 +183,8 @@ public class Combat {
startGainXp(master, PPo, target, SkillType.TAMING, plugin);
}
}
} else if (damager instanceof Projectile) {
}
else if (damager instanceof Projectile) {
if (!configInstance.getArcheryPVP() && ((Projectile) damager).getShooter().getType().equals(EntityType.PLAYER)) {
if (targetIsPlayer || targetIsTamedPet) {
return;
@ -201,11 +202,11 @@ public class Combat {
if (target instanceof Player) {
if (configInstance.getSwordsPVP() && damager instanceof Player) {
Swords.counterAttackChecks(event);
Swords.counterAttackChecks(damager, (Player) target, event.getDamage());
}
if (configInstance.getSwordsPVE() && !(damager instanceof Player)) {
Swords.counterAttackChecks(event);
Swords.counterAttackChecks(damager, (Player) target, event.getDamage());
}
if (configInstance.getAcrobaticsPVP() && damager instanceof Player) {