Search in sources :

Example 46 with Element

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

the class PlayerItemTakesDamageScriptEvent method onPlayerItemTakesDamage.

@EventHandler
public void onPlayerItemTakesDamage(PlayerItemDamageEvent event) {
    if (dEntity.isNPC(event.getPlayer())) {
        return;
    }
    item = new dItem(event.getItem());
    damage = new Element(event.getDamage());
    location = new dLocation(event.getPlayer().getLocation());
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
    event.setDamage(damage.asInt());
    final Player p = event.getPlayer();
    if (cancelled) {
        Bukkit.getScheduler().scheduleSyncDelayedTask(DenizenAPI.getCurrentInstance(), new Runnable() {

            @Override
            public void run() {
                p.updateInventory();
            }
        }, 1);
    }
}
Also used : net.aufdemrand.denizen.objects.dPlayer(net.aufdemrand.denizen.objects.dPlayer) Player(org.bukkit.entity.Player) net.aufdemrand.denizen.objects.dItem(net.aufdemrand.denizen.objects.dItem) Element(net.aufdemrand.denizencore.objects.Element) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation) EventHandler(org.bukkit.event.EventHandler)

Example 47 with Element

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

the class LingeringPotionSplashScriptEvent method onLingeringPotionSplash.

@EventHandler
public void onLingeringPotionSplash(LingeringPotionSplashEvent event) {
    AreaEffectCloud cloud = event.getAreaEffectCloud();
    item = new dItem(event.getEntity().getItem());
    duration = new Element(cloud.getDuration());
    entity = new dEntity(event.getEntity());
    location = entity.getLocation();
    radius = new Element(cloud.getRadius());
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
}
Also used : net.aufdemrand.denizen.objects.dItem(net.aufdemrand.denizen.objects.dItem) net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Element(net.aufdemrand.denizencore.objects.Element) AreaEffectCloud(org.bukkit.entity.AreaEffectCloud) EventHandler(org.bukkit.event.EventHandler)

Example 48 with Element

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

the class PlayerEditsBookScriptEvent method onPlayerEditsBook.

@EventHandler
public void onPlayerEditsBook(PlayerEditBookEvent event) {
    player = dPlayer.mirrorBukkitPlayer(event.getPlayer());
    signing = new Element(event.isSigning());
    bookMeta = event.getNewBookMeta();
    pages = new Element(bookMeta.getPageCount());
    title = event.isSigning() ? new Element(bookMeta.getTitle()) : null;
    book = new dItem(event.getPlayer().getInventory().getItem(event.getSlot()));
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
    event.setNewBookMeta(bookMeta);
    event.setSigning(signing.asBoolean());
}
Also used : net.aufdemrand.denizen.objects.dItem(net.aufdemrand.denizen.objects.dItem) Element(net.aufdemrand.denizencore.objects.Element) EventHandler(org.bukkit.event.EventHandler)

Example 49 with Element

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

the class PlayerReceivesMessageScriptEvent method applyDetermination.

@Override
public boolean applyDetermination(ScriptContainer container, String determination) {
    String lower = CoreUtilities.toLowerCase(determination);
    if (lower.startsWith("message:")) {
        message = new Element(determination.substring("message:".length()));
        messageModified = true;
        return true;
    }
    if (lower.startsWith("raw_json:")) {
        rawJson = new Element(determination.substring("raw_json:".length()));
        rawJsonModified = true;
        return true;
    }
    return super.applyDetermination(container, determination);
}
Also used : Element(net.aufdemrand.denizencore.objects.Element)

Example 50 with Element

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

the class EntityHealsScriptEvent method onEntityHeals.

@EventHandler
public void onEntityHeals(EntityRegainHealthEvent event) {
    entity = new dEntity(event.getEntity());
    amount = new Element(event.getAmount());
    reason = new Element(event.getRegainReason().toString());
    cancelled = event.isCancelled();
    this.event = event;
    fire();
    event.setCancelled(cancelled);
    event.setAmount(amount.asDouble());
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Element(net.aufdemrand.denizencore.objects.Element) 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