Skip to content

Commit

Permalink
Show errors on invalid objects update
Browse files Browse the repository at this point in the history
also patch title command
  • Loading branch information
mcmonkey4eva committed Sep 25, 2019
1 parent ed03723 commit ade242d
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 11 deletions.
Expand Up @@ -157,7 +157,7 @@ else if (Argument.valueOf(lower).matchesArgumentList(ItemTag.class)) {
drops.clear();
dropItems = new ArrayList<>();
ListTag drops_list = ListTag.valueOf(determination);
drops_list.filter(ItemTag.class, path.container);
drops_list.filter(ItemTag.class, path.container, true);
for (String drop : drops_list) {
ItemTag item = ItemTag.valueOf(drop, path.container);
if (item != null) {
Expand Down
Expand Up @@ -100,7 +100,7 @@ public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
cancelled = true;

// Get the list of entities
List<EntityTag> newProjectiles = ListTag.getListFor(determinationObj).filter(EntityTag.class, path.container);
List<EntityTag> newProjectiles = ListTag.getListFor(determinationObj).filter(EntityTag.class, path.container, true);
// Go through all the entities, spawning/teleporting them
for (EntityTag newProjectile : newProjectiles) {
newProjectile.spawnAt(entity.getEyeLocation()
Expand Down
Expand Up @@ -128,7 +128,7 @@ else if (lower.startsWith("raw_format:")) {
else if (lower.startsWith("recipients:")) {
String rec_new = determination.substring("recipients:".length());
ListTag recs = ListTag.valueOf(rec_new);
List<PlayerTag> players = recs.filter(PlayerTag.class, path.container);
List<PlayerTag> players = recs.filter(PlayerTag.class, path.container, true);
Set<Player> recipients;
if (pcEvent != null) {
recipients = pcEvent.getRecipients();
Expand Down
Expand Up @@ -103,7 +103,7 @@ else if (((ElementTag) determinationObj).isInt()) {
if (Argument.valueOf(determination).matchesArgumentList(ItemTag.class)) {
cancelled = true;
block.setType(Material.AIR);
for (ItemTag newItem : ListTag.valueOf(determination).filter(ItemTag.class, path.container)) {
for (ItemTag newItem : ListTag.valueOf(determination).filter(ItemTag.class, path.container, true)) {
block.getWorld().dropItemNaturally(block.getLocation(), newItem.getItemStack()); // Drop each item
}
return true;
Expand Down
Expand Up @@ -1325,7 +1325,7 @@ public ObjectTag run(Attribute attribute, ObjectTag object) {
if (!attribute.hasContext(1)) {
return null;
}
List<ItemTag> items = ListTag.valueOf(attribute.getContext(1)).filter(ItemTag.class, attribute.getScriptEntry());
List<ItemTag> items = ListTag.valueOf(attribute.getContext(1)).filter(ItemTag.class, attribute.context, !attribute.hasAlternative());
if (items == null || items.isEmpty()) {
return null;
}
Expand Down Expand Up @@ -1795,7 +1795,7 @@ else if (item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName
qty = attribute.getIntContext(2);
attribs = 2;
}
List<ItemTag> contains = list.filter(ItemTag.class, attribute.getScriptEntry());
List<ItemTag> contains = list.filter(ItemTag.class, attribute.context, !attribute.hasAlternative());
if (contains.size() == list.size()) {
for (ItemTag item : contains) {
if (!((InventoryTag) object).containsItem(item, qty)) {
Expand Down Expand Up @@ -1838,7 +1838,7 @@ public ObjectTag run(Attribute attribute, ObjectTag object) {
qty = attribute.getIntContext(2);
attribs = 2;
}
List<ItemTag> contains = list.filter(ItemTag.class, attribute.getScriptEntry());
List<ItemTag> contains = list.filter(ItemTag.class, attribute.context, !attribute.hasAlternative());
if (!contains.isEmpty()) {
for (ItemTag item : contains) {
if (((InventoryTag) object).containsItem(item, qty)) {
Expand Down
Expand Up @@ -22,14 +22,14 @@ public class NarrateCommand extends AbstractCommand {

// <--[command]
// @Name Narrate
// @Syntax narrate [<text>] (targets:<player>|...) (format:<name>)
// @Syntax narrate [<text>] (targets:<player>|...) (format:<script>)
// @Required 1
// @Short Shows some text to the player.
// @Group player
//
// @Description
// Prints some text into the target's chat area. If no target is specified it will default to the attached player
// or the console. Accepts the 'format:<name>' argument, which will reformat the text according to the specified
// or the console. Accepts the 'format:<script>' argument, which will reformat the text according to the specified
// format script.
//
// @Tags
Expand Down
Expand Up @@ -69,6 +69,9 @@ else if (arg.matchesPrefix("targets", "target")
&& arg.matchesArgumentList(PlayerTag.class)) {
scriptEntry.addObject("targets", arg.asType(ListTag.class).filter(PlayerTag.class, scriptEntry));
}
else {
arg.reportUnhandled();
}

}

Expand Down
Expand Up @@ -207,7 +207,6 @@ else if (ItemTag.matches(item)) {
inventory.setContents(finalItems);
}
if (contains("PROCEDURAL ITEMS")) {
// TODO: Document this feature!
if (inventory == null) {
size = InventoryType.CHEST.getDefaultSize();
inventory = new InventoryTag(size, contains("TITLE") ? TagManager.tag(getString("TITLE"), context) : "Chest");
Expand All @@ -228,7 +227,7 @@ else if (ItemTag.matches(item)) {
ListTag list = ListTag.getListFor(queue.determinations.getObject(0));
if (list != null) {
int x = 0;
for (ItemTag item : list.filter(ItemTag.class, this)) {
for (ItemTag item : list.filter(ItemTag.class, this, true)) {
while (x < filledSlots.length && filledSlots[x]) {
x++;
}
Expand Down

0 comments on commit ade242d

Please sign in to comment.