Search in sources :

Example 26 with EventHandler

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));
        }
    }
}
Also used : EventHandler(org.bukkit.event.EventHandler) Method(java.lang.reflect.Method)

Example 27 with EventHandler

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);
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Block(org.bukkit.block.Block) Material(org.bukkit.Material) Projectile(org.bukkit.entity.Projectile) EventHandler(org.bukkit.event.EventHandler)

Example 28 with EventHandler

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));
    }
}
Also used : Entity(org.bukkit.entity.Entity) Random(java.util.Random) EventHandler(org.bukkit.event.EventHandler)

Example 29 with EventHandler

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);
    }
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 30 with EventHandler

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);
    }
}
Also used : Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EventHandler (org.bukkit.event.EventHandler)409 Player (org.bukkit.entity.Player)126 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)67 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)62 Entity (org.bukkit.entity.Entity)58 Block (org.bukkit.block.Block)47 Location (org.bukkit.Location)43 Element (net.aufdemrand.denizencore.objects.Element)38 ItemStack (org.bukkit.inventory.ItemStack)33 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)31 Minigame (au.com.mineauz.minigames.minigame.Minigame)29 net.aufdemrand.denizen.objects.dItem (net.aufdemrand.denizen.objects.dItem)29 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)28 LivingEntity (org.bukkit.entity.LivingEntity)24 Projectile (org.bukkit.entity.Projectile)19 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)18 FPlayer (me.totalfreedom.totalfreedommod.player.FPlayer)15 BlockState (org.bukkit.block.BlockState)15 User (com.earth2me.essentials.User)14 net.aufdemrand.denizen.objects.dPlayer (net.aufdemrand.denizen.objects.dPlayer)14