Search in sources :

Example 76 with EventHandler

use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.

the class EntityExitsVehicleScriptEvent method onEntityExitsVehicle.

@EventHandler
public void onEntityExitsVehicle(VehicleExitEvent event) {
    vehicle = new dEntity(event.getVehicle());
    entity = new dEntity(event.getExited());
    this.event = event;
    cancelled = event.isCancelled();
    fire();
    event.setCancelled(cancelled);
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) EventHandler(org.bukkit.event.EventHandler)

Example 77 with EventHandler

use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.

the class EntityExplodesScriptEvent method onEntityExplodes.

@EventHandler
public void onEntityExplodes(EntityExplodeEvent event) {
    entity = new dEntity(event.getEntity());
    location = new dLocation(event.getLocation());
    strength = event.getYield();
    blocks = new dList();
    blockSet = false;
    for (Block block : event.blockList()) {
        blocks.add(new dLocation(block.getLocation()).identifySimple());
    }
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
    if (blockSet) {
        event.blockList().clear();
        if (blocks.size() > 0) {
            event.blockList().clear();
            for (String loc : blocks) {
                dLocation location = dLocation.valueOf(loc);
                event.blockList().add(location.getWorld().getBlockAt(location));
            }
        }
    }
    event.setYield(strength);
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) Block(org.bukkit.block.Block) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) EventHandler(org.bukkit.event.EventHandler)

Example 78 with EventHandler

use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.

the class EntityFoodLevelChangeScriptEvent method onEntityFoodLevelChanged.

@EventHandler
public void onEntityFoodLevelChanged(FoodLevelChangeEvent event) {
    entity = new dEntity(event.getEntity());
    food = event.getFoodLevel();
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
    event.setFoodLevel(food);
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) EventHandler(org.bukkit.event.EventHandler)

Example 79 with EventHandler

use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.

the class EntityGlideScriptEvent method onEntityToggleGlide.

@EventHandler
public void onEntityToggleGlide(EntityToggleGlideEvent event) {
    entity = new dEntity(event.getEntity());
    state = event.isGliding();
    cancelled = event.isCancelled();
    fire();
    event.setCancelled(cancelled);
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) EventHandler(org.bukkit.event.EventHandler)

Example 80 with EventHandler

use of org.bukkit.event.EventHandler in project Denizen-For-Bukkit by DenizenScript.

the class AssignmentTrait method onHit.

// <--[action]
// @Actions
// hit
// hit on <entity>
//
// @Triggers when the NPC hits an enemy.
//
// @Context
// None
//
// -->
// <--[action]
// @Actions
// kill
// kill of <entity>
//
// @Triggers when the NPC kills an enemy.
//
// @Context
// None
//
// -->
// Listen for this NPC's hits on entities
@EventHandler(priority = EventPriority.MONITOR)
public void onHit(EntityDamageByEntityEvent event) {
    // Check if the damager is this NPC
    if (event.getDamager() != npc.getEntity()) {
        // projectile shot by this NPC, in which case we want to continue
        if (event.getDamager() instanceof Projectile) {
            if (((Projectile) event.getDamager()).getShooter() != npc.getEntity()) {
                return;
            }
        } else {
            return;
        }
    }
    dPlayer player = null;
    // Check if the entity hit by this NPC is a player
    if (event.getEntity() instanceof Player) {
        player = dPlayer.mirrorBukkitPlayer((Player) event.getEntity());
    }
    // TODO: Context containing the entity hit
    DenizenAPI.getDenizenNPC(npc).action("hit", player);
    DenizenAPI.getDenizenNPC(npc).action("hit on " + event.getEntityType().name(), player);
    if (event.getEntity() instanceof LivingEntity) {
        if (((LivingEntity) event.getEntity()).getHealth() - event.getFinalDamage() <= 0) {
            DenizenAPI.getDenizenNPC(npc).action("kill", player);
            DenizenAPI.getDenizenNPC(npc).action("kill of " + event.getEntityType().name(), player);
        }
    }
// All done!
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) net.aufdemrand.denizen.objects.dPlayer(net.aufdemrand.denizen.objects.dPlayer) Player(org.bukkit.entity.Player) net.aufdemrand.denizen.objects.dPlayer(net.aufdemrand.denizen.objects.dPlayer) Projectile(org.bukkit.entity.Projectile) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EventHandler (org.bukkit.event.EventHandler)532 Player (org.bukkit.entity.Player)185 Entity (org.bukkit.entity.Entity)70 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)67 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)62 Block (org.bukkit.block.Block)62 ItemStack (org.bukkit.inventory.ItemStack)55 Location (org.bukkit.Location)54 Island (com.wasteofplastic.acidisland.Island)42 Element (net.aufdemrand.denizencore.objects.Element)38 LivingEntity (org.bukkit.entity.LivingEntity)37 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 Projectile (org.bukkit.entity.Projectile)26 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)23 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)22 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)18 ArrayList (java.util.ArrayList)18