Search in sources :

Example 96 with Element

use of net.aufdemrand.denizencore.objects.Element in project Denizen-For-Bukkit by DenizenScript.

the class PlayerBreaksBlockScriptEvent method onPlayerBreaksBlock.

@EventHandler
public void onPlayerBreaksBlock(BlockBreakEvent event) {
    if (dEntity.isNPC(event.getPlayer())) {
        return;
    }
    material = dMaterial.getMaterialFrom(event.getBlock().getType(), event.getBlock().getData());
    location = new dLocation(event.getBlock().getLocation());
    cuboids = new dList();
    for (dCuboid cuboid : dCuboid.getNotableCuboidsContaining(location)) {
        cuboids.add(cuboid.identifySimple());
    }
    cancelled = event.isCancelled();
    xp = new Element(event.getExpToDrop());
    this.event = event;
    fire();
    event.setCancelled(cancelled);
    event.setExpToDrop(xp.asInt());
}
Also used : net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) Element(net.aufdemrand.denizencore.objects.Element) EventHandler(org.bukkit.event.EventHandler)

Example 97 with Element

use of net.aufdemrand.denizencore.objects.Element in project Denizen-For-Bukkit by DenizenScript.

the class PlayerChangesGamemodeScriptEvent method onPlayerChangesGamemode.

@EventHandler
public void onPlayerChangesGamemode(PlayerGameModeChangeEvent event) {
    if (dEntity.isNPC(event.getPlayer())) {
        return;
    }
    gamemode = new Element(event.getNewGameMode().name());
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
}
Also used : Element(net.aufdemrand.denizencore.objects.Element) EventHandler(org.bukkit.event.EventHandler)

Example 98 with Element

use of net.aufdemrand.denizencore.objects.Element in project Denizen-For-Bukkit by DenizenScript.

the class EntityKilledScriptEvent method onEntityKilled.

@EventHandler
public void onEntityKilled(EntityDamageEvent event) {
    entity = new dEntity(event.getEntity());
    // Check for possibility of death first
    if (entity.isValid() && entity.isLivingEntity()) {
        if (event.getFinalDamage() < entity.getLivingEntity().getHealth()) {
            return;
        }
    } else {
        return;
    }
    damage = new Element(event.getDamage());
    final_damage = new Element(event.getFinalDamage());
    cause = new Element(CoreUtilities.toLowerCase(event.getCause().name()));
    damager = null;
    projectile = null;
    if (event instanceof EntityDamageByEntityEvent) {
        damager = new dEntity(((EntityDamageByEntityEvent) event).getDamager());
        if (damager.isProjectile()) {
            projectile = damager;
            if (damager.hasShooter()) {
                damager = damager.getShooter();
            }
        }
    }
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
    event.setDamage(damage.asDouble());
}
Also used : EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Element(net.aufdemrand.denizencore.objects.Element) EventHandler(org.bukkit.event.EventHandler)

Example 99 with Element

use of net.aufdemrand.denizencore.objects.Element in project Denizen-For-Bukkit by DenizenScript.

the class EntityUnleashedScriptEvent method onEntityUnleashed.

@EventHandler
public void onEntityUnleashed(EntityUnleashEvent event) {
    entity = new dEntity(event.getEntity());
    reason = new Element(event.getReason().toString());
    this.event = event;
    fire();
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Element(net.aufdemrand.denizencore.objects.Element) EventHandler(org.bukkit.event.EventHandler)

Example 100 with Element

use of net.aufdemrand.denizencore.objects.Element in project Denizen-For-Bukkit by DenizenScript.

the class HangingBreaksScriptEvent method onHangingBreaks.

@EventHandler
public void onHangingBreaks(HangingBreakEvent event) {
    hanging = new dEntity(event.getEntity());
    cause = new Element(event.getCause().name());
    location = new dLocation(hanging.getLocation());
    if (event instanceof HangingBreakByEntityEvent) {
        entity = new dEntity(((HangingBreakByEntityEvent) event).getRemover());
    }
    cuboids = new dList();
    for (dCuboid cuboid : dCuboid.getNotableCuboidsContaining(location)) {
        cuboids.add(cuboid.identifySimple());
    }
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
}
Also used : HangingBreakByEntityEvent(org.bukkit.event.hanging.HangingBreakByEntityEvent) net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Element(net.aufdemrand.denizencore.objects.Element) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) net.aufdemrand.denizen.objects.dCuboid(net.aufdemrand.denizen.objects.dCuboid) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Element (net.aufdemrand.denizencore.objects.Element)166 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)74 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)49 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)46 BukkitScriptEntryData (net.aufdemrand.denizen.BukkitScriptEntryData)38 InvalidArgumentsException (net.aufdemrand.denizencore.exceptions.InvalidArgumentsException)38 EventHandler (org.bukkit.event.EventHandler)38 List (java.util.List)29 net.aufdemrand.denizencore.objects.aH (net.aufdemrand.denizencore.objects.aH)28 net.aufdemrand.denizen.objects.dPlayer (net.aufdemrand.denizen.objects.dPlayer)27 net.aufdemrand.denizencore.objects.dObject (net.aufdemrand.denizencore.objects.dObject)21 Duration (net.aufdemrand.denizencore.objects.Duration)20 CommandExecutionException (net.aufdemrand.denizencore.exceptions.CommandExecutionException)16 ArrayList (java.util.ArrayList)14 net.aufdemrand.denizen.objects.dItem (net.aufdemrand.denizen.objects.dItem)14 net.aufdemrand.denizen.objects.dNPC (net.aufdemrand.denizen.objects.dNPC)14 Player (org.bukkit.entity.Player)11 net.aufdemrand.denizen.objects.dWorld (net.aufdemrand.denizen.objects.dWorld)10 net.aufdemrand.denizencore.objects.dScript (net.aufdemrand.denizencore.objects.dScript)10 ScriptEntry (net.aufdemrand.denizencore.scripts.ScriptEntry)9