mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Fixes wolves gaining combat bonuses based on their owner's held item.
Closes #713
This commit is contained in:
parent
3dc1afde7e
commit
0a68b82078
@ -58,8 +58,9 @@ public final class CombatTools {
|
|||||||
public static void combatChecks(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) {
|
public static void combatChecks(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) {
|
||||||
boolean targetIsPlayer = (target.getType() == EntityType.PLAYER);
|
boolean targetIsPlayer = (target.getType() == EntityType.PLAYER);
|
||||||
boolean targetIsTamedPet = (target instanceof Tameable) ? ((Tameable) target).isTamed() : false;
|
boolean targetIsTamedPet = (target instanceof Tameable) ? ((Tameable) target).isTamed() : false;
|
||||||
|
Entity damager = event.getDamager();
|
||||||
|
|
||||||
if (attacker instanceof Player) {
|
if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) {
|
||||||
Player player = (Player) attacker;
|
Player player = (Player) attacker;
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (Misc.isNPCEntity(player)) {
|
||||||
@ -72,9 +73,8 @@ public final class CombatTools {
|
|||||||
|
|
||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
Material heldItemType = heldItem.getType();
|
Material heldItemType = heldItem.getType();
|
||||||
DamageCause damageCause = event.getCause();
|
|
||||||
|
|
||||||
if (ItemChecks.isSword(heldItem) && damageCause == DamageCause.ENTITY_ATTACK) {
|
if (ItemChecks.isSword(heldItem)) {
|
||||||
if (targetIsPlayer || targetIsTamedPet) {
|
if (targetIsPlayer || targetIsTamedPet) {
|
||||||
if (!SkillType.SWORDS.getPVPEnabled()) {
|
if (!SkillType.SWORDS.getPVPEnabled()) {
|
||||||
return;
|
return;
|
||||||
@ -105,7 +105,7 @@ public final class CombatTools {
|
|||||||
startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
|
startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ItemChecks.isAxe(heldItem) && damageCause == DamageCause.ENTITY_ATTACK) {
|
else if (ItemChecks.isAxe(heldItem)) {
|
||||||
if (targetIsPlayer || targetIsTamedPet) {
|
if (targetIsPlayer || targetIsTamedPet) {
|
||||||
if (!SkillType.AXES.getPVPEnabled()) {
|
if (!SkillType.AXES.getPVPEnabled()) {
|
||||||
return;
|
return;
|
||||||
@ -143,7 +143,7 @@ public final class CombatTools {
|
|||||||
startGainXp(mcMMOPlayer, target, SkillType.AXES);
|
startGainXp(mcMMOPlayer, target, SkillType.AXES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (heldItemType == Material.AIR && damageCause == DamageCause.ENTITY_ATTACK) {
|
else if (heldItemType == Material.AIR) {
|
||||||
if (targetIsPlayer || targetIsTamedPet) {
|
if (targetIsPlayer || targetIsTamedPet) {
|
||||||
if (!SkillType.UNARMED.getPVPEnabled()) {
|
if (!SkillType.UNARMED.getPVPEnabled()) {
|
||||||
return;
|
return;
|
||||||
@ -178,15 +178,13 @@ public final class CombatTools {
|
|||||||
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
|
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player) && damageCause == DamageCause.ENTITY_ATTACK) {
|
else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player)) {
|
||||||
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
TamingManager tamingManager = new TamingManager(Users.getPlayer(player));
|
||||||
tamingManager.beastLore(target);
|
tamingManager.beastLore(target);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity damager = event.getDamager();
|
|
||||||
|
|
||||||
switch (damager.getType()) {
|
switch (damager.getType()) {
|
||||||
case WOLF:
|
case WOLF:
|
||||||
Wolf wolf = (Wolf) damager;
|
Wolf wolf = (Wolf) damager;
|
||||||
|
Loading…
Reference in New Issue
Block a user