Crafting Special Items

Discussion in 'Plugin Development' started by snake4212, Mar 2, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    snake4212

    So I began creating a plugin that adds new items to the game.
    There are no java or console errors but it doesn't work here is my code.
    Code:
    package me.snake4212.MoItems;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapedRecipe;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class MoItems extends JavaPlugin{
     
    public void onEnable()
    {
    }
     
    public void onDisable()
    {
    }
     
    public void NewItems() {
     ItemStack burningsword = new ItemStack (Material.DIAMOND_SWORD, 1);
     burningsword.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 10);
     burningsword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);
       ShapedRecipe bsrecipe = new ShapedRecipe(burningsword);
       bsrecipe.shape(new String[] { "BDB", "BDB", "BSB" });
       bsrecipe.setIngredient('B', Material.BLAZE_POWDER);
       bsrecipe.setIngredient('D', Material.DIAMOND_SWORD);
       bsrecipe.setIngredient('S', Material.STICK);
    ItemMeta burningswordname = burningsword.getItemMeta();
    burningswordname.setDisplayName(ChatColor.DARK_RED + "Sword of Flames");
    burningsword.setItemMeta(burningswordname);
       getServer().addRecipe(bsrecipe);
    }
     
     
    }
     
  2. Offline

    turkey2349

    The code needs to be in OnEnable
     
  3. Offline

    beastman3226

    Just put "this.newItems();" into your onEnable. Congratulations! It works.
     
  4. Offline

    turkey2349

    That works to
     
Thread Status:
Not open for further replies.

Share This Page