Ugh, why you so hard, Java?

Discussion in 'Plugin Development' started by Connor2weirdness, Feb 26, 2014.

Thread Status:
Not open for further replies.
  1. To begin with, I want to say sorry I'm hogging most of the help on Bukkit right now, I'm trying to create the hardest plugin I've ever made :(

    Basically, I'm trying to create a plugin that makes custom armor so for example:
    Any chest plate + 8 emeralds = a jump boost chest plate
    I've got the chest plate to work, but I want it possible to use emeralds, feathers or anything that I list.
    And I need to reproduce this for every armor piece and apply a certain effect when they are wearing it (got that). Thanks and sorry again.
     
  2. Offline

    maxben34

    Connor2weirdness
    Make custom recipes for making the armor that will produce the same piece of armor but named. Then just check if the player is wearing armor with the same meta as the one that is crafted and then give them the effect that you want.
     
  3. That's what I have, but it's inefficient and it's about 50 lines of code just for the chest plate. Isn't there a simple way?
     
  4. Connor2weirdness
    Create a method that does the recipes for you, then call it with necessary parameters (shape and ingredients). Then you can call that method for every recipe you want to create.
     
  5. Assist I think I already have this.

    Code:
    public void featherset() {
            for (Material chestplate : chestplates) {
                ItemStack i = new ItemStack(chestplate, 1);
                ItemMeta meta = i.getItemMeta();
                meta.setDisplayName(ChatColor.BLUE + "Feather Chestplate");
                ArrayList<String> lore = new ArrayList<String>();
                lore.add("Makes you light as a feather!");
                meta.setLore(lore);
                i.setItemMeta(meta);
                ShapelessRecipe sr = new ShapelessRecipe(i);
                sr.addIngredient(8, Material.FEATHER);
                sr.addIngredient(1, chestplate);
                Bukkit.addRecipe(sr);
            }
            for (Material legging : leggings) {
                ItemStack i = new ItemStack(legging, 1);
                ItemMeta meta = i.getItemMeta();
                meta.setDisplayName(ChatColor.BLUE + "Feather Leggings");
                ArrayList<String> lore = new ArrayList<String>();
                lore.add("Makes you light as a feather!");
                meta.setLore(lore);
                i.setItemMeta(meta);
                ShapelessRecipe sr = new ShapelessRecipe(i);
                sr.addIngredient(8, Material.FEATHER);
                sr.addIngredient(1, legging);
                Bukkit.addRecipe(sr);
            }
            for (Material boot : boots) {
                ItemStack i = new ItemStack(boot, 1);
                ItemMeta meta = i.getItemMeta();
                meta.setDisplayName(ChatColor.BLUE + "Feather Boots");
                ArrayList<String> lore = new ArrayList<String>();
                lore.add("Makes you light as a feather!");
                meta.setLore(lore);
                i.setItemMeta(meta);
                ShapelessRecipe sr = new ShapelessRecipe(i);
                sr.addIngredient(8, Material.FEATHER);
                sr.addIngredient(1, boot);
                Bukkit.addRecipe(sr);
     
  6. Offline

    Alshain01

    You need to study up on Object Oriented Programming. This forum is for supporting Bukkit, not Java or OOP. It's not that we don't want to help you but the support you get is going to be discussed on a higher level than your able to understand unless you can grasp the basic concepts.
     
    adam753 likes this.
  7. I just changed my reply, my brain was having a funny moment.
     
Thread Status:
Not open for further replies.

Share This Page