use of org.bukkit.entity.LivingEntity in project NoCheatPlus by NoCheatPlus.
the class MCAccessSpigotCB1_8_R2 method getHeight.
@Override
public double getHeight(final Entity entity) {
final net.minecraft.server.v1_8_R2.Entity mcEntity = ((CraftEntity) entity).getHandle();
AxisAlignedBB boundingBox = mcEntity.getBoundingBox();
final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.getHeadHeight(), boundingBox.e - boundingBox.b));
if (entity instanceof LivingEntity) {
return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
} else
return entityHeight;
}
use of org.bukkit.entity.LivingEntity in project NoCheatPlus by NoCheatPlus.
the class MCAccessSpigotCB1_9_R1 method getHeight.
@Override
public double getHeight(final Entity entity) {
final net.minecraft.server.v1_9_R1.Entity mcEntity = ((CraftEntity) entity).getHandle();
AxisAlignedBB boundingBox = mcEntity.getBoundingBox();
final double entityHeight = Math.max(mcEntity.length, Math.max(mcEntity.getHeadHeight(), boundingBox.e - boundingBox.b));
if (entity instanceof LivingEntity) {
return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
} else
return entityHeight;
}
use of org.bukkit.entity.LivingEntity in project NoCheatPlus by NoCheatPlus.
the class RichEntityLocation method doSet.
/**
* Do set.<br>
* For the bounding box height, the maximum of given fullHeight, eyeHeight
* with sneaking ignored and entity height is used. Sets isLiving and
* eyeHeight.
*
* @param location
* the location
* @param entity
* the entity
* @param fullWidth
* the full width
* @param fullHeight
* the full height
* @param yOnGround
* the y on ground
*/
protected void doSet(final Location location, final Entity entity, final double fullWidth, double fullHeight, final double yOnGround) {
final double eyeHeight;
final boolean isLiving;
if (entity instanceof LivingEntity) {
isLiving = true;
final LivingEntity living = (LivingEntity) entity;
eyeHeight = living.getEyeHeight();
fullHeight = Math.max(Math.max(fullHeight, eyeHeight), living.getEyeHeight(true));
} else {
isLiving = false;
eyeHeight = fullHeight;
}
doSetExactHeight(location, entity, isLiving, fullWidth, eyeHeight, fullHeight, fullHeight, yOnGround);
}
use of org.bukkit.entity.LivingEntity in project Skills by StarTux.
the class BukkitSkillHunt method onEntityDamageByEntity.
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof LivingEntity))
return;
LivingEntity entity = (LivingEntity) event.getEntity();
if (!(event.getDamager() instanceof Arrow))
return;
Arrow arrow = (Arrow) event.getDamager();
if (!(arrow.getShooter() instanceof Player))
return;
Player player = (Player) arrow.getShooter();
if (!allowPlayer(player))
return;
if (entity.getCustomName() != null && entity.getCustomName().startsWith("" + ChatColor.COLOR_CHAR))
return;
if (BukkitExploits.getInstance().recentKillDistance(player, entity.getLocation(), killDistanceInterval) < minKillDistance)
return;
double percentage = BukkitExploits.getInstance().getEntityDamageByPlayerRemainderPercentage(entity, Math.min(entity.getHealth(), event.getFinalDamage()));
if (getSkills().hasDebugMode(player))
BukkitUtil.msg(player, "&eHunt Dmg=%.02f/%.02f Pct=%.02f", event.getFinalDamage(), entity.getMaxHealth(), percentage);
giveReward(player, rewardForEntity(entity), percentage);
}
use of org.bukkit.entity.LivingEntity in project Ublisk by Derkades.
the class EntityDeath method entityDeath.
@EventHandler
public void entityDeath(EntityDeathEvent event) {
// Never let the entity drop any XP on death
event.setDroppedExp(0);
LivingEntity entity = event.getEntity();
if (entity.getType() == EntityType.PLAYER) {
return;
}
if (entity.getLastDamageCause().getCause() != DamageCause.ENTITY_ATTACK) {
return;
}
if (!Mobs.getEntityTypes().contains(entity.getType())) {
return;
}
// Now we know that the entity has been killed by the player, so it is safe to call getKiller()
UPlayer player = new UPlayer(entity.getKiller());
// Track player kills for statistics
player.tracker(PlayerInfo.MOB_KILLS);
if (!Mobs.SPAWNED_MOBS.containsKey(entity.getUniqueId())) {
player.sendActionBarMessage(ChatColor.RED + "Error :(", 0);
}
// Get mob from entity UUID
Mob mob = Mobs.SPAWNED_MOBS.get(entity.getUniqueId());
// Drop gold and items
if (mob.getMobDrops().length > 0) {
for (MobDrop drop : mob.getMobDrops()) drop.drop(entity.getLocation());
}
for (MobDrop drop : mob.getGoldDrop().getMobDrops()) drop.drop(entity.getLocation());
String name = mob.getName();
String color;
int xp;
if (DoubleXP.isActive()) {
xp = mob.getXP() * 2;
color = ChatColor.GOLD.toString();
} else {
xp = mob.getXP();
color = ChatColor.GREEN.toString();
}
player.sendActionBarMessage(color + "+ " + xp + " XP", 15);
player.addXP(xp);
Logger.log(LogLevel.INFO, "XP", "Given " + player.getName() + " " + xp + " for killing a " + name);
}
Aggregations