Search in sources :

Example 41 with Element

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

the class ItemAttributeNBT method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("nbt_attributes")) {
        dList list = mechanism.getValue().asType(dList.class);
        ItemStack itemStack = item.getItemStack();
        for (String string : list) {
            String[] split = string.split("/");
            String attribute = EscapeTags.unEscape(split[0]);
            String slot = EscapeTags.unEscape(split[1]);
            int op = new Element(split[2]).asInt();
            double amt = new Element(split[3]).asDouble();
            itemStack = CustomNBT.addAttribute(itemStack, attribute, slot, op, amt);
        }
        item.setItemStack(itemStack);
    }
}
Also used : net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) Element(net.aufdemrand.denizencore.objects.Element) ItemStack(org.bukkit.inventory.ItemStack)

Example 42 with Element

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

the class EntityBoundingBox method adjust.

@Override
public void adjust(Mechanism mechanism) {
    Element value = mechanism.getValue();
    if (mechanism.matches("bounding_box")) {
        if (entity.isCitizensNPC()) {
            // TODO: Allow editing NPC boxes properly?
            return;
        }
        List<dLocation> locations = value.asType(dList.class).filter(dLocation.class);
        if (locations.size() == 2) {
            BoundingBox boundingBox = new BoundingBox(locations.get(0).toVector(), locations.get(1).toVector());
            NMSHandler.getInstance().getEntityHelper().setBoundingBox(entity.getBukkitEntity(), boundingBox);
            modifiedBoxes.add(entity.getUUID());
        } else {
            dB.echoError("Must specify exactly 2 dLocations in the format '<low>|<high>'!");
        }
    }
}
Also used : Element(net.aufdemrand.denizencore.objects.Element) net.aufdemrand.denizencore.objects.dList(net.aufdemrand.denizencore.objects.dList) BoundingBox(net.aufdemrand.denizen.nms.util.BoundingBox) net.aufdemrand.denizen.objects.dLocation(net.aufdemrand.denizen.objects.dLocation)

Example 43 with Element

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

the class HorseJumpsScriptEvent method onHorseJumps.

@EventHandler
public void onHorseJumps(HorseJumpEvent event) {
    if (event.getEntity() instanceof Horse) {
        entity = new dEntity(event.getEntity());
        color = new Element(((Horse) event.getEntity()).getColor().name());
        variant = new Element(event.getEntity().getVariant().name());
        power = event.getPower();
        cancelled = event.isCancelled();
        this.event = event;
        fire();
        event.setCancelled(cancelled);
        event.setPower(power);
    }
}
Also used : net.aufdemrand.denizen.objects.dEntity(net.aufdemrand.denizen.objects.dEntity) Horse(org.bukkit.entity.Horse) Element(net.aufdemrand.denizencore.objects.Element) EventHandler(org.bukkit.event.EventHandler)

Example 44 with Element

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

the class PlayerEquipsArmorScriptEvent method fireUnequipsEvent.

private void fireUnequipsEvent(Player bukkitPlayer, String type, ItemStack oldItem, String reasonString) {
    equipType = new Element("unequips");
    armorType = new Element(type);
    reason = new Element(reasonString);
    armor = new dItem(oldItem);
    player = dPlayer.mirrorBukkitPlayer(bukkitPlayer);
    fire();
}
Also used : net.aufdemrand.denizen.objects.dItem(net.aufdemrand.denizen.objects.dItem) Element(net.aufdemrand.denizencore.objects.Element)

Example 45 with Element

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

the class PlayerEquipsArmorScriptEvent method fireEquipsEvent.

private void fireEquipsEvent(Player bukkitPlayer, String type, ItemStack newItem, String reasonString) {
    equipType = new Element("equips");
    armorType = new Element(type);
    reason = new Element(reasonString);
    armor = new dItem(newItem);
    player = dPlayer.mirrorBukkitPlayer(bukkitPlayer);
    fire();
}
Also used : net.aufdemrand.denizen.objects.dItem(net.aufdemrand.denizen.objects.dItem) Element(net.aufdemrand.denizencore.objects.Element)

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