This commit is contained in:
nossr50 2019-03-28 04:22:26 -07:00
parent 732726bbd3
commit e2b8d940d3
3 changed files with 38 additions and 33 deletions

View File

@ -7,6 +7,9 @@ Key:
! Change ! Change
- Removal - Removal
Version 2.1.28
Fixed a bug where Archery could not gain XP
Version 2.1.27 Version 2.1.27
Fixed an exploit that allowed players to duplicate torches, and rails Fixed an exploit that allowed players to duplicate torches, and rails

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>2.1.27</version> <version>2.1.28</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm> <scm>

View File

@ -22,6 +22,7 @@ import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.*; import org.bukkit.entity.*;
@ -240,7 +241,37 @@ public final class CombatUtils {
* @param event The event to run the combat checks on. * @param event The event to run the combat checks on.
*/ */
public static void processCombatAttack(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) { public static void processCombatAttack(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) {
EntityType entityType = attacker.getType(); Entity damager = event.getDamager();
EntityType entityType = damager.getType();
if (target instanceof Player) {
if (Misc.isNPCEntity(target)) {
return;
}
Player player = (Player) target;
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
if (acrobaticsManager.canDodge(target)) {
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
}
if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) {
if (!PrimarySkillType.SWORDS.shouldProcess(target)) {
return;
}
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
if (swordsManager.canUseCounterAttack(damager)) {
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
}
}
}
if (attacker instanceof Player && entityType == EntityType.PLAYER) { if (attacker instanceof Player && entityType == EntityType.PLAYER) {
Player player = (Player) attacker; Player player = (Player) attacker;
@ -297,7 +328,7 @@ public final class CombatUtils {
} }
else if (entityType == EntityType.WOLF) { else if (entityType == EntityType.WOLF) {
Wolf wolf = (Wolf) attacker; Wolf wolf = (Wolf) damager;
AnimalTamer tamer = wolf.getOwner(); AnimalTamer tamer = wolf.getOwner();
if (tamer != null && tamer instanceof Player && PrimarySkillType.TAMING.shouldProcess(target)) { if (tamer != null && tamer instanceof Player && PrimarySkillType.TAMING.shouldProcess(target)) {
@ -309,7 +340,7 @@ public final class CombatUtils {
} }
} }
else if (entityType == EntityType.ARROW) { else if (entityType == EntityType.ARROW) {
Arrow arrow = (Arrow) attacker; Arrow arrow = (Arrow) damager;
ProjectileSource projectileSource = arrow.getShooter(); ProjectileSource projectileSource = arrow.getShooter();
if (projectileSource != null && projectileSource instanceof Player && PrimarySkillType.ARCHERY.shouldProcess(target)) { if (projectileSource != null && projectileSource instanceof Player && PrimarySkillType.ARCHERY.shouldProcess(target)) {
@ -326,35 +357,6 @@ public final class CombatUtils {
} }
} }
} }
if (target instanceof Player) {
if (Misc.isNPCEntity(target)) {
return;
}
Player player = (Player) target;
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
if (acrobaticsManager.canDodge(target)) {
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
}
if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) {
if (!PrimarySkillType.SWORDS.shouldProcess(target)) {
return;
}
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
if (swordsManager.canUseCounterAttack(attacker)) {
swordsManager.counterAttackChecks((LivingEntity) attacker, event.getDamage());
}
}
}
} }
public static int getLimitBreakDamage(Player player, SubSkillType subSkillType) { public static int getLimitBreakDamage(Player player, SubSkillType subSkillType) {