mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Reworking our invincibility checks to accomodate for vanilla mc behaviour
This commit is contained in:
parent
2f5edb6329
commit
1c866a52e5
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user