Optimize more things.

This commit is contained in:
GJ 2012-02-23 21:44:44 -05:00
parent 1fe259eb7a
commit 10fa9e5465
2 changed files with 67 additions and 82 deletions

View File

@ -63,18 +63,21 @@ public class mcEntityListener implements Listener
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) public void onEntityDamage(EntityDamageEvent event)
{ {
Entity entity = event.getEntity();
DamageCause cause = event.getCause();
//Check for world pvp flag //Check for world pvp flag
if(event instanceof EntityDamageByEntityEvent) if(event instanceof EntityDamageByEntityEvent)
{ {
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event; EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent)event;
if(eventb.getEntity() instanceof Player && eventb.getDamager() instanceof Player && !event.getEntity().getWorld().getPVP()) if(eventb.getEntity() instanceof Player && eventb.getDamager() instanceof Player && !entity.getWorld().getPVP())
return; return;
} }
/* /*
* CHECK FOR INVULNERABILITY * CHECK FOR INVULNERABILITY
*/ */
if(event.getEntity() instanceof Player) if(entity instanceof Player)
{ {
Player defender = (Player)event.getEntity(); Player defender = (Player)event.getEntity();
PlayerProfile PPd = Users.getProfile(defender); PlayerProfile PPd = Users.getProfile(defender);
@ -84,66 +87,52 @@ public class mcEntityListener implements Listener
Users.addUser(defender); Users.addUser(defender);
} }
/* if(entity instanceof LivingEntity)
* Demolitions Expert
*/
if(event.getCause() == DamageCause.BLOCK_EXPLOSION)
{
if(event.getEntity() instanceof Player)
{
Player player = (Player)event.getEntity();
if(mcPermissions.getInstance().blastmining(player))
BlastMining.demolitionsExpertise(player, event);
}
}
if(event.getEntity() instanceof LivingEntity)
{ {
{ {
LivingEntity entityliving = (LivingEntity)event.getEntity(); LivingEntity entityliving = (LivingEntity)entity;
if(entityliving.getNoDamageTicks() < entityliving.getMaximumNoDamageTicks()/2.0F) if(entityliving.getNoDamageTicks() < entityliving.getMaximumNoDamageTicks()/2.0F)
{ {
Entity x = event.getEntity(); if(entity instanceof Wolf && ((Wolf)entity).isTamed() && Taming.getOwner(((Wolf)entity), plugin) != null)
DamageCause type = event.getCause();
if(event.getEntity() instanceof Wolf && ((Wolf)event.getEntity()).isTamed() && Taming.getOwner(((Wolf)event.getEntity()), plugin) != null)
{ {
Wolf theWolf = (Wolf) event.getEntity(); Wolf theWolf = (Wolf) event.getEntity();
Player master = Taming.getOwner(theWolf, plugin); Player master = Taming.getOwner(theWolf, plugin);
PlayerProfile PPo = Users.getProfile(master); PlayerProfile PPo = Users.getProfile(master);
int skillLevel = PPo.getSkillLevel(SkillType.TAMING);
if(master == null || PPo == null) if(master == null || PPo == null)
return; return;
//Environmentally Aware //Environmentally Aware
if((event.getCause() == DamageCause.CONTACT || event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE) && PPo.getSkillLevel(SkillType.TAMING) >= 100) if((cause == DamageCause.CONTACT || cause == DamageCause.LAVA || cause == DamageCause.FIRE) && skillLevel >= 100)
{ {
if(event.getDamage() < ((Wolf) event.getEntity()).getHealth()) if(event.getDamage() < theWolf.getHealth())
{ {
event.getEntity().teleport(Taming.getOwner(theWolf, plugin).getLocation()); entity.teleport(Taming.getOwner(theWolf, plugin).getLocation());
master.sendMessage(mcLocale.getString("mcEntityListener.WolfComesBack")); //$NON-NLS-1$ master.sendMessage(mcLocale.getString("mcEntityListener.WolfComesBack")); //$NON-NLS-1$
event.getEntity().setFireTicks(0); entity.setFireTicks(0);
} }
} }
if(event.getCause() == DamageCause.FALL && PPo.getSkillLevel(SkillType.TAMING) >= 100) if(cause == DamageCause.FALL && skillLevel >= 100)
{
event.setCancelled(true); event.setCancelled(true);
}
//Thick Fur //Thick Fur
if(event.getCause() == DamageCause.FIRE_TICK) if(cause == DamageCause.FIRE_TICK)
{
event.getEntity().setFireTicks(0); event.getEntity().setFireTicks(0);
} }
}
if(entity instanceof Player){
Player player = (Player)entity;
/* /*
* ACROBATICS * ACROBATICS
*/ */
if(x instanceof Player){ if(cause == DamageCause.FALL && mcPermissions.getInstance().acrobatics(player))
Player player = (Player)x;
if(type == DamageCause.FALL){
Acrobatics.acrobaticsCheck(player, event); Acrobatics.acrobaticsCheck(player, event);
} /*
* Demolitions Expert
*/
if(cause == DamageCause.BLOCK_EXPLOSION && mcPermissions.getInstance().blastmining(player))
BlastMining.demolitionsExpertise(player, event);
} }
/* /*
@ -153,13 +142,12 @@ public class mcEntityListener implements Listener
{ {
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event; EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event;
Entity f = eventb.getDamager(); Entity f = eventb.getDamager();
Entity e = event.getEntity();
/* /*
* PARTY CHECKS * PARTY CHECKS
*/ */
if(e instanceof Player && f instanceof Player) if(entity instanceof Player && f instanceof Player)
{ {
Player defender = (Player)e; Player defender = (Player)entity;
Player attacker = (Player)f; Player attacker = (Player)f;
if(Party.getInstance().inSameParty(defender, attacker)) if(Party.getInstance().inSameParty(defender, attacker))
event.setCancelled(true); event.setCancelled(true);
@ -169,9 +157,9 @@ public class mcEntityListener implements Listener
/* /*
* Check to see if the defender took damage so we can apply recently hurt * Check to see if the defender took damage so we can apply recently hurt
*/ */
if(event.getEntity() instanceof Player) if(entity instanceof Player)
{ {
Player herpderp = (Player)event.getEntity(); Player herpderp = (Player)entity;
if(!event.isCancelled() && event.getDamage() >= 1) if(!event.isCancelled() && event.getDamage() >= 1)
{ {
Users.getProfile(herpderp).setRecentlyHurt(System.currentTimeMillis()); Users.getProfile(herpderp).setRecentlyHurt(System.currentTimeMillis());

View File

@ -29,8 +29,6 @@ import com.gmail.nossr50.datatypes.SkillType;
public class Acrobatics { public class Acrobatics {
public static void acrobaticsCheck(Player player, EntityDamageEvent event) public static void acrobaticsCheck(Player player, EntityDamageEvent event)
{
if(player != null && mcPermissions.getInstance().acrobatics(player))
{ {
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS); int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
@ -70,7 +68,6 @@ public class Acrobatics {
} }
} }
} }
}
public static void dodgeChecks(EntityDamageByEntityEvent event){ public static void dodgeChecks(EntityDamageByEntityEvent event){
Player defender = (Player) event.getEntity(); Player defender = (Player) event.getEntity();
PlayerProfile PPd = Users.getProfile(defender); PlayerProfile PPd = Users.getProfile(defender);