Package net.aufdemrand.denizen.objects

Examples of net.aufdemrand.denizen.objects.dItem


                for (Map.Entry<String, String> entry : idMap.entrySet()) {
                    // Tag the entry value to account for replaceables
                    String entry_value = TagManager.tag(player, npc, entry.getValue());
                    // Check if the item specified in the specified id's 'trigger:' key
                    // matches the item that the player is holding.
                    dItem item = dItem.valueOf(entry_value);
                    if (item == null) {
                        dB.echoError("Invalid click trigger in script '" + script.getName() + "' (null trigger item)!");
                    }
                    if (item != null && item.comparesTo(player.getPlayerEntity().getItemInHand()) >= 0
                            && script.checkSpecificTriggerScriptRequirementsFor(this.getClass(),
                            player, npc, entry.getKey()))
                        id = entry.getKey();
                }
        }
View Full Code Here


    public boolean check(RequirementsContext context, List<String> args) throws RequirementCheckException {
        boolean outcome = false;

        boolean exact = false;
        int quantity = 1;
        dItem itemToCheck = null;

        for (String thisArg : args) {
            if (aH.matchesQuantity(thisArg))
                quantity = aH.getIntegerFrom(thisArg);

            else if(aH.matchesArg("EXACT, EXACTLY, EQUALS", thisArg)) {
                exact = true;
            }

            else itemToCheck = aH.getItemFrom(thisArg);
        }

        if (itemToCheck != null)
            itemToCheck.getItemStack().setAmount(quantity);

        if (exact)
            outcome = context.getPlayer().getPlayerEntity().getItemInHand().equals(itemToCheck.getItemStack());
        else
            outcome = context.getPlayer().getPlayerEntity().getItemInHand().isSimilar(itemToCheck.getItemStack());

        dB.echoDebug(context.getScriptContainer(), "Outcome: " + ((outcome) ? (exact) ? "Player is holding exact item" : "Player is holding item" : ""));

        return outcome;
    }
View Full Code Here

    @Override
    public boolean check(RequirementsContext context, List<String> args)
            throws RequirementCheckException {

        dItem contains = null;
        int quantity = 1;

        for (aH.Argument arg : aH.interpret(args)) {

            if (contains == null
                    && arg.matchesArgumentType(dItem.class))
                contains = arg.asType(dItem.class);

            else if (arg.matchesPrimitive(aH.PrimitiveType.Integer))
                quantity = aH.getIntegerFrom(arg.getValue());
        }

        if (context.getPlayer().getPlayerEntity().getInventory().containsAtLeast(contains.getItemStack(), quantity)) {
            dB.echoDebug(context.getScriptContainer(), "...player has " + contains.identify() + ".");
            return true;

        } else {
            dB.echoDebug(context.getScriptContainer(), "...player doesn't have " + contains.identify() + ".");
            return false;
        }
    }
View Full Code Here

    @Override
    public String getPropertyString() {
        ItemStack item = new ItemStack(Material.FIREWORK);
        item.setItemMeta(((Firework) firework.getBukkitEntity()).getFireworkMeta());
        return new dItem(item).identify();
    }
View Full Code Here

        // If the entity is a firework, returns the firework item used to launch it.
        // -->
        if (attribute.startsWith("firework_item")) {
            ItemStack item = new ItemStack(Material.FIREWORK);
            item.setItemMeta(((Firework) firework.getBukkitEntity()).getFireworkMeta());
            return new dItem(item).getAttribute(attribute.fulfill(1));
        }

        return null;
    }
View Full Code Here

        // Changes the firework effect on this entity, using a firework item.
        // @tags
        // <e@entity.firework_item>
        // -->
        if (mechanism.matches("firework_item") && mechanism.requireObject(dItem.class)) {
            dItem item = mechanism.getValue().asType(dItem.class);
            if (item != null && item.getItemStack().getItemMeta() instanceof FireworkMeta) {
                ((Firework)firework.getBukkitEntity()).setFireworkMeta((FireworkMeta)item.getItemStack().getItemMeta());
            }
            else {
                dB.echoError("'" + mechanism.getValue().asString() + "' is not a valid firework item.");
            }
        }
View Full Code Here

    public dItem getBookFrom() {
        return getBookFrom(null, null);
    }

    public dItem getBookFrom(dPlayer player, dNPC npc) {
        dItem stack = new dItem(Material.WRITTEN_BOOK);
        return writeBookTo(stack, player, npc);
    }
View Full Code Here

TOP

Related Classes of net.aufdemrand.denizen.objects.dItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.