use of com.denizenscript.denizencore.utilities.text.StringHolder in project Denizen-For-Bukkit by DenizenScript.
the class EntityArmorPose method adjust.
@Override
public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("armor_pose")) {
ArmorStand armorStand = (ArmorStand) entity.getBukkitEntity();
if (mechanism.value.canBeType(MapTag.class)) {
MapTag map = mechanism.valueAsType(MapTag.class);
for (Map.Entry<StringHolder, ObjectTag> entry : map.map.entrySet()) {
PosePart posePart = PosePart.fromName(entry.getKey().str);
if (posePart == null) {
mechanism.echoError("Invalid pose part specified: " + entry.getKey().str);
} else {
posePart.setAngle(armorStand, toEulerAngle(entry.getValue().asType(LocationTag.class, mechanism.context)));
}
}
} else {
ListTag list = mechanism.valueAsType(ListTag.class);
Iterator<String> iterator = list.iterator();
while (iterator.hasNext()) {
String name = iterator.next();
String angle = iterator.next();
PosePart posePart = PosePart.fromName(name);
if (posePart == null) {
mechanism.echoError("Invalid pose part specified: " + name + "; ignoring next: " + angle);
} else {
posePart.setAngle(armorStand, toEulerAngle(LocationTag.valueOf(angle, mechanism.context)));
}
}
}
}
}
use of com.denizenscript.denizencore.utilities.text.StringHolder in project Denizen-For-Bukkit by DenizenScript.
the class EntityAttributeBaseValues method adjust.
@Override
public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("attribute_base_values") && mechanism.requireObject(MapTag.class)) {
MapTag input = mechanism.valueAsType(MapTag.class);
Attributable ent = getAttributable();
for (Map.Entry<StringHolder, ObjectTag> subValue : input.map.entrySet()) {
Attribute attr = Attribute.valueOf(subValue.getKey().str.toUpperCase());
AttributeInstance instance = ent.getAttribute(attr);
if (instance == null) {
mechanism.echoError("Attribute " + attr.name() + " is not applicable to entity of type " + entity.getBukkitEntityType().name());
continue;
}
ElementTag value = subValue.getValue().asElement();
if (!value.isDouble()) {
mechanism.echoError("Invalid input '" + value + "': must be a decimal number.");
continue;
}
instance.setBaseValue(value.asDouble());
}
}
}
use of com.denizenscript.denizencore.utilities.text.StringHolder in project Denizen-For-Bukkit by DenizenScript.
the class ItemRawNBT method setFullNBT.
public void setFullNBT(ItemTag item, MapTag input, TagContext context, boolean retainOld) {
CompoundTag compoundTag = retainOld ? NMSHandler.getItemHelper().getNbtData(item.getItemStack()) : null;
Map<String, Tag> result = compoundTag == null ? new LinkedHashMap<>() : new LinkedHashMap<>(compoundTag.getValue());
for (Map.Entry<StringHolder, ObjectTag> entry : input.map.entrySet()) {
try {
Tag tag = convertObjectToNbt(entry.getValue().toString(), context, "(item).");
if (tag != null) {
result.put(entry.getKey().str, tag);
}
} catch (Exception ex) {
Debug.echoError("Raw_Nbt input failed for root key '" + entry.getKey().str + "'.");
Debug.echoError(ex);
return;
}
}
compoundTag = NMSHandler.getInstance().createCompoundTag(result);
item.setItemStack(NMSHandler.getItemHelper().setNbtData(item.getItemStack(), compoundTag));
}
use of com.denizenscript.denizencore.utilities.text.StringHolder in project Denizen-For-Bukkit by DenizenScript.
the class ItemRawNBT method getNonDefaultNBTMap.
public MapTag getNonDefaultNBTMap() {
MapTag result = getFullNBTMap();
for (StringHolder key : defaultNbtKeys) {
result.map.remove(key);
}
if (item.getBukkitMaterial() == Material.ITEM_FRAME) {
MapTag entityMap = (MapTag) result.getObject("EntityTag");
if (entityMap != null) {
entityMap.putObject("Invisible", null);
if (entityMap.map.isEmpty()) {
result.putObject("EntityTag", null);
}
}
}
if (item.getBukkitMaterial() == Material.ARMOR_STAND) {
MapTag entityMap = (MapTag) result.getObject("EntityTag");
if (entityMap != null) {
entityMap.putObject("Pose", null);
entityMap.putObject("Small", null);
entityMap.putObject("NoBasePlate", null);
entityMap.putObject("Marker", null);
entityMap.putObject("Invisible", null);
entityMap.putObject("ShowArms", null);
if (entityMap.map.isEmpty()) {
result.putObject("EntityTag", null);
}
}
}
return result;
}
use of com.denizenscript.denizencore.utilities.text.StringHolder in project Denizen-For-Bukkit by DenizenScript.
the class ConstantsTrait method rebuildAssignmentConstants.
public void rebuildAssignmentConstants() {
assignmentConstants.clear();
if (!npc.hasTrait(AssignmentTrait.class)) {
npc.removeTrait(ConstantsTrait.class);
return;
}
AssignmentTrait trait = npc.getOrAddTrait(AssignmentTrait.class);
for (AssignmentScriptContainer container : trait.containerCache) {
if (container != null) {
if (container.contains("default constants", Map.class)) {
for (StringHolder constant : container.getConfigurationSection("default constants").getKeys(false)) {
assignmentConstants.put(CoreUtilities.toLowerCase(constant.str), container.getString("default constants." + constant.str.toUpperCase(), ""));
}
}
}
}
}
Aggregations