Giter VIP home page Giter VIP logo

recipeutil's Introduction

An utility class for comparing recipes from Bukkit API.

Please report any issues you find.

To use it just grab the ro/thehunters/digi/recipeUtil/RecipeUtil.java class and place it in your own plugin, then use it statically!

Example:

if(RecipeUtil.areEqual(recipe, otherRecipe))
{
    // ...
}


Methods have JavaDoc, read those for more information.

recipeutil's People

Contributors

thdigi avatar

Stargazers

Commentary avatar Cubesteak avatar

Watchers

James Cloos avatar  avatar

recipeutil's Issues

RecipeCompare Returns False

I've got my custom recipes stored in an array and then I loop through them like this on PrepareCraftEvent:

    @EventHandler
    public void onPrepareItemCraftEvent(PrepareItemCraftEvent event) {
        boolean equal = false;
        boolean stop = false;

        for(String s : pl.getRecipes().keySet()) {
            equal = RecipeUtil.areEqual(event.getRecipe(), pl.getRecipes().get(s));
            pl.getLogger().info("Currently " + s + " is at " + equal);
            if(equal) {
                if(s.equalsIgnoreCase("Skooma")) {
                    stop = !checkSkooma(event);
                }else if(s.equalsIgnoreCase("Pipeweed")) {
                    pl.getLogger().info("It is a pipeweed");
                    stop = !checkPipeweed(event);
                    pl.getLogger().info("Should we stop: " + stop);
                }
                break;
            } else
                continue;
        }

        if(stop) {
            event.getInventory().setResult(null);
        }
    }

The thing is that the "Skooma" one returns true but the "Pipeweed" never returns true even though the recipe works and it can be crafted. Here are the two recipes:

Skooma

        ItemStack i = new ItemStack(Material.GHAST_TEAR, 1, (short) 14);
            ItemMeta meta = i.getItemMeta();
            meta.setDisplayName(ChatColor.YELLOW + "Skooma" + ChatColor.MAGIC);
            List<String> lore = new LinkedList<String>();
            lore.add("Take this and you'll think");
            lore.add("you can see graywolf336");
            meta.setLore(lore);
        i.setItemMeta(meta);

        ShapedRecipe r = new ShapedRecipe(i);
        r.shape(new String[] { "aaa", "bbb", "ccc" });
        r.setIngredient('a', Material.BROWN_MUSHROOM);
        r.setIngredient('b', Material.INK_SACK, 2);
        r.setIngredient('c', Material.RED_MUSHROOM);

Pipeweed

        ItemStack i = new ItemStack(Material.TORCH, 1, (short) 14);
            ItemMeta meta = i.getItemMeta();
            meta.setDisplayName(ChatColor.YELLOW + "Pipeweed" + ChatColor.MAGIC);
            List<String> lore = new LinkedList<String>();
            lore.add("Burn one up Behindthebush");
            meta.setLore(lore);
        i.setItemMeta(meta);

        ShapedRecipe r = new ShapedRecipe(i);
        r.shape(new String[] { "aaa", "bbb", "aaa" });
        r.setIngredient('a', Material.PAPER);
        r.setIngredient('b', Material.LONG_GRASS, 2);

Don't laugh cause it's all drugs and stuff, it's for a special project. ;) But the Skooma one works just fine with your utility but the pipeweed doesn't, any clues as to why? If you try it does it work for you?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.