Search in sources :

Example 6 with Property

use of net.aufdemrand.denizencore.objects.properties.Property in project Denizen-For-Bukkit by DenizenScript.

the class dWorld method getAttribute.

@Override
public String getAttribute(Attribute attribute) {
    if (attribute == null) {
        return null;
    }
    // TODO: Scrap getAttribute, make this functionality a core system
    String attrLow = CoreUtilities.toLowerCase(attribute.getAttributeWithoutContext(1));
    TagRunnable tr = registeredTags.get(attrLow);
    if (tr != null) {
        if (!tr.name.equals(attrLow)) {
            net.aufdemrand.denizencore.utilities.debugging.dB.echoError(attribute.getScriptEntry() != null ? attribute.getScriptEntry().getResidingQueue() : null, "Using deprecated form of tag '" + tr.name + "': '" + attrLow + "'.");
        }
        return tr.run(attribute, this);
    }
    // Iterate through this object's properties' attributes
    for (Property property : PropertyParser.getProperties(this)) {
        String returned = property.getAttribute(attribute);
        if (returned != null) {
            return returned;
        }
    }
    return new Element(identify()).getAttribute(attribute);
}
Also used : Property(net.aufdemrand.denizencore.objects.properties.Property)

Example 7 with Property

use of net.aufdemrand.denizencore.objects.properties.Property in project Denizen-For-Bukkit by DenizenScript.

the class dWorld method adjust.

@Override
public void adjust(Mechanism mechanism) {
    Element value = mechanism.getValue();
    // -->
    if (mechanism.matches("ambient_spawn_limit") && mechanism.requireInteger()) {
        getWorld().setAmbientSpawnLimit(value.asInt());
    }
    // -->
    if (mechanism.matches("animal_spawn_limit") && mechanism.requireInteger()) {
        getWorld().setAnimalSpawnLimit(value.asInt());
    }
    // -->
    if (mechanism.matches("auto_save") && mechanism.requireBoolean()) {
        getWorld().setAutoSave(value.asBoolean());
    }
    // -->
    if (mechanism.matches("difficulty") && mechanism.requireEnum(true, Difficulty.values())) {
        String upper = value.asString().toUpperCase();
        Difficulty diff;
        if (upper.matches("(PEACEFUL|EASY|NORMAL|HARD)")) {
            diff = Difficulty.valueOf(upper);
        } else {
            diff = Difficulty.getByValue(value.asInt());
        }
        if (diff != null) {
            getWorld().setDifficulty(diff);
        }
    }
    // -->
    if (mechanism.matches("save")) {
        getWorld().save();
    }
    // -->
    if (mechanism.matches("destroy")) {
        if (!Settings.allowDelete()) {
            dB.echoError("Unable to delete due to config.");
            return;
        }
        File folder = new File(getWorld().getName());
        Bukkit.getServer().unloadWorld(getWorld(), false);
        try {
            FileUtils.deleteDirectory(folder);
        } catch (Exception ex) {
            dB.echoError(ex);
        }
        return;
    }
    // -->
    if (mechanism.matches("force_unload")) {
        Bukkit.getServer().unloadWorld(getWorld(), false);
        return;
    }
    // -->
    if (mechanism.matches("full_time") && mechanism.requireInteger()) {
        getWorld().setFullTime(value.asInt());
    }
    // -->
    if (mechanism.matches("keep_spawn") && mechanism.requireBoolean()) {
        getWorld().setKeepSpawnInMemory(value.asBoolean());
    }
    // -->
    if (mechanism.matches("monster_spawn_limit") && mechanism.requireInteger()) {
        getWorld().setMonsterSpawnLimit(value.asInt());
    }
    // -->
    if (mechanism.matches("allow_pvp") && mechanism.requireBoolean()) {
        getWorld().setPVP(value.asBoolean());
    }
    // -->
    if (mechanism.matches("spawn_location") && mechanism.requireObject(dLocation.class)) {
        dLocation loc = value.asType(dLocation.class);
        getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    }
    // -->
    if (mechanism.matches("storming") && mechanism.requireBoolean()) {
        getWorld().setStorm(value.asBoolean());
    }
    // -->
    if (mechanism.matches("thunder_duration") && mechanism.requireObject(Duration.class)) {
        getWorld().setThunderDuration(value.asType(Duration.class).getTicksAsInt());
    }
    // -->
    if (mechanism.matches("thundering") && mechanism.requireBoolean()) {
        getWorld().setThundering(value.asBoolean());
    }
    // -->
    if (mechanism.matches("ticks_per_animal_spawns") && mechanism.requireObject(Duration.class)) {
        getWorld().setTicksPerAnimalSpawns(value.asType(Duration.class).getTicksAsInt());
    }
    // -->
    if (mechanism.matches("ticks_per_monster_spawns") && mechanism.requireObject(Duration.class)) {
        getWorld().setTicksPerMonsterSpawns(value.asType(Duration.class).getTicksAsInt());
    }
    // -->
    if (mechanism.matches("time") && mechanism.requireInteger()) {
        getWorld().setTime(value.asInt());
    }
    // -->
    if (mechanism.matches("unload")) {
        Bukkit.getServer().unloadWorld(getWorld(), true);
        return;
    }
    // -->
    if (mechanism.matches("water_animal_spawn_limit") && mechanism.requireInteger()) {
        getWorld().setWaterAnimalSpawnLimit(value.asInt());
    }
    // -->
    if (mechanism.matches("weather_duration") && mechanism.requireObject(Duration.class)) {
        getWorld().setWeatherDuration(value.asType(Duration.class).getTicksAsInt());
    }
    // Iterate through this object's properties' mechanisms
    for (Property property : PropertyParser.getProperties(this)) {
        property.adjust(mechanism);
        if (mechanism.fulfilled()) {
            break;
        }
    }
    if (!mechanism.fulfilled()) {
        mechanism.reportInvalid();
    }
}
Also used : File(java.io.File) Property(net.aufdemrand.denizencore.objects.properties.Property)

Example 8 with Property

use of net.aufdemrand.denizencore.objects.properties.Property in project Denizen-For-Bukkit by DenizenScript.

the class dChunk method getAttribute.

@Override
public String getAttribute(Attribute attribute) {
    if (attribute == null) {
        return null;
    }
    // TODO: Scrap getAttribute, make this functionality a core system
    String attrLow = CoreUtilities.toLowerCase(attribute.getAttributeWithoutContext(1));
    TagRunnable tr = registeredTags.get(attrLow);
    if (tr != null) {
        if (!tr.name.equals(attrLow)) {
            net.aufdemrand.denizencore.utilities.debugging.dB.echoError(attribute.getScriptEntry() != null ? attribute.getScriptEntry().getResidingQueue() : null, "Using deprecated form of tag '" + tr.name + "': '" + attrLow + "'.");
        }
        return tr.run(attribute, this);
    }
    // Iterate through this object's properties' attributes
    for (Property property : PropertyParser.getProperties(this)) {
        String returned = property.getAttribute(attribute);
        if (returned != null) {
            return returned;
        }
    }
    return new Element(identify()).getAttribute(attribute);
}
Also used : Property(net.aufdemrand.denizencore.objects.properties.Property)

Example 9 with Property

use of net.aufdemrand.denizencore.objects.properties.Property in project Denizen-For-Bukkit by DenizenScript.

the class dCuboid method adjust.

@Override
public void adjust(Mechanism mechanism) {
    Element value = mechanism.getValue();
    if (mechanism.matches("outset")) {
        int mod = 1;
        if (value != null && mechanism.requireInteger("Invalid integer specified. Assuming '1'.")) {
            mod = value.asInt();
        }
        for (LocationPair pair : pairs) {
            pair.low.add(-1 * mod, -1 * mod, -1 * mod);
            pair.high.add(mod, mod, mod);
            // Modify the locations, need to readjust the distances generated
            pair.generateDistances();
        }
        // TODO: Make sure negative numbers don't collapse (and invert) the Cuboid
        return;
    }
    if (mechanism.matches("expand")) {
        int mod = 1;
        if (value != null && mechanism.requireInteger("Invalid integer specified. Assuming '1'.")) {
            mod = value.asInt();
        }
        for (LocationPair pair : pairs) {
            pair.low.add(-1 * mod, -1 * mod, -1 * mod);
            pair.high.add(mod, mod, mod);
            // Modify the locations, need to readjust the distances generated
            pair.generateDistances();
        }
        // the Cuboid
        return;
    }
    if (mechanism.matches("set_location")) {
        int mod = 1;
        if (value != null && mechanism.requireInteger("Invalid integer specified. Assuming '1'.")) {
            mod = value.asInt();
        }
        for (LocationPair pair : pairs) {
            pair.low.add(-1 * mod, -1 * mod, -1 * mod);
            pair.high.add(mod, mod, mod);
            // Modify the locations, need to readjust the distances generated
            pair.generateDistances();
        }
        // the Cuboid
        return;
    }
    // Iterate through this object's properties' mechanisms
    for (Property property : PropertyParser.getProperties(this)) {
        property.adjust(mechanism);
        if (mechanism.fulfilled()) {
            break;
        }
    }
    if (!mechanism.fulfilled()) {
        mechanism.reportInvalid();
    }
}
Also used : Property(net.aufdemrand.denizencore.objects.properties.Property)

Example 10 with Property

use of net.aufdemrand.denizencore.objects.properties.Property in project Denizen-For-Bukkit by DenizenScript.

the class dInventory method getAttribute.

////////////////////////
//  Attributes
/////////////////////
public String getAttribute(Attribute attribute) {
    if (attribute == null) {
        return null;
    }
    // -->
    if (attribute.startsWith("empty_slots")) {
        int full = new dInventory(inventory).count(null, true);
        return new Element(inventory.getSize() - full).getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("can_fit") && attribute.hasContext(1) && dItem.matches(attribute.getContext(1))) {
        dItem item = dItem.valueOf(attribute.getContext(1));
        if (item == null) {
            return null;
        }
        int attribs = 1;
        int qty = 1;
        InventoryType type = inventory.getType();
        dInventory dummyInv = new dInventory(Bukkit.createInventory(null, type == InventoryType.PLAYER ? InventoryType.CHEST : type, inventory.getTitle()));
        ItemStack[] contents = getStorageContents();
        if (dummyInv.getInventoryType() == InventoryType.CHEST) {
            dummyInv.setSize(contents.length);
        }
        if (contents.length != dummyInv.getSize()) {
            contents = Arrays.copyOf(contents, dummyInv.getSize());
        }
        dummyInv.setContents(contents);
        // -->
        if ((attribute.getAttribute(2).startsWith("quantity") || attribute.getAttribute(2).startsWith("qty")) && attribute.hasContext(2) && aH.matchesInteger(attribute.getContext(2))) {
            qty = attribute.getIntContext(2);
            attribs = 2;
        }
        item.setAmount(qty);
        List<ItemStack> leftovers = dummyInv.addWithLeftovers(0, true, item.getItemStack());
        return new Element(leftovers.isEmpty()).getAttribute(attribute.fulfill(attribs));
    }
    // -->
    if (attribute.startsWith("include") && attribute.hasContext(1) && dItem.matches(attribute.getContext(1))) {
        dItem item = dItem.valueOf(attribute.getContext(1));
        if (item == null) {
            return null;
        }
        int attribs = 1;
        int qty = 1;
        dInventory dummyInv = new dInventory(Bukkit.createInventory(null, inventory.getType(), inventory.getTitle()));
        if (inventory.getType() == InventoryType.CHEST) {
            dummyInv.setSize(inventory.getSize());
        }
        dummyInv.setContents(getContents());
        // -->
        if ((attribute.getAttribute(2).startsWith("quantity") || attribute.getAttribute(2).startsWith("qty")) && attribute.hasContext(2) && aH.matchesInteger(attribute.getContext(2))) {
            qty = attribute.getIntContext(2);
            attribs = 2;
        }
        item.setAmount(qty);
        dummyInv.add(0, item.getItemStack());
        return dummyInv.getAttribute(attribute.fulfill(attribs));
    }
    // -->
    if (attribute.startsWith("is_empty")) {
        boolean empty = true;
        for (ItemStack item : getStorageContents()) {
            if (item != null && item.getType() != Material.AIR) {
                empty = false;
                break;
            }
        }
        return new Element(empty).getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("is_full")) {
        boolean full = true;
        for (ItemStack item : getStorageContents()) {
            if ((item == null) || (item.getType() == Material.AIR) || (item.getAmount() < item.getMaxStackSize())) {
                full = false;
                break;
            }
        }
        return new Element(full).getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("contains.display") && attribute.hasContext(2)) {
        String search_string = attribute.getContext(2);
        boolean strict = false;
        if (CoreUtilities.toLowerCase(search_string).startsWith("strict:") && search_string.length() > 7) {
            strict = true;
            search_string = search_string.substring(7);
        }
        if (search_string.length() == 0) {
            return null;
        }
        int qty = 1;
        int attribs = 2;
        // -->
        if ((attribute.getAttribute(3).startsWith("quantity") || attribute.getAttribute(3).startsWith("qty")) && attribute.hasContext(3) && aH.matchesInteger(attribute.getContext(3))) {
            qty = attribute.getIntContext(3);
            attribs = 3;
        }
        int found_items = 0;
        if (strict) {
            for (ItemStack item : getContents()) {
                if (item != null && item.getType() == Material.WRITTEN_BOOK && ((BookMeta) item.getItemMeta()).getTitle().equalsIgnoreCase(search_string)) {
                    found_items += item.getAmount();
                    if (found_items >= qty) {
                        break;
                    }
                } else if (item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase(search_string)) {
                    found_items += item.getAmount();
                    if (found_items >= qty) {
                        break;
                    }
                }
            }
        } else {
            for (ItemStack item : getContents()) {
                if (item != null && item.getType() == Material.WRITTEN_BOOK && CoreUtilities.toLowerCase(((BookMeta) item.getItemMeta()).getTitle()).contains(CoreUtilities.toLowerCase(search_string))) {
                    found_items += item.getAmount();
                    if (found_items >= qty) {
                        break;
                    }
                } else if (item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && CoreUtilities.toLowerCase(item.getItemMeta().getDisplayName()).contains(CoreUtilities.toLowerCase(search_string))) {
                    found_items += item.getAmount();
                    if (found_items >= qty) {
                        break;
                    }
                }
            }
        }
        return new Element(found_items >= qty).getAttribute(attribute.fulfill(attribs));
    }
    // -->
    if (attribute.startsWith("contains.lore") && attribute.hasContext(2)) {
        String search_string = attribute.getContext(2);
        boolean strict = false;
        if (CoreUtilities.toLowerCase(search_string).startsWith("strict:")) {
            strict = true;
            search_string = search_string.substring(7);
        }
        if (search_string.length() == 0) {
            return null;
        }
        dList lore = dList.valueOf(search_string);
        int qty = 1;
        int attribs = 2;
        // -->
        if ((attribute.getAttribute(3).startsWith("quantity") || attribute.getAttribute(3).startsWith("qty")) && attribute.hasContext(3) && aH.matchesInteger(attribute.getContext(3))) {
            qty = attribute.getIntContext(3);
            attribs = 3;
        }
        int found_items = 0;
        if (strict) {
            strict_items: for (ItemStack item : getContents()) {
                if (item != null && item.hasItemMeta() && item.getItemMeta().hasLore()) {
                    List<String> item_lore = item.getItemMeta().getLore();
                    if (lore.size() != item_lore.size()) {
                        continue;
                    }
                    for (int i = 0; i < item_lore.size(); i++) {
                        if (lore.get(i).equalsIgnoreCase(item_lore.get(i))) {
                            if (i == lore.size()) {
                                found_items += item.getAmount();
                                if (found_items >= qty) {
                                    break strict_items;
                                }
                            }
                        } else {
                            continue strict_items;
                        }
                    }
                }
            }
        } else {
            for (ItemStack item : getContents()) {
                if (item != null && item.hasItemMeta() && item.getItemMeta().hasLore()) {
                    List<String> item_lore = item.getItemMeta().getLore();
                    int loreCount = 0;
                    lines: for (String line : lore) {
                        for (String item_line : item_lore) {
                            if (CoreUtilities.toLowerCase(item_line).contains(CoreUtilities.toLowerCase(line))) {
                                loreCount++;
                                continue lines;
                            }
                        }
                    }
                    if (loreCount == lore.size()) {
                        found_items += item.getAmount();
                        if (found_items >= qty) {
                            break;
                        }
                    }
                }
            }
        }
        return new Element(found_items >= qty).getAttribute(attribute.fulfill(attribs));
    }
    // -->
    if (attribute.startsWith("contains.material") && attribute.hasContext(2) && dMaterial.matches(attribute.getContext(2))) {
        dMaterial material = dMaterial.valueOf(attribute.getContext(2));
        int qty = 1;
        int attribs = 2;
        // -->
        if ((attribute.getAttribute(3).startsWith("quantity") || attribute.getAttribute(3).startsWith("qty")) && attribute.hasContext(3) && aH.matchesInteger(attribute.getContext(3))) {
            qty = attribute.getIntContext(3);
            attribs = 3;
        }
        int found_items = 0;
        for (ItemStack item : getContents()) {
            if (item != null && item.getType() == material.getMaterial()) {
                found_items += item.getAmount();
                if (found_items >= qty) {
                    break;
                }
            }
        }
        return new Element(found_items >= qty).getAttribute(attribute.fulfill(attribs));
    }
    // -->
    if (attribute.startsWith("contains_any") && attribute.hasContext(1)) {
        dList list = dList.valueOf(attribute.getContext(1));
        if (list.isEmpty()) {
            return null;
        }
        int qty = 1;
        int attribs = 1;
        // -->
        if ((attribute.getAttribute(2).startsWith("quantity") || attribute.getAttribute(2).startsWith("qty")) && attribute.hasContext(2) && aH.matchesInteger(attribute.getContext(2))) {
            qty = attribute.getIntContext(2);
            attribs = 2;
        }
        List<dItem> contains = list.filter(dItem.class, attribute.getScriptEntry());
        if (!contains.isEmpty()) {
            for (dItem item : contains) {
                if (containsItem(item, qty)) {
                    return Element.TRUE.getAttribute(attribute.fulfill(attribs));
                }
            }
        }
        return Element.FALSE.getAttribute(attribute.fulfill(attribs));
    }
    // -->
    if (attribute.startsWith("contains") && attribute.hasContext(1)) {
        dList list = dList.valueOf(attribute.getContext(1));
        if (list.isEmpty()) {
            return null;
        }
        int qty = 1;
        int attribs = 1;
        // -->
        if ((attribute.getAttribute(2).startsWith("quantity") || attribute.getAttribute(2).startsWith("qty")) && attribute.hasContext(2) && aH.matchesInteger(attribute.getContext(2))) {
            qty = attribute.getIntContext(2);
            attribs = 2;
        }
        // TODO: Fix logic
        List<dItem> contains = list.filter(dItem.class, attribute.getScriptEntry());
        if (!contains.isEmpty()) {
            for (dItem item : contains) {
                if (containsItem(item, qty)) {
                    return Element.TRUE.getAttribute(attribute.fulfill(attribs));
                }
            }
        }
        return Element.FALSE.getAttribute(attribute.fulfill(attribs));
    }
    // -->
    if (attribute.startsWith("first_empty")) {
        return new Element(firstEmpty(0)).getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("find.material") && attribute.hasContext(2) && dMaterial.matches(attribute.getContext(2))) {
        dMaterial material = dMaterial.valueOf(attribute.getContext(2));
        if (material == null) {
            return null;
        }
        int slot = -1;
        for (int i = 0; i < inventory.getSize(); i++) {
            if (inventory.getItem(i) != null && inventory.getItem(i).getType() == material.getMaterial()) {
                slot = i + 1;
                break;
            }
        }
        return new Element(slot).getAttribute(attribute.fulfill(2));
    }
    // -->
    if (attribute.startsWith("find_imperfect") && attribute.hasContext(1) && dItem.matches(attribute.getContext(1))) {
        dItem item = dItem.valueOf(attribute.getContext(1), attribute.getScriptEntry() != null ? ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getPlayer() : null, attribute.getScriptEntry() != null ? ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getNPC() : null);
        item.setAmount(1);
        int slot = -1;
        for (int i = 0; i < inventory.getSize(); i++) {
            if (inventory.getItem(i) != null) {
                dItem compare_to = new dItem(inventory.getItem(i).clone());
                compare_to.setAmount(1);
                if (item.identify().equalsIgnoreCase(compare_to.identify())) {
                    slot = i + 1;
                    break;
                }
            }
        }
        return new Element(slot).getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("find") && attribute.hasContext(1) && dItem.matches(attribute.getContext(1))) {
        dItem item = dItem.valueOf(attribute.getContext(1), attribute.getScriptEntry() != null ? ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getPlayer() : null, attribute.getScriptEntry() != null ? ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getNPC() : null);
        item.setAmount(1);
        int slot = -1;
        for (int i = 0; i < inventory.getSize(); i++) {
            if (inventory.getItem(i) != null) {
                dItem compare_to = new dItem(inventory.getItem(i).clone());
                compare_to.setAmount(1);
                if (item.getFullString().equalsIgnoreCase(compare_to.getFullString())) {
                    slot = i + 1;
                    break;
                }
            }
        }
        return new Element(slot).getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("id_type")) {
        return new Element(idType).getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("notable_name")) {
        String notname = NotableManager.getSavedId(this);
        if (notname == null) {
            return null;
        }
        return new Element(notname).getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("location")) {
        dLocation location = getLocation();
        if (location == null) {
            return null;
        }
        return location.getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("quantity") || attribute.startsWith("qty")) {
        if (attribute.hasContext(1) && dItem.matches(attribute.getContext(1))) {
            return new Element(count(dItem.valueOf(attribute.getContext(1), ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getPlayer(), ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getNPC()).getItemStack(), false)).getAttribute(attribute.fulfill(1));
        } else {
            return new Element(count(null, false)).getAttribute(attribute.fulfill(1));
        }
    }
    // -->
    if (attribute.startsWith("stacks")) {
        if (attribute.hasContext(1) && dItem.matches(attribute.getContext(1))) {
            return new Element(count(dItem.valueOf(attribute.getContext(1), ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getPlayer(), ((BukkitScriptEntryData) attribute.getScriptEntry().entryData).getNPC()).getItemStack(), true)).getAttribute(attribute.fulfill(1));
        } else {
            return new Element(count(null, true)).getAttribute(attribute.fulfill(1));
        }
    }
    // -->
    if (attribute.startsWith("slot") && attribute.hasContext(1) && aH.matchesInteger(attribute.getContext(1))) {
        int slot = new Element(attribute.getContext(1)).asInt() - 1;
        if (slot < 0) {
            slot = 0;
        } else if (slot > getInventory().getSize() - 1) {
            slot = getInventory().getSize() - 1;
        }
        return new dItem(getInventory().getItem(slot)).getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("inventory_type")) {
        return new Element(inventory instanceof HorseInventory ? "HORSE" : getInventory().getType().name()).getAttribute(attribute.fulfill(1));
    }
    // -->
    if (attribute.startsWith("equipment")) {
        dList equipment = getEquipment();
        if (equipment == null) {
            return null;
        }
        return equipment.getAttribute(attribute.fulfill(1));
    }
    if (inventory instanceof CraftingInventory) {
        CraftingInventory craftingInventory = (CraftingInventory) inventory;
        // -->
        if (attribute.startsWith("matrix")) {
            dList recipeList = new dList();
            for (ItemStack item : craftingInventory.getMatrix()) {
                if (item != null) {
                    recipeList.add(new dItem(item).identify());
                } else {
                    recipeList.add(new dItem(Material.AIR).identify());
                }
            }
            return recipeList.getAttribute(attribute.fulfill(1));
        }
        // -->
        if (attribute.startsWith("result")) {
            ItemStack result = craftingInventory.getResult();
            if (result == null) {
                return null;
            }
            return new dItem(result).getAttribute(attribute.fulfill(1));
        }
    }
    // -->
    if (attribute.startsWith("type")) {
        return new Element("Inventory").getAttribute(attribute.fulfill(1));
    }
    // Iterate through this object's properties' attributes
    for (Property property : PropertyParser.getProperties(this)) {
        String returned = property.getAttribute(attribute);
        if (returned != null) {
            return returned;
        }
    }
    return new Element(identify()).getAttribute(attribute);
}
Also used : CraftingInventory(org.bukkit.inventory.CraftingInventory) InventoryType(org.bukkit.event.inventory.InventoryType) BukkitScriptEntryData(net.aufdemrand.denizen.BukkitScriptEntryData) HorseInventory(org.bukkit.inventory.HorseInventory) ItemStack(org.bukkit.inventory.ItemStack) BookMeta(org.bukkit.inventory.meta.BookMeta) Property(net.aufdemrand.denizencore.objects.properties.Property)

Aggregations

Property (net.aufdemrand.denizencore.objects.properties.Property)20 ArrayList (java.util.ArrayList)4 Pattern (java.util.regex.Pattern)4 FlagManager (net.aufdemrand.denizen.flags.FlagManager)3 Material (org.bukkit.Material)3 Player (org.bukkit.entity.Player)3 ItemStack (org.bukkit.inventory.ItemStack)3 PotionEffect (org.bukkit.potion.PotionEffect)3 ImprovedOfflinePlayer (net.aufdemrand.denizen.nms.abstracts.ImprovedOfflinePlayer)2 EntityHelper (net.aufdemrand.denizen.nms.interfaces.EntityHelper)2 Entity (org.bukkit.entity.Entity)2 LivingEntity (org.bukkit.entity.LivingEntity)2 CraftingInventory (org.bukkit.inventory.CraftingInventory)2 BlockIterator (org.bukkit.util.BlockIterator)2 File (java.io.File)1 java.util (java.util)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 List (java.util.List)1 BukkitScriptEntryData (net.aufdemrand.denizen.BukkitScriptEntryData)1