Search in sources :

Example 71 with ListTag

use of com.denizenscript.denizencore.objects.core.ListTag in project Denizen-For-Bukkit by DenizenScript.

the class EntityAge method adjust.

@Override
public void adjust(Mechanism mechanism) {
    // -->
    if (mechanism.matches("age_lock") && mechanism.requireBoolean()) {
        setLock(mechanism.getValue().asBoolean());
    }
    // -->
    if (mechanism.matches("age") && mechanism.requireObject(ListTag.class)) {
        ListTag list = mechanism.valueAsType(ListTag.class);
        if (list.isEmpty()) {
            mechanism.echoError("Missing value for 'age' mechanism!");
            return;
        }
        String input = list.get(0);
        if (input.equalsIgnoreCase("baby")) {
            setAge(-24000);
        } else if (input.equalsIgnoreCase("adult")) {
            setAge(0);
        } else if (ArgumentHelper.matchesInteger(input)) {
            setAge(new ElementTag(input).asInt());
        } else {
            mechanism.echoError("Invalid age '" + input + "': must be 'baby', 'adult', or a valid age number.");
        }
        if (list.size() > 1) {
            input = list.get(1);
            if (input.equalsIgnoreCase("locked")) {
                setLock(true);
            } else if (input.equalsIgnoreCase("unlocked")) {
                setLock(false);
            } else {
                mechanism.echoError("Invalid lock state '" + input + "': must be 'locked' or 'unlocked'.");
            }
        }
    }
}
Also used : ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 72 with ListTag

use of com.denizenscript.denizencore.objects.core.ListTag in project Denizen-For-Bukkit by DenizenScript.

the class EntityBoundingBox method getBoundingBox.

private ListTag getBoundingBox() {
    BoundingBox boundingBox = NMSHandler.getEntityHelper().getBoundingBox(entity.getBukkitEntity());
    ListTag list = new ListTag();
    list.addObject(new LocationTag(boundingBox.getLow().toLocation(entity.getWorld())));
    list.addObject(new LocationTag(boundingBox.getHigh().toLocation(entity.getWorld())));
    return list;
}
Also used : LocationTag(com.denizenscript.denizen.objects.LocationTag) BoundingBox(com.denizenscript.denizen.nms.util.BoundingBox) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 73 with ListTag

use of com.denizenscript.denizencore.objects.core.ListTag in project Denizen-For-Bukkit by DenizenScript.

the class EntityDisabledSlots method getDisabledSlots.

private ListTag getDisabledSlots() {
    Map<EquipmentSlot, Set<Action>> map = CustomNBT.getDisabledSlots(dentity.getBukkitEntity());
    ListTag list = new ListTag();
    for (Map.Entry<EquipmentSlot, Set<Action>> entry : map.entrySet()) {
        for (Action action : entry.getValue()) {
            list.add(CoreUtilities.toLowerCase(entry.getKey().name() + "/" + action.name()));
        }
    }
    return list;
}
Also used : EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 74 with ListTag

use of com.denizenscript.denizencore.objects.core.ListTag in project Denizen-For-Bukkit by DenizenScript.

the class PaperTagBase method paperTag.

public void paperTag(ReplaceableTagEvent event) {
    if (!event.matches("paper") || event.replaced()) {
        return;
    }
    Attribute attribute = event.getAttributes().fulfill(1);
    // -->
    if (attribute.startsWith("tick_times")) {
        ListTag list = new ListTag();
        for (long time : Bukkit.getServer().getTickTimes()) {
            list.addObject(new DurationTag(time / 1000000000D));
        }
        event.setReplacedObject(list.getObjectAttribute(attribute.fulfill(1)));
        return;
    }
}
Also used : Attribute(com.denizenscript.denizencore.tags.Attribute) DurationTag(com.denizenscript.denizencore.objects.core.DurationTag) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Example 75 with ListTag

use of com.denizenscript.denizencore.objects.core.ListTag in project Denizen-For-Bukkit by DenizenScript.

the class FollowCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) {
    ElementTag stop = scriptEntry.getElement("stop");
    ElementTag lead = scriptEntry.getElement("lead");
    ElementTag maxRange = scriptEntry.getElement("max");
    ElementTag allowWander = scriptEntry.getElement("allow_wander");
    ElementTag speed = scriptEntry.getElement("speed");
    ElementTag noTeleport = scriptEntry.getElement("no_teleport");
    ListTag entities = scriptEntry.getObjectTag("entities");
    EntityTag target = scriptEntry.getObjectTag("target");
    if (scriptEntry.dbCallShouldDebug()) {
        Debug.report(scriptEntry, getName(), Utilities.getEntryPlayer(scriptEntry), (!stop.asBoolean() ? db("Action", "FOLLOW") : db("Action", "STOP")), lead, noTeleport, maxRange, allowWander, entities, target);
    }
    for (EntityTag entity : entities.filter(EntityTag.class, scriptEntry)) {
        if (entity.isCitizensNPC()) {
            NPCTag npc = entity.getDenizenNPC();
            if (lead != null) {
                npc.getNavigator().getLocalParameters().distanceMargin(lead.asDouble());
            }
            if (speed != null) {
                npc.getNavigator().getLocalParameters().speedModifier(speed.asFloat());
            }
            if (noTeleport != null && noTeleport.asBoolean()) {
                npc.getNavigator().getLocalParameters().stuckAction(null);
            }
            if (stop.asBoolean()) {
                npc.getNavigator().cancelNavigation();
            } else {
                npc.getNavigator().setTarget(target.getBukkitEntity(), false);
            }
        } else {
            if (stop.asBoolean()) {
                NMSHandler.getEntityHelper().stopFollowing(entity.getBukkitEntity());
            } else {
                NMSHandler.getEntityHelper().follow(target.getBukkitEntity(), entity.getBukkitEntity(), speed != null ? speed.asDouble() : 0.3, lead != null ? lead.asDouble() : 5, maxRange != null ? maxRange.asDouble() : 8, allowWander.asBoolean(), noTeleport == null || !noTeleport.asBoolean());
            }
        }
    }
}
Also used : NPCTag(com.denizenscript.denizen.objects.NPCTag) EntityTag(com.denizenscript.denizen.objects.EntityTag) ElementTag(com.denizenscript.denizencore.objects.core.ElementTag) ListTag(com.denizenscript.denizencore.objects.core.ListTag)

Aggregations

ListTag (com.denizenscript.denizencore.objects.core.ListTag)122 ElementTag (com.denizenscript.denizencore.objects.core.ElementTag)71 MapTag (com.denizenscript.denizencore.objects.core.MapTag)21 ItemStack (org.bukkit.inventory.ItemStack)18 EntityTag (com.denizenscript.denizen.objects.EntityTag)16 ObjectTag (com.denizenscript.denizencore.objects.ObjectTag)14 List (java.util.List)14 ItemTag (com.denizenscript.denizen.objects.ItemTag)13 PlayerTag (com.denizenscript.denizen.objects.PlayerTag)13 Player (org.bukkit.entity.Player)13 DurationTag (com.denizenscript.denizencore.objects.core.DurationTag)12 LocationTag (com.denizenscript.denizen.objects.LocationTag)11 NPCTag (com.denizenscript.denizen.objects.NPCTag)9 InvalidArgumentsException (com.denizenscript.denizencore.exceptions.InvalidArgumentsException)9 ArrayList (java.util.ArrayList)9 ScriptTag (com.denizenscript.denizencore.objects.core.ScriptTag)8 MaterialTag (com.denizenscript.denizen.objects.MaterialTag)7 ScriptEntry (com.denizenscript.denizencore.scripts.ScriptEntry)7 NPC (net.citizensnpcs.api.npc.NPC)7 Entity (org.bukkit.entity.Entity)7