Solved Recipe Error

Discussion in 'Plugin Development' started by Mayor_Mike, Jun 25, 2014.

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

    Mayor_Mike

    I've made a horse item recipe plugin just to get myself familarized with plugin programming a bit, but now the console gives me an error and none of the recipes work.

    Console Error:
    Show Spoiler
    Code:
     [16:03:41 ERROR]: Error occurred while enabling MikeHorseRecipes v1.0 (Is it up to date?)
    java.lang.IllegalArgumentException: Symbol does not appear in the shape:83
            at org.apache.commons.lang.Validate.isTrue(Validate.java:103) ~[bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.inventory.ShapedRecipe.setIngredient(ShapedRecipe.java:103) ~[bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.inventory.ShapedRecipe.setIngredient(ShapedRecipe.java:89) ~[bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at io.github.MayorMike.MikeHorseRecipes.MikeHorseRecipes.onEnable(MikeHorseRecipes.java:25) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:324) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugin(CraftServer.java:446) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.craftbukkit.v1_7_R3.CraftServer.enablePlugins(CraftServer.java:380) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.craftbukkit.v1_7_R3.CraftServer.reload(CraftServer.java:799) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.Bukkit.reload(Bukkit.java:288) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:180) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand(CraftServer.java:701) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchServerCommand(CraftServer.java:688) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at net.minecraft.server.v1_7_R3.DedicatedServer.aB(DedicatedServer.java:296) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:261) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
            at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [bukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]


    Here is my main .Java file aswell.

    Show Spoiler
    Code:
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package io.github.MayorMike.MikeHorseRecipes;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.Bukkit;
    import org.bukkit.Material;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.ShapedRecipe;
    import org.bukkit.plugin.java.JavaPlugin;
     
    /**
     *
     * @author mike
     */
    public class MikeHorseRecipes extends JavaPlugin{
        
         @Override
         /*
         D = Diamond
         G = Gold Ingot
         I = Iron Ingot
         L = Leather
         P = Paper
         S = String
         W = Wool
         */
    public void onEnable() {
                //Saddle
    ShapedRecipe mayorSaddle = new ShapedRecipe(new ItemStack(Material.SADDLE));
    mayorSaddle.shape(new String[]{"LLL","LIL","I I"}).setIngredient('L', Material.LEATHER).setIngredient('S', Material.STRING).setIngredient('I', Material.IRON_INGOT);
                    
                //Iron Horse Armour
    ShapedRecipe mayorIronha = new ShapedRecipe(new ItemStack(Material.IRON_BARDING));
    mayorIronha.shape(new String[]{"I  ","IWI","III"}).setIngredient('I', Material.IRON_INGOT).setIngredient('W', Material.WOOL);
                    
                //Gold Horse Armour
    ShapedRecipe mayorGoldha = new ShapedRecipe(new ItemStack(Material.GOLD_BARDING));
    mayorGoldha.shape(new String[]{"G  ","GWG","GGG"}).setIngredient('G', Material.GOLD_INGOT).setIngredient('W', Material.WOOL);
                    
                //Diamond Horse Amour
    ShapedRecipe mayorDiamondha = new ShapedRecipe(new ItemStack(Material.DIAMOND_BARDING));
    mayorDiamondha.shape(new String[]{"D   ","DWD","DDD"}).setIngredient('D', Material.DIAMOND).setIngredient('W', Material.WOOL);
                    
                //Name Tag
    ShapedRecipe mayorTag = new ShapedRecipe(new ItemStack(Material.NAME_TAG));
    mayorTag.shape(new String[]{"   ","PSS","   "}).setIngredient('S', Material.STRING).setIngredient('P', Material.PAPER);
                    
                    
    Bukkit.getServer().addRecipe(mayorSaddle);
    Bukkit.getServer().addRecipe(mayorIronha);
    Bukkit.getServer().addRecipe(mayorGoldha);
    Bukkit.getServer().addRecipe(mayorDiamondha);
    Bukkit.getServer().addRecipe(mayorTag);
    }
     
            @Override
    public void onDisable() {
    Bukkit.getServer().clearRecipes();
    }
        
      
        
    }
    

    Any help will be greatly appreciated.
     
  2. Offline

    iQuetzalito

    DONT MAKE STRING[]!!!

    It will break the recipe.

    Code:java
    1. ShapedRecipe mayorGoldha = new ShapedRecipe(new ItemStack(Material.GOLD_BARDING));
    2. mayorGoldha.shape("G ","GWG","GGG").setIngredient('G', Material.GOLD_INGOT).setIngredient('W', Material.WOOL);
     
  3. Offline

    Traks

    You're setting the material that should be used for char 'S' in mayorSaddle while its shape doesn't contain any 'S' characters...
     
  4. Offline

    Mayor_Mike

    Thank you both very much. I'm not the most experienced in Java but we all start somewhere right?

    iQuetzalito Thank you for the "Don't make String[]". I had no idea.
    Traks Thank you for finding my silly error of keeping "S" when I clearly didn't. I didn't see it and over looked it.

    During this I also found an error for the crafting spot in line 46. I had too many spaces in one of the variables.

    Once again, thank you both.
     
  5. Offline

    fireblast709

    ZeusAllMighty11 likes this.
  6. Offline

    iQuetzalito

    fireblast709 Every time I use a String[] it breaks for me. Hmm, I guess I was doing it wrong. Sorry. :p
     
  7. Offline

    Mayor_Mike

    I removed the String[] and it's all good. Whatever. Don't fix what's not broke.
     
Thread Status:
Not open for further replies.

Share This Page