mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Optimize more things.
This commit is contained in:
parent
1fe259eb7a
commit
10fa9e5465
@ -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);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* ACROBATICS
|
if(entity instanceof Player){
|
||||||
*/
|
Player player = (Player)entity;
|
||||||
if(x instanceof Player){
|
/*
|
||||||
Player player = (Player)x;
|
* ACROBATICS
|
||||||
if(type == DamageCause.FALL){
|
*/
|
||||||
|
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))
|
||||||
|
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());
|
||||||
|
@ -30,46 +30,43 @@ 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);
|
||||||
{
|
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
|
||||||
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
|
|
||||||
|
|
||||||
if(player.isSneaking())
|
if(player.isSneaking())
|
||||||
acrovar = acrovar * 2;
|
acrovar = acrovar * 2;
|
||||||
|
|
||||||
if(Math.random() * 1000 <= acrovar && !event.isCancelled())
|
if(Math.random() * 1000 <= acrovar && !event.isCancelled())
|
||||||
{
|
{
|
||||||
int threshold = 7;
|
int threshold = 7;
|
||||||
if(player.isSneaking())
|
if(player.isSneaking())
|
||||||
threshold = 14;
|
threshold = 14;
|
||||||
|
|
||||||
int newDamage = event.getDamage() - threshold;
|
int newDamage = event.getDamage() - threshold;
|
||||||
if(newDamage < 0)
|
if(newDamage < 0)
|
||||||
newDamage = 0;
|
newDamage = 0;
|
||||||
/*
|
/*
|
||||||
* Check for death
|
* Check for death
|
||||||
*/
|
*/
|
||||||
if(player.getHealth() - newDamage >= 1){
|
if(player.getHealth() - newDamage >= 1){
|
||||||
if(!event.isCancelled())
|
if(!event.isCancelled())
|
||||||
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 8)*10, player);
|
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 8)*10, player);
|
||||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||||
event.setDamage(newDamage);
|
event.setDamage(newDamage);
|
||||||
if(event.getDamage() <= 0)
|
if(event.getDamage() <= 0)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if(player.isSneaking()){
|
if(player.isSneaking()){
|
||||||
player.sendMessage(ChatColor.GREEN+"**GRACEFUL ROLL**");
|
player.sendMessage(ChatColor.GREEN+"**GRACEFUL ROLL**");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage("**ROLL**");
|
player.sendMessage("**ROLL**");
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (!event.isCancelled()){
|
|
||||||
if(player.getHealth() - event.getDamage() >= 1){
|
|
||||||
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*10, player);
|
|
||||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (!event.isCancelled()){
|
||||||
|
if(player.getHealth() - event.getDamage() >= 1){
|
||||||
|
PP.addXP(SkillType.ACROBATICS, (event.getDamage() * 12)*10, player);
|
||||||
|
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static void dodgeChecks(EntityDamageByEntityEvent event){
|
public static void dodgeChecks(EntityDamageByEntityEvent event){
|
||||||
Player defender = (Player) event.getEntity();
|
Player defender = (Player) event.getEntity();
|
||||||
|
Loading…
Reference in New Issue
Block a user