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'.");
}
}
}
}
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;
}
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;
}
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;
}
}
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());
}
}
}
}
Aggregations