mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-10-31 17:23:42 +01:00 
			
		
		
		
	Check if a player has Absorption when calculating Acrobatics XP gain
This commit is contained in:
		| @@ -78,7 +78,9 @@ public class Roll extends AcrobaticsSubSkill { | |||||||
|                 if (canRoll(player)) { |                 if (canRoll(player)) { | ||||||
|                     entityDamageEvent.setDamage(rollCheck(player, mcMMOPlayer, entityDamageEvent.getDamage())); |                     entityDamageEvent.setDamage(rollCheck(player, mcMMOPlayer, entityDamageEvent.getDamage())); | ||||||
|  |  | ||||||
|                     if (entityDamageEvent.getFinalDamage() == 0) { |                     //Check getDamage() instead of getFinalDamage() | ||||||
|  |                     //Prevent unintended invincibility if Absorption covers all of the damage | ||||||
|  |                     if (entityDamageEvent.getDamage() == 0) { | ||||||
|                         entityDamageEvent.setCancelled(true); |                         entityDamageEvent.setCancelled(true); | ||||||
|                         return true; |                         return true; | ||||||
|                     } |                     } | ||||||
|   | |||||||
| @@ -43,6 +43,7 @@ import org.bukkit.event.entity.EntityDamageEvent; | |||||||
| import org.bukkit.event.player.PlayerFishEvent; | import org.bukkit.event.player.PlayerFishEvent; | ||||||
| import org.bukkit.inventory.ItemStack; | import org.bukkit.inventory.ItemStack; | ||||||
| import org.bukkit.plugin.PluginManager; | import org.bukkit.plugin.PluginManager; | ||||||
|  | import org.bukkit.potion.PotionEffectType; | ||||||
|  |  | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| @@ -85,7 +86,7 @@ public class EventUtils { | |||||||
|      * |      * | ||||||
|      * 1) The player is real and not an NPC |      * 1) The player is real and not an NPC | ||||||
|      * 2) The player is not in god mode |      * 2) The player is not in god mode | ||||||
|      * 3) The damage dealt is above 0 |      * 3) The damage dealt is above 0 (if a player has Absorption, check if damage and final damage are above 0) | ||||||
|      * 4) The player is loaded into our mcMMO user profiles |      * 4) The player is loaded into our mcMMO user profiles | ||||||
|      * |      * | ||||||
|      * @param entityDamageEvent |      * @param entityDamageEvent | ||||||
| @@ -94,12 +95,27 @@ public class EventUtils { | |||||||
|     public static boolean isRealPlayerDamaged(EntityDamageEvent entityDamageEvent) |     public static boolean isRealPlayerDamaged(EntityDamageEvent entityDamageEvent) | ||||||
|     { |     { | ||||||
|         //Make sure the damage is above 0 |         //Make sure the damage is above 0 | ||||||
|         double damage = entityDamageEvent.getFinalDamage(); |         double damage = entityDamageEvent.getDamage(); | ||||||
|  |         double finalDamage = entityDamageEvent.getFinalDamage(); | ||||||
|  |  | ||||||
|         if (damage <= 0) { |         if (entityDamageEvent.getEntity() instanceof Player) { | ||||||
|             return false; |             Player player = (Player) entityDamageEvent.getEntity(); | ||||||
|  |  | ||||||
|  |             //If a player has Absorption, check both damage and final damage | ||||||
|  |             if (player.hasPotionEffect(PotionEffectType.ABSORPTION)) { | ||||||
|  |                 if (damage <= 0 && finalDamage <= 0) { | ||||||
|  |                     return false; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             //Otherwise, do original check - only check final damage | ||||||
|  |             else { | ||||||
|  |                 if (finalDamage <= 0) { | ||||||
|  |                     return false; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         Entity entity = entityDamageEvent.getEntity(); |         Entity entity = entityDamageEvent.getEntity(); | ||||||
|  |  | ||||||
|         //Check to make sure the entity is not an NPC |         //Check to make sure the entity is not an NPC | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jstnf
					jstnf