/** * Monitor EntityExplode events. * * @param event The event to monitor */ @EventHandler(priority = EventPriority.HIGHEST) public void onEnitityExplode(EntityExplodeEvent event) { Entity entity = event.getEntity(); if (event.getEntity() instanceof TNTPrimed) { int id = entity.getEntityId(); if (plugin.tntTracker.containsKey(id)) { Player player = plugin.tntTracker.get(id); BlastMining.dropProcessing(player, event); plugin.tntTracker.remove(id); } } }
/** * Monitor EntityDamage events. * * @param event The event to monitor */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { if (event instanceof FakeEntityDamageEvent) { return; } Entity entity = event.getEntity(); EntityType type = entity.getType(); DamageCause cause = event.getCause(); switch (type) { case PLAYER: /* Check for invincibility */ Player player = (Player) entity; PlayerProfile PP = Users.getProfile(player); if (PP.getGodMode()) { event.setCancelled(true); return; } if (!m.isInvincible(player, event)) { if (cause == DamageCause.FALL && mcPermissions.getInstance().acrobatics(player)) { Acrobatics.acrobaticsCheck(player, event); } else if (cause == DamageCause.BLOCK_EXPLOSION && mcPermissions.getInstance().demolitionsExpertise(player)) { BlastMining.demolitionsExpertise(player, event); } if (event.getDamage() >= 1) { PP.setRecentlyHurt(System.currentTimeMillis()); } } break; case WOLF: Wolf wolf = (Wolf) entity; if ((!m.isInvincible(wolf, event)) && wolf.isTamed() && (wolf.getOwner() instanceof Player)) { Taming.preventDamage(event); } break; default: break; } }
/** * Monitor ExplosionPrime events. * * @param event The event to monitor */ @EventHandler(priority = EventPriority.LOW) public void onExplosionPrime(ExplosionPrimeEvent event) { Entity entity = event.getEntity(); if (entity instanceof TNTPrimed) { int id = entity.getEntityId(); if (plugin.tntTracker.containsKey(id)) { Player player = plugin.tntTracker.get(id); if (mcPermissions.getInstance().biggerBombs(player)) { BlastMining.biggerBombs(player, event); } } } }