Development Assistance Custom Recipes

Discussion in 'Plugin Help/Development/Requests' started by Frostblockers, Mar 13, 2015.

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

    Frostblockers

    Hi! I need Someone to add Permission to my plugin
    Please in the code, Add only to the gihelmet item a permission needed ! I cant do it i tried everything!
    reply the codes but with perms added

    (Dont add perms to evrything... i just want 1 of them to have on so i can learn!



    Code:
    package me.Frostblockers.CustomCrafting;
    
    import java.util.Arrays;
    
    import org.bukkit.Bukkit;
    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 CC extends JavaPlugin {
    
        public void onEnable() {
            this.getServer()
                    .getConsoleSender()
                    .sendMessage(
                            ChatColor.AQUA + "[CustomCrafting] by"
                                    + ChatColor.YELLOW + " Frostblockers"
                                    + ChatColor.GREEN + " as been enabled!");
            gihelmet();
            gichestplate();
            gileggings();
            giboots();
        }
        private void gihelmet() {
            ItemStack helmet = new ItemStack(Material.IRON_HELMET, 1);
            ItemMeta meta = helmet.getItemMeta();
            meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 4, true);
            meta.setDisplayName(ChatColor.GRAY + "God Iron Helmet");
            meta.setLore(Arrays.asList("God", "Iron", "Helmet"));
            helmet.setItemMeta(meta);
    
            ShapedRecipe hrecipe = new ShapedRecipe(helmet);
            hrecipe.shape("@@@", "@ @");
            hrecipe.setIngredient('@', Material.IRON_BLOCK);
            Bukkit.getServer().addRecipe(hrecipe);
            }
    
        private void gichestplate() {
            ItemStack chestplate = new ItemStack(Material.IRON_CHESTPLATE, 1);
            ItemMeta meta = chestplate.getItemMeta();
            meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 4, true);
            meta.setDisplayName(ChatColor.GRAY + "God Iron Chestplate");
            meta.setLore(Arrays.asList("God", "Iron", "Chestplate"));
            chestplate.setItemMeta(meta);
    
            ShapedRecipe gichestplater = new ShapedRecipe(chestplate);
            gichestplater.shape("@ @", "@@@", "@@@");
            gichestplater.setIngredient('@', Material.IRON_BLOCK);
            Bukkit.getServer().addRecipe(gichestplater);
        }
    
        private void gileggings() {
            ItemStack leggings = new ItemStack(Material.IRON_LEGGINGS, 1);
            ItemMeta meta = leggings.getItemMeta();
            meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 4, true);
            meta.setDisplayName(ChatColor.GRAY + "God Iron Leggings");
            meta.setLore(Arrays.asList("God", "Iron", "Leggings"));
            leggings.setItemMeta(meta);
    
            ShapedRecipe gileggingsr = new ShapedRecipe(leggings);
            gileggingsr.shape("@@@", "@ @", "@ @");
            gileggingsr.setIngredient('@', Material.IRON_BLOCK);
            Bukkit.getServer().addRecipe(gileggingsr);
        }
    
        private void giboots() {
            ItemStack boots = new ItemStack(Material.IRON_BOOTS, 1);
            ItemMeta meta = boots.getItemMeta();
            meta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 4, true);
            meta.setDisplayName(ChatColor.GRAY + "God Iron Boots");
            meta.setLore(Arrays.asList("God", "Iron", "Boots"));
            boots.setItemMeta(meta);
    
            ShapedRecipe gibootsf = new ShapedRecipe(boots);
            gibootsf.shape("   ", "@ @", "@ @");
            gibootsf.setIngredient('@', Material.IRON_BLOCK);
            Bukkit.getServer().addRecipe(gibootsf);
        }
    
        public void onDisable() {
            Bukkit.getServer().clearRecipes();
        }
    }
     
  2. Offline

    pie_flavor

    @Frostblockers Your post is difficult to comprehend. However I think it's safe to assume that you want the players to only be able to craft it if they have a permission.

    Listen for a CraftItemEvent. Check if the result item is one of your items (maybe by checking the name) and then check if the player has the permission. Don't forget to register the permission in plugin.yml, otherwise it can't be used.
     
  3. Offline

    Frostblockers

    like i asaid im new! thats why i post it here so someone can place it in the codes and i can learn from there
     
Thread Status:
Not open for further replies.

Share This Page