mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-03 18:43:43 +01:00 
			
		
		
		
	Reworking our invincibility checks to accomodate for vanilla mc behaviour
This commit is contained in:
		@@ -40,6 +40,7 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
 | 
			
		||||
 | 
			
		||||
import com.gmail.nossr50.Combat;
 | 
			
		||||
import com.gmail.nossr50.Users;
 | 
			
		||||
import com.gmail.nossr50.m;
 | 
			
		||||
import com.gmail.nossr50.mcMMO;
 | 
			
		||||
import com.gmail.nossr50.mcPermissions;
 | 
			
		||||
import com.gmail.nossr50.config.LoadProperties;
 | 
			
		||||
@@ -79,7 +80,7 @@ public class mcEntityListener implements Listener
 | 
			
		||||
		if(defender instanceof LivingEntity)
 | 
			
		||||
		{
 | 
			
		||||
		    LivingEntity livingDefender = (LivingEntity)defender;
 | 
			
		||||
		    if(livingDefender.getNoDamageTicks() < livingDefender.getMaximumNoDamageTicks()/2.0F)
 | 
			
		||||
		    if(!m.isInvincible(livingDefender, event))
 | 
			
		||||
		        Combat.combatChecks(event, plugin);
 | 
			
		||||
		}
 | 
			
		||||
    }
 | 
			
		||||
@@ -102,7 +103,7 @@ public class mcEntityListener implements Listener
 | 
			
		||||
    		if(PP.getGodMode())
 | 
			
		||||
    			event.setCancelled(true);
 | 
			
		||||
    		
 | 
			
		||||
    		if(player.getNoDamageTicks() < player.getMaximumNoDamageTicks()/2.0F)
 | 
			
		||||
    		if(!m.isInvincible(player, event))
 | 
			
		||||
    		{
 | 
			
		||||
    			if(cause == DamageCause.FALL && mcPermissions.getInstance().acrobatics(player))
 | 
			
		||||
    				Acrobatics.acrobaticsCheck(player, event);
 | 
			
		||||
@@ -114,7 +115,7 @@ public class mcEntityListener implements Listener
 | 
			
		||||
    		break;
 | 
			
		||||
    	case WOLF:
 | 
			
		||||
    		Wolf wolf = (Wolf) entity;
 | 
			
		||||
    		if((wolf.getNoDamageTicks() < wolf.getMaximumNoDamageTicks()/2.0F) && wolf.isTamed() && wolf.getOwner() != null)
 | 
			
		||||
    		if((!m.isInvincible(wolf, event)) && wolf.isTamed() && wolf.getOwner() != null)
 | 
			
		||||
    			Taming.preventDamage(event, plugin);
 | 
			
		||||
    		break;
 | 
			
		||||
    	}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.block.Block;
 | 
			
		||||
import org.bukkit.entity.*;
 | 
			
		||||
import org.bukkit.event.entity.EntityDamageEvent;
 | 
			
		||||
import org.bukkit.event.player.PlayerAnimationEvent;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
import com.gmail.nossr50.config.*;
 | 
			
		||||
@@ -60,6 +61,20 @@ public class m
 | 
			
		||||
			return 0;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static boolean isInvincible(LivingEntity le, EntityDamageEvent event)
 | 
			
		||||
	{
 | 
			
		||||
	    //So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility
 | 
			
		||||
	    //So yeah, this is for that
 | 
			
		||||
	    if(le.getNoDamageTicks() < le.getMaximumNoDamageTicks()/2.0F)
 | 
			
		||||
	    {
 | 
			
		||||
	        if(event.getDamage() <= le.getLastDamage())
 | 
			
		||||
	            return true;
 | 
			
		||||
	        else
 | 
			
		||||
	            return false;
 | 
			
		||||
	    }
 | 
			
		||||
	    return true;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public static boolean isDouble(String string)
 | 
			
		||||
	{
 | 
			
		||||
		try 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user