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);
}
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);
}
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);
}
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);
}
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!
}
Aggregations