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)
|
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();
|
||||||
return;
|
Entity attacker = eventb.getDamager();
|
||||||
|
|
||||||
|
if(attacker instanceof Player && defender instanceof Player)
|
||||||
|
{
|
||||||
|
if(!entity.getWorld().getPVP())
|
||||||
|
return;
|
||||||
|
if(Party.getInstance().inSameParty((Player)defender, (Player)attacker))
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Combat.combatChecks(eventb, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
switch(type)
|
||||||
* CHECK FOR INVULNERABILITY
|
|
||||||
*/
|
|
||||||
if(entity instanceof Player)
|
|
||||||
{
|
{
|
||||||
Player defender = (Player)event.getEntity();
|
case PLAYER:
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
/*
|
||||||
if(defender != null && PPd.getGodMode())
|
* CHECK FOR INVULNERABILITY
|
||||||
|
*/
|
||||||
|
Player player = (Player) entity;
|
||||||
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
|
if(PP.getGodMode())
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if(PPd == null)
|
|
||||||
Users.addUser(defender);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(entity instanceof LivingEntity)
|
if(player.getNoDamageTicks() < player.getMaximumNoDamageTicks()/2.0F)
|
||||||
{
|
{
|
||||||
{
|
if(cause == DamageCause.FALL && mcPermissions.getInstance().acrobatics(player))
|
||||||
LivingEntity entityliving = (LivingEntity)entity;
|
Acrobatics.acrobaticsCheck(player, event);
|
||||||
if(entityliving.getNoDamageTicks() < entityliving.getMaximumNoDamageTicks()/2.0F)
|
if(cause == DamageCause.BLOCK_EXPLOSION && mcPermissions.getInstance().blastMining(player))
|
||||||
{
|
BlastMining.demolitionsExpertise(player, event);
|
||||||
if(entity instanceof Wolf && ((Wolf)entity).isTamed() && Taming.getOwner(((Wolf)entity), plugin) != null)
|
if(!event.isCancelled() && event.getDamage() >= 1)
|
||||||
Taming.preventDamage(event, plugin);
|
PP.setRecentlyHurt(System.currentTimeMillis());
|
||||||
|
}
|
||||||
if(entity instanceof Player){
|
case WOLF:
|
||||||
Player player = (Player)entity;
|
Wolf wolf = (Wolf) entity;
|
||||||
/*
|
if((wolf.getNoDamageTicks() < wolf.getMaximumNoDamageTicks()/2.0F) && wolf.isTamed() && wolf.getOwner() != null)
|
||||||
* ACROBATICS
|
Taming.preventDamage(event, plugin);
|
||||||
*/
|
|
||||||
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())
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Users.getProfile(herpderp).setRecentlyHurt(System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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