use of com.denizenscript.denizencore.objects.core.MapTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemArmorStand method getDataMap.
public MapTag getDataMap() {
ArmorStandMeta meta = (ArmorStandMeta) item.getItemMeta();
if (meta == null) {
return null;
}
MapTag result = new MapTag();
result.putObject("base_plate", new ElementTag(!meta.hasNoBasePlate()));
result.putObject("visible", new ElementTag(!meta.isInvisible()));
result.putObject("marker", new ElementTag(meta.isMarker()));
result.putObject("is_small", new ElementTag(meta.isSmall()));
result.putObject("arms", new ElementTag(meta.shouldShowArms()));
return result;
}
use of com.denizenscript.denizencore.objects.core.MapTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemArmorStand method adjust.
@Override
public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("armor_stand_data") && mechanism.requireObject(MapTag.class)) {
MapTag map = mechanism.valueAsType(MapTag.class);
ArmorStandMeta meta = (ArmorStandMeta) item.getItemMeta();
ObjectTag base_plate = map.getObject("base_plate");
ObjectTag visible = map.getObject("visible");
ObjectTag marker = map.getObject("marker");
ObjectTag is_small = map.getObject("is_small");
ObjectTag arms = map.getObject("arms");
if (base_plate != null) {
meta.setNoBasePlate(!((ElementTag) base_plate).asBoolean());
}
if (visible != null) {
meta.setInvisible(!((ElementTag) visible).asBoolean());
}
if (marker != null) {
meta.setMarker(((ElementTag) marker).asBoolean());
}
if (is_small != null) {
meta.setSmall(((ElementTag) is_small).asBoolean());
}
if (arms != null) {
meta.setShowArms(((ElementTag) arms).asBoolean());
}
item.setItemMeta(meta);
}
}
use of com.denizenscript.denizencore.objects.core.MapTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerPreparesEnchantScriptEvent method applyDetermination.
@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
if (determinationObj instanceof ElementTag) {
String determineLow = CoreUtilities.toLowerCase(determinationObj.toString());
if (determineLow.startsWith("offers:")) {
ListTag offers = ListTag.valueOf(determineLow.substring("offers:".length()), getTagContext(path));
if (offers.size() != event.getOffers().length) {
Debug.echoError("Offer list size incorrect.");
return false;
}
for (int i = 0; i < offers.size(); i++) {
MapTag map = MapTag.getMapFor(offers.getObject(i), getTagContext(path));
event.getOffers()[i].setCost(map.getObject("cost").asElement().asInt());
ObjectTag enchantment = map.getObject("enchantment_type");
if (enchantment == null) {
enchantment = map.getObject("enchantment");
}
event.getOffers()[i].setEnchantment(enchantment.asType(EnchantmentTag.class, getTagContext(path)).enchantment);
event.getOffers()[i].setEnchantmentLevel(map.getObject("level").asElement().asInt());
}
return true;
}
}
return super.applyDetermination(path, determinationObj);
}
use of com.denizenscript.denizencore.objects.core.MapTag in project Denizen-For-Bukkit by DenizenScript.
the class PlayerPreparesEnchantScriptEvent method getContext.
@Override
public ObjectTag getContext(String name) {
switch(name) {
case "item":
return new ItemTag(event.getItem());
case "location":
return new LocationTag(event.getEnchantBlock().getLocation());
case "bonus":
return new ElementTag(event.getEnchantmentBonus());
case "offers":
ListTag output = new ListTag();
for (EnchantmentOffer offer : event.getOffers()) {
MapTag map = new MapTag();
map.putObject("cost", new ElementTag(offer.getCost()));
map.putObject("enchantment", new ElementTag(offer.getEnchantment().getKey().getKey()));
map.putObject("enchantment_type", new EnchantmentTag(offer.getEnchantment()));
map.putObject("level", new ElementTag(offer.getEnchantmentLevel()));
output.addObject(map);
}
return output;
}
return super.getContext(name);
}
use of com.denizenscript.denizencore.objects.core.MapTag in project Denizen-For-Bukkit by DenizenScript.
the class LocationTag method parsePointsAroundArgs.
public static double[] parsePointsAroundArgs(Attribute attribute) {
if (!attribute.hasParam()) {
return null;
}
MapTag inputMap = attribute.paramAsType(MapTag.class);
if (inputMap == null) {
return null;
}
ObjectTag radiusObj = inputMap.getObject("radius");
ObjectTag pointsObj = inputMap.getObject("points");
if (radiusObj == null || pointsObj == null) {
return null;
}
ElementTag radiusElement = radiusObj.asElement();
ElementTag amountElement = pointsObj.asElement();
if (radiusElement == null || amountElement == null) {
return null;
}
double radius = radiusElement.asDouble();
int amount = amountElement.asInt();
if (amount < 1) {
attribute.echoError("Invalid amount of points! There must be at least 1 point.");
return null;
}
return new double[] { radius, amount };
}
Aggregations