mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-28 11:37:39 +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)
|
if(event instanceof EntityDamageByEntityEvent && !event.isCancelled())
|
||||||
{
|
{
|
||||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event;
|
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event;
|
||||||
if(eventb.getEntity() instanceof Player && eventb.getDamager() instanceof Player && !entity.getWorld().getPVP())
|
Entity defender = eventb.getEntity();
|
||||||
|
Entity attacker = eventb.getDamager();
|
||||||
|
|
||||||
|
if(attacker instanceof Player && defender instanceof Player)
|
||||||
|
{
|
||||||
|
if(!entity.getWorld().getPVP())
|
||||||
return;
|
return;
|
||||||
|
if(Party.getInstance().inSameParty((Player)defender, (Player)attacker))
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Combat.combatChecks(eventb, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case PLAYER:
|
||||||
/*
|
/*
|
||||||
* CHECK FOR INVULNERABILITY
|
* CHECK FOR INVULNERABILITY
|
||||||
*/
|
*/
|
||||||
if(entity instanceof Player)
|
Player player = (Player) entity;
|
||||||
{
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
Player defender = (Player)event.getEntity();
|
if(PP.getGodMode())
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
|
||||||
if(defender != null && PPd.getGodMode())
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if(PPd == null)
|
|
||||||
Users.addUser(defender);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(entity instanceof LivingEntity)
|
if(player.getNoDamageTicks() < player.getMaximumNoDamageTicks()/2.0F)
|
||||||
{
|
{
|
||||||
{
|
|
||||||
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))
|
if(cause == DamageCause.FALL && mcPermissions.getInstance().acrobatics(player))
|
||||||
Acrobatics.acrobaticsCheck(player, event);
|
Acrobatics.acrobaticsCheck(player, event);
|
||||||
/*
|
|
||||||
* Demolitions Expert
|
|
||||||
*/
|
|
||||||
if(cause == DamageCause.BLOCK_EXPLOSION && mcPermissions.getInstance().blastMining(player))
|
if(cause == DamageCause.BLOCK_EXPLOSION && mcPermissions.getInstance().blastMining(player))
|
||||||
BlastMining.demolitionsExpertise(Users.getProfile(player).getSkillLevel(SkillType.MINING), event);
|
BlastMining.demolitionsExpertise(player, event);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Entity Damage by Entity checks
|
|
||||||
*/
|
|
||||||
if(event instanceof EntityDamageByEntityEvent && !event.isCancelled())
|
|
||||||
{
|
|
||||||
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event;
|
|
||||||
Entity f = eventb.getDamager();
|
|
||||||
/*
|
|
||||||
* PARTY CHECKS
|
|
||||||
*/
|
|
||||||
if(entity instanceof Player && f instanceof Player)
|
|
||||||
{
|
|
||||||
Player defender = (Player)entity;
|
|
||||||
Player attacker = (Player)f;
|
|
||||||
if(Party.getInstance().inSameParty(defender, attacker))
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
Combat.combatChecks(eventb, plugin);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Check to see if the defender took damage so we can apply recently hurt
|
|
||||||
*/
|
|
||||||
if(entity instanceof Player)
|
|
||||||
{
|
|
||||||
Player herpderp = (Player)entity;
|
|
||||||
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