Skip to content

Commit

Permalink
add tag inventory.map_slots
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 26, 2020
1 parent 8dd397d commit bac7dd9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Expand Up @@ -5,9 +5,11 @@
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.MapTag;
import com.denizenscript.denizencore.objects.properties.Property;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.denizencore.utilities.Deprecations;
import com.denizenscript.denizencore.utilities.text.StringHolder;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -122,7 +124,28 @@ public String getPropertyId() {

public static void registerTags() {



// <--[tag]
// @attribute <InventoryTag.map_slots>
// @returns MapTag
// @group properties
// @description
// Returns a map of inventory slots to the items in those slots (excludes air).
// -->
PropertyParser.<InventoryContents>registerTag("map_slots", (attribute, contents) -> {
MapTag map = new MapTag();
ItemStack[] items = contents.inventory.getContents();
for (int i = 0; i < items.length; i++) {
if (items[i] == null || items[i].getType() == Material.AIR) {
continue;
}
map.map.put(new StringHolder(String.valueOf(i + 1)), new ItemTag(items[i]));
}
return map;
});

// <--[tag]
// @attribute <InventoryTag.list_contents>
// @returns ListTag(ItemTag)
// @group properties
Expand Down
Expand Up @@ -47,11 +47,11 @@ public AdjustBlockCommand() {
//
// @Usage
// Use to put snow on the block at the player's feet.
// - adjust <player.location.below> snowy:true
// - adjustblock <player.location.below> snowy:true
//
// @Usage
// Use to switch on the lever that the player is looking at, without actually providing redstone power.
// - adjust <player.cursor_on> switched:true no_physics
// - adjustblock <player.cursor_on> switched:true no_physics
//
// -->

Expand Down

0 comments on commit bac7dd9

Please sign in to comment.