mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 13:46:46 +01:00
Cleanup EntityListener.java
This commit is contained in:
parent
b2989a8bab
commit
ed5531d44b
@ -65,84 +65,51 @@ public class mcEntityListener implements Listener
|
|||||||
public void onEntityDamage(EntityDamageEvent event)
|
public void onEntityDamage(EntityDamageEvent event)
|
||||||
{
|
{
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
EntityType type = entity.getType();
|
||||||
DamageCause cause = event.getCause();
|
DamageCause cause = event.getCause();
|
||||||
|
|
||||||
//Check for world pvp flag
|
//Check for world pvp flag
|
||||||
if(event instanceof EntityDamageByEntityEvent)
|
|
||||||
{
|
|
||||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event;
|
|
||||||
if(eventb.getEntity() instanceof Player && eventb.getDamager() instanceof Player && !entity.getWorld().getPVP())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* CHECK FOR INVULNERABILITY
|
|
||||||
*/
|
|
||||||
if(entity instanceof Player)
|
|
||||||
{
|
|
||||||
Player defender = (Player)event.getEntity();
|
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
|
||||||
if(defender != null && PPd.getGodMode())
|
|
||||||
event.setCancelled(true);
|
|
||||||
if(PPd == null)
|
|
||||||
Users.addUser(defender);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(entity instanceof LivingEntity)
|
|
||||||
{
|
|
||||||
{
|
|
||||||
LivingEntity entityliving = (LivingEntity)entity;
|
|
||||||
if(entityliving.getNoDamageTicks() < entityliving.getMaximumNoDamageTicks()/2.0F)
|
|
||||||
{
|
|
||||||
if(entity instanceof Wolf && ((Wolf)entity).isTamed() && Taming.getOwner(((Wolf)entity), plugin) != null)
|
|
||||||
Taming.preventDamage(event, plugin);
|
|
||||||
|
|
||||||
if(entity instanceof Player){
|
|
||||||
Player player = (Player)entity;
|
|
||||||
/*
|
|
||||||
* ACROBATICS
|
|
||||||
*/
|
|
||||||
if(cause == DamageCause.FALL && mcPermissions.getInstance().acrobatics(player))
|
|
||||||
Acrobatics.acrobaticsCheck(player, event);
|
|
||||||
/*
|
|
||||||
* Demolitions Expert
|
|
||||||
*/
|
|
||||||
if(cause == DamageCause.BLOCK_EXPLOSION && mcPermissions.getInstance().blastMining(player))
|
|
||||||
BlastMining.demolitionsExpertise(Users.getProfile(player).getSkillLevel(SkillType.MINING), event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Entity Damage by Entity checks
|
|
||||||
*/
|
|
||||||
if(event instanceof EntityDamageByEntityEvent && !event.isCancelled())
|
if(event instanceof EntityDamageByEntityEvent && !event.isCancelled())
|
||||||
{
|
{
|
||||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event;
|
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event;
|
||||||
Entity f = eventb.getDamager();
|
Entity defender = eventb.getEntity();
|
||||||
/*
|
Entity attacker = eventb.getDamager();
|
||||||
* PARTY CHECKS
|
|
||||||
*/
|
if(attacker instanceof Player && defender instanceof Player)
|
||||||
if(entity instanceof Player && f instanceof Player)
|
|
||||||
{
|
{
|
||||||
Player defender = (Player)entity;
|
if(!entity.getWorld().getPVP())
|
||||||
Player attacker = (Player)f;
|
return;
|
||||||
if(Party.getInstance().inSameParty(defender, attacker))
|
if(Party.getInstance().inSameParty((Player)defender, (Player)attacker))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Combat.combatChecks(eventb, plugin);
|
Combat.combatChecks(eventb, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case PLAYER:
|
||||||
/*
|
/*
|
||||||
* Check to see if the defender took damage so we can apply recently hurt
|
* CHECK FOR INVULNERABILITY
|
||||||
*/
|
*/
|
||||||
if(entity instanceof Player)
|
Player player = (Player) entity;
|
||||||
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
|
if(PP.getGodMode())
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
if(player.getNoDamageTicks() < player.getMaximumNoDamageTicks()/2.0F)
|
||||||
{
|
{
|
||||||
Player herpderp = (Player)entity;
|
if(cause == DamageCause.FALL && mcPermissions.getInstance().acrobatics(player))
|
||||||
|
Acrobatics.acrobaticsCheck(player, event);
|
||||||
|
if(cause == DamageCause.BLOCK_EXPLOSION && mcPermissions.getInstance().blastMining(player))
|
||||||
|
BlastMining.demolitionsExpertise(player, event);
|
||||||
if(!event.isCancelled() && event.getDamage() >= 1)
|
if(!event.isCancelled() && event.getDamage() >= 1)
|
||||||
{
|
PP.setRecentlyHurt(System.currentTimeMillis());
|
||||||
Users.getProfile(herpderp).setRecentlyHurt(System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case WOLF:
|
||||||
|
Wolf wolf = (Wolf) entity;
|
||||||
|
if((wolf.getNoDamageTicks() < wolf.getMaximumNoDamageTicks()/2.0F) && wolf.isTamed() && wolf.getOwner() != null)
|
||||||
|
Taming.preventDamage(event, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,8 +223,9 @@ public class BlastMining{
|
|||||||
* Reduces explosion damage to 1/2 of normal at 750.
|
* Reduces explosion damage to 1/2 of normal at 750.
|
||||||
* Reduces explosion damage to 0 at 1000.
|
* Reduces explosion damage to 0 at 1000.
|
||||||
*/
|
*/
|
||||||
public static void demolitionsExpertise(int skill, EntityDamageEvent event)
|
public static void demolitionsExpertise(Player player, EntityDamageEvent event)
|
||||||
{
|
{
|
||||||
|
int skill = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||||
int damage = event.getDamage();
|
int damage = event.getDamage();
|
||||||
if(skill < 500)
|
if(skill < 500)
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user