use of org.bukkit.event.EventHandler in project AuthMeReloaded by AuthMe.
the class ListenerConsistencyTest method checkCanceledAttribute.
private static void checkCanceledAttribute(Class<?> listenerClass) {
final String clazz = listenerClass.getSimpleName();
Method[] methods = listenerClass.getDeclaredMethods();
for (Method method : methods) {
if (isTestableMethod(method) && method.isAnnotationPresent(EventHandler.class)) {
if (CANCELED_EXCEPTIONS.contains(clazz + "#" + method.getName())) {
continue;
}
EventHandler eventHandlerAnnotation = method.getAnnotation(EventHandler.class);
assertThat("Method " + clazz + "#" + method.getName() + " should have ignoreCancelled = true", eventHandlerAnnotation.ignoreCancelled(), equalTo(true));
}
}
}
use of org.bukkit.event.EventHandler in project EliteMobs by MagmaGuy.
the class AttackWeb method attackWeb.
@EventHandler
public void attackWeb(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Entity damagee = event.getEntity();
Block block = damagee.getLocation().getBlock();
Material originalMaterial = block.getType();
if (!originalMaterial.equals(Material.AIR)) {
return;
}
if (damager.hasMetadata(MetadataHandler.ATTACK_FREEZE_MD) || damager instanceof Projectile && ProjectileMetadataDetector.projectileMetadataDetector((Projectile) damager, MetadataHandler.ATTACK_FREEZE_MD)) {
return;
}
if (damagee.hasMetadata("WebCooldown")) {
return;
}
if (damager.hasMetadata(powerMetadata)) {
//if a block spawned by the plugin is already in place, skip effect
if (block.hasMetadata("TemporaryBlock")) {
return;
}
processID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
int counter = 0;
@Override
public void run() {
webEffectApplier(counter, damagee, block);
counter++;
}
}, 2, 1);
}
if (damager instanceof Projectile) {
if (ProjectileMetadataDetector.projectileMetadataDetector((Projectile) damager, powerMetadata)) {
processID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
int counter = 0;
@Override
public void run() {
webEffectApplier(counter, damagee, block);
counter++;
}
}, 1, 1);
}
}
}
use of org.bukkit.event.EventHandler in project EliteMobs by MagmaGuy.
the class BonusLoot method onDeath.
@EventHandler
public void onDeath(EntityDeathEvent event) {
if (event.getEntity().hasMetadata(powerMetadata)) {
Entity entity = event.getEntity();
Random random = new Random();
int randomDrop = random.nextInt(EliteDropsHandler.lootList.size());
entity.getWorld().dropItem(entity.getLocation(), EliteDropsHandler.lootList.get(randomDrop));
}
}
use of org.bukkit.event.EventHandler in project EliteMobs by MagmaGuy.
the class DropsHandler method onDeath.
@EventHandler
public void onDeath(EntityDeathEvent event) {
if (event.getEntity().hasMetadata(MetadataHandler.ELITE_MOB_MD) && !event.getEntity().hasMetadata(MetadataHandler.FORBIDDEN_MD) && event.getEntity().getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() > 1) {
List<ItemStack> droppedItems = event.getDrops();
int mobLevel = (int) (event.getEntity().getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() * ConfigValues.defaultConfig.getDouble("Aggressive EliteMob default loot multiplier"));
for (ItemStack itemStack : droppedItems) {
for (int i = 0; i < mobLevel; i++) {
event.getEntity().getLocation().getWorld().dropItem(event.getEntity().getLocation(), itemStack);
}
}
int droppedXP = event.getDroppedExp();
event.setDroppedExp(droppedXP * mobLevel);
}
}
use of org.bukkit.event.EventHandler in project EliteMobs by MagmaGuy.
the class Taunt method onDeath.
@EventHandler
public void onDeath(EntityDeathEvent event) {
if (event.getEntity().hasMetadata(powerMetadata)) {
Entity entity = event.getEntity();
nametagProcessor(entity, DEATH_LIST);
}
}
Aggregations