use of com.denizenscript.denizencore.objects.core.ListTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemKnowledgeBookRecipes method adjust.
@Override
public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("knowledge_book_recipes")) {
KnowledgeBookMeta meta = (KnowledgeBookMeta) item.getItemMeta();
List<NamespacedKey> recipes = new ArrayList<>();
ListTag newRecipes = mechanism.valueAsType(ListTag.class);
for (String str : newRecipes) {
recipes.add(Utilities.parseNamespacedKey(str));
}
meta.setRecipes(recipes);
item.setItemMeta(meta);
}
}
use of com.denizenscript.denizencore.objects.core.ListTag in project Denizen-For-Bukkit by DenizenScript.
the class ItemLore method adjust.
@Override
public void adjust(Mechanism mechanism) {
// -->
if (mechanism.matches("lore")) {
ListTag lore = mechanism.valueAsType(ListTag.class);
CoreUtilities.fixNewLinesToListSeparation(lore);
for (int i = 0; i < lore.size(); i++) {
String loreLine = lore.get(i);
if (lore.wasLegacy) {
loreLine = EscapeTagBase.unEscape(loreLine);
}
lore.set(i, CoreUtilities.clearNBSPs(loreLine));
}
NMSHandler.getItemHelper().setLore(item, lore);
}
}
use of com.denizenscript.denizencore.objects.core.ListTag in project Denizen-For-Bukkit by DenizenScript.
the class MaterialFaces method registerTags.
public static void registerTags() {
// <--[tag]
// @attribute <MaterialTag.valid_faces>
// @returns ListTag
// @mechanism MaterialTag.faces
// @group properties
// @description
// Returns a list of faces that are valid for a material that has multiple faces.
// See also <@link tag MaterialTag.faces>
// -->
PropertyParser.<MaterialFaces, ListTag>registerStaticTag(ListTag.class, "valid_faces", (attribute, material) -> {
ListTag toReturn = new ListTag();
for (BlockFace face : material.getFaces().getAllowedFaces()) {
toReturn.add(face.name());
}
return toReturn;
});
// <--[tag]
// @attribute <MaterialTag.faces>
// @returns ListTag
// @mechanism MaterialTag.faces
// @group properties
// @description
// Returns a list of the current faces for a material that has multiple faces (like a mushroom block).
// Output is a direction name like "NORTH".
// -->
PropertyParser.<MaterialFaces, ListTag>registerStaticTag(ListTag.class, "faces", (attribute, material) -> {
return material.getFaceList();
});
}
use of com.denizenscript.denizencore.objects.core.ListTag in project Denizen-For-Bukkit by DenizenScript.
the class CuboidTag method getOutline.
public ListTag getOutline() {
int max = Settings.blockTagsMaxBlocks();
int index = 0;
ListTag list = new ListTag();
for (LocationPair pair : pairs) {
LocationTag loc_1 = pair.low;
LocationTag loc_2 = pair.high;
int y_distance = pair.yDistance();
int z_distance = pair.zDistance();
int x_distance = pair.xDistance();
for (int y = loc_1.getBlockY(); y < loc_1.getBlockY() + y_distance; y++) {
list.addObject(new LocationTag(loc_1.getWorld(), loc_1.getBlockX(), y, loc_1.getBlockZ()));
list.addObject(new LocationTag(loc_1.getWorld(), loc_2.getBlockX(), y, loc_2.getBlockZ()));
list.addObject(new LocationTag(loc_1.getWorld(), loc_1.getBlockX(), y, loc_2.getBlockZ()));
list.addObject(new LocationTag(loc_1.getWorld(), loc_2.getBlockX(), y, loc_1.getBlockZ()));
index++;
if (index > max) {
return list;
}
}
for (int x = loc_1.getBlockX(); x < loc_1.getBlockX() + x_distance; x++) {
list.addObject(new LocationTag(loc_1.getWorld(), x, loc_1.getBlockY(), loc_1.getBlockZ()));
list.addObject(new LocationTag(loc_1.getWorld(), x, loc_1.getBlockY(), loc_2.getBlockZ()));
list.addObject(new LocationTag(loc_1.getWorld(), x, loc_2.getBlockY(), loc_2.getBlockZ()));
list.addObject(new LocationTag(loc_1.getWorld(), x, loc_2.getBlockY(), loc_1.getBlockZ()));
index++;
if (index > max) {
return list;
}
}
for (int z = loc_1.getBlockZ(); z < loc_1.getBlockZ() + z_distance; z++) {
list.addObject(new LocationTag(loc_1.getWorld(), loc_1.getBlockX(), loc_1.getBlockY(), z));
list.addObject(new LocationTag(loc_1.getWorld(), loc_2.getBlockX(), loc_2.getBlockY(), z));
list.addObject(new LocationTag(loc_1.getWorld(), loc_1.getBlockX(), loc_2.getBlockY(), z));
list.addObject(new LocationTag(loc_1.getWorld(), loc_2.getBlockX(), loc_1.getBlockY(), z));
index++;
if (index > max) {
return list;
}
}
list.addObject(pair.high);
}
return list;
}
use of com.denizenscript.denizencore.objects.core.ListTag in project Denizen-For-Bukkit by DenizenScript.
the class CuboidTag method getOutline2D.
public ListTag getOutline2D(double y) {
int max = Settings.blockTagsMaxBlocks();
int index = 0;
ListTag list = new ListTag();
for (LocationPair pair : pairs) {
LocationTag loc_1 = pair.low;
LocationTag loc_2 = pair.high;
int z_distance = pair.zDistance();
int x_distance = pair.xDistance();
list.addObject(new LocationTag(loc_2.getWorld(), loc_2.getBlockX(), y, loc_2.getBlockZ()));
for (int x = loc_1.getBlockX(); x < loc_1.getBlockX() + x_distance; x++) {
list.addObject(new LocationTag(loc_1.getWorld(), x, y, loc_2.getBlockZ()));
list.addObject(new LocationTag(loc_1.getWorld(), x, y, loc_1.getBlockZ()));
index++;
if (index > max) {
return list;
}
}
for (int z = loc_1.getBlockZ(); z < loc_1.getBlockZ() + z_distance; z++) {
list.addObject(new LocationTag(loc_1.getWorld(), loc_2.getBlockX(), y, z));
list.addObject(new LocationTag(loc_1.getWorld(), loc_1.getBlockX(), y, z));
index++;
if (index > max) {
return list;
}
}
}
return list;
}
Aggregations