An internal error occurred while attempting to preform the command

Discussion in 'Plugin Development' started by BIG AL 117, Apr 18, 2014.

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

    BIG AL 117

    Hey everyone, so i have been working on a custom plugin, and am having a problem when i type in /[The command] it sends me a message saying "An internal error occurred while attempting to preform the command". Now i'm still new to java and i don't know how to fix this, can anyone help?
     
  2. Offline

    MrInspector

    A code, a error log, and possibly your plugin yml would be helpful, the plugin yml is really optional if you don't want to.
     
  3. Offline

    BIG AL 117

    MrInspector ok Here is the Log:
    [23:12:05] [Server thread/INFO]: BIG_AL_117 issued server command: /wardrobe
    [23:12:05] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'wardrobe' in plugin HubWardrobe v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:175) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:683) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerConnection.java:952) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:814) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_7_R1.inventory.CraftMetaItem cannot be cast to org.bukkit.inventory.meta.LeatherArmorMeta
    at me.BIGAL117.HubWardrobe.Main.onCommand(Main.java:35) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    ... 13 more

    And here is the Plugin.yml:
    main: me.BIGAL117.HubWardrobe.Main
    name: HubWardrobe
    version: 1.0
    auther: BIG_AL_117
    description: Allows users to wear armor in the Hub!
    commands:
    Wardrobe:
    description: brings up a wardrobe gui.
    usage: /wardrobe
    permission: HubWardrobe.use
    permission-message: You don't have permmission to use that command.
     
  4. Offline

    DoctorDark

    BIG AL 117 So what is Line 35 in your Main class in the HubWardrobe plugin?
     
  5. Offline

    MrInspector

    We uh, still need your code. :p
     
  6. Offline

    BIG AL 117

    Right sorry, here it is:
    Code:java
    1. package me.BIGAL117.HubWardrobe;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Color;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.inventory.Inventory;
    12. import org.bukkit.inventory.ItemStack;
    13. import org.bukkit.inventory.meta.LeatherArmorMeta;
    14. import org.bukkit.plugin.java.JavaPlugin;
    15.  
    16. public final class Main extends JavaPlugin
    17. implements Listener
    18. {
    19. public Inventory inv = null;
    20.  
    21. public void onEnable() {
    22. System.out.println("Plugin Enabled");
    23. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    24. }
    25.  
    26. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    27. Player p = (Player)sender;
    28. if (cmd.getName().equalsIgnoreCase("wardrobe")) {
    29. if (p.hasPermission("wardrobe.use")) {
    30. this.inv = p.getServer().createInventory(null, 36, "Choose your outfit");
    31. }
    32.  
    33. ItemStack hat2 = new ItemStack(Material.DIAMOND_HELMET);
    34. LeatherArmorMeta meta2 = (LeatherArmorMeta)hat2.getItemMeta();
    35. meta2.setDisplayName(ChatColor.AQUA + "Diamond Helmet");
    36. meta2.setColor(Color.AQUA);
    37. hat2.setItemMeta(meta2);
    38. this.inv.setItem(2, hat2);
    39.  
    40. ItemStack hat3 = new ItemStack(Material.IRON_HELMET);
    41. LeatherArmorMeta meta3 = (LeatherArmorMeta)hat3.getItemMeta();
    42. meta3.setDisplayName(ChatColor.WHITE + "Iron Helmet");
    43. meta3.setColor(Color.WHITE);
    44. hat3.setItemMeta(meta3);
    45. this.inv.setItem(3, hat3);
    46.  
    47. ItemStack hat4 = new ItemStack(Material.CHAINMAIL_HELMET);
    48. LeatherArmorMeta meta4 = (LeatherArmorMeta)hat4.getItemMeta();
    49. meta4.setDisplayName(ChatColor.GRAY + "ChainMail Helmet");
    50. meta4.setColor(Color.GRAY);
    51. hat4.setItemMeta(meta4);
    52. this.inv.setItem(4, hat4);
    53.  
    54. ItemStack hat5 = new ItemStack(Material.GOLD_HELMET);
    55. LeatherArmorMeta meta5 = (LeatherArmorMeta)hat5.getItemMeta();
    56. meta5.setDisplayName(ChatColor.YELLOW + "GOLD HELMET");
    57. meta5.setColor(Color.YELLOW);
    58. hat5.setItemMeta(meta5);
    59. this.inv.setItem(5, hat5);
    60.  
    61. ItemStack hat6 = new ItemStack(Material.LEATHER_HELMET);
    62. LeatherArmorMeta meta6 = (LeatherArmorMeta)hat6.getItemMeta();
    63. meta6.setDisplayName(ChatColor.RED + "Leather Helmet");
    64. meta6.setColor(Color.RED);
    65. hat6.setItemMeta(meta6);
    66. this.inv.setItem(6, hat6);
    67.  
    68. ItemStack shirt3 = new ItemStack(Material.DIAMOND_CHESTPLATE);
    69. LeatherArmorMeta shirt3m = (LeatherArmorMeta)shirt3.getItemMeta();
    70. shirt3m.setDisplayName(ChatColor.AQUA + "Diamond Chestplate");
    71. shirt3m.setColor(Color.AQUA);
    72. shirt3.setItemMeta(shirt3m);
    73. this.inv.setItem(11, shirt3);
    74.  
    75. ItemStack shirt4 = new ItemStack(Material.IRON_CHESTPLATE);
    76. LeatherArmorMeta shirt4m = (LeatherArmorMeta)shirt4.getItemMeta();
    77. shirt4m.setDisplayName(ChatColor.WHITE + "Iron Chestplate");
    78. shirt4m.setColor(Color.WHITE);
    79. shirt4.setItemMeta(shirt4m);
    80. this.inv.setItem(12, shirt4);
    81.  
    82. ItemStack shirt5 = new ItemStack(Material.CHAINMAIL_CHESTPLATE);
    83. LeatherArmorMeta shirt5m = (LeatherArmorMeta)shirt5.getItemMeta();
    84. shirt5m.setDisplayName(ChatColor.GRAY + "Chainmail Chestplate");
    85. shirt5m.setColor(Color.GRAY);
    86. shirt5.setItemMeta(shirt5m);
    87. this.inv.setItem(13, shirt5);
    88.  
    89. ItemStack shirt6 = new ItemStack(Material.GOLD_CHESTPLATE);
    90. LeatherArmorMeta shirt6m = (LeatherArmorMeta)shirt6.getItemMeta();
    91. shirt6m.setDisplayName(ChatColor.YELLOW + "Gold Chestplate");
    92. shirt6m.setColor(Color.YELLOW);
    93. shirt6.setItemMeta(shirt6m);
    94. this.inv.setItem(14, shirt6);
    95.  
    96. ItemStack shirt7 = new ItemStack(Material.LEATHER_CHESTPLATE);
    97. LeatherArmorMeta shirt7m = (LeatherArmorMeta)shirt7.getItemMeta();
    98. shirt7m.setDisplayName(ChatColor.RED + "Leather Chestplate");
    99. shirt7m.setColor(Color.RED);
    100. shirt7.setItemMeta(shirt7m);
    101. this.inv.setItem(15, shirt7);
    102.  
    103. ItemStack leggings4 = new ItemStack(Material.DIAMOND_LEGGINGS);
    104. LeatherArmorMeta leggings4m = (LeatherArmorMeta)leggings4.getItemMeta();
    105. leggings4m.setDisplayName(ChatColor.AQUA + "Diamond Leggings");
    106. leggings4m.setColor(Color.AQUA);
    107. leggings4.setItemMeta(leggings4m);
    108. this.inv.setItem(20, leggings4);
    109.  
    110. ItemStack leggings5 = new ItemStack(Material.IRON_LEGGINGS);
    111. LeatherArmorMeta leggings5m = (LeatherArmorMeta)leggings5.getItemMeta();
    112. leggings5m.setDisplayName(ChatColor.WHITE + "Iron Leggings");
    113. leggings5m.setColor(Color.WHITE);
    114. leggings5.setItemMeta(leggings5m);
    115. this.inv.setItem(21, leggings5);
    116.  
    117. ItemStack leggings6 = new ItemStack(Material.CHAINMAIL_LEGGINGS);
    118. LeatherArmorMeta leggings6m = (LeatherArmorMeta)leggings6.getItemMeta();
    119. leggings6m.setDisplayName(ChatColor.GRAY + "Chainmail Leggings");
    120. leggings6m.setColor(Color.GRAY);
    121. leggings6.setItemMeta(leggings6m);
    122. this.inv.setItem(22, leggings6);
    123.  
    124. ItemStack leggings7 = new ItemStack(Material.GOLD_LEGGINGS);
    125. LeatherArmorMeta leggings7m = (LeatherArmorMeta)leggings7.getItemMeta();
    126. leggings7m.setDisplayName(ChatColor.YELLOW + "Gold Leggings");
    127. leggings7m.setColor(Color.YELLOW);
    128. leggings7.setItemMeta(leggings7m);
    129. this.inv.setItem(23, leggings7);
    130.  
    131. ItemStack leggings8 = new ItemStack(Material.LEATHER_LEGGINGS);
    132. LeatherArmorMeta leggings8m = (LeatherArmorMeta)leggings8.getItemMeta();
    133. leggings8m.setDisplayName(ChatColor.RED + "Leather Leggings");
    134. leggings8m.setColor(Color.RED);
    135. leggings8.setItemMeta(leggings8m);
    136. this.inv.setItem(24, leggings8);
    137.  
    138. ItemStack boots8 = new ItemStack(Material.DIAMOND_BOOTS);
    139. LeatherArmorMeta boots8m = (LeatherArmorMeta)boots8.getItemMeta();
    140. boots8m.setDisplayName(ChatColor.AQUA + "Diamond Boots");
    141. boots8m.setColor(Color.AQUA);
    142. boots8.setItemMeta(boots8m);
    143. this.inv.setItem(29, boots8);
    144.  
    145. ItemStack boots9 = new ItemStack(Material.IRON_BOOTS);
    146. LeatherArmorMeta boots9m = (LeatherArmorMeta)boots9.getItemMeta();
    147. boots9m.setDisplayName(ChatColor.WHITE + "Iron Boots");
    148. boots9m.setColor(Color.WHITE);
    149. boots9.setItemMeta(boots9m);
    150. this.inv.setItem(30, boots9);
    151.  
    152. ItemStack boots10 = new ItemStack(Material.CHAINMAIL_BOOTS);
    153. LeatherArmorMeta boots10m = (LeatherArmorMeta)boots10.getItemMeta();
    154. boots10m.setDisplayName(ChatColor.GRAY + "Chainmail Boots");
    155. boots10m.setColor(Color.GRAY);
    156. boots10.setItemMeta(boots10m);
    157. this.inv.setItem(31, boots10);
    158.  
    159. ItemStack boots11 = new ItemStack(Material.GOLD_BOOTS);
    160. LeatherArmorMeta boots11m = (LeatherArmorMeta)boots11.getItemMeta();
    161. boots11m.setDisplayName(ChatColor.YELLOW + "Gold Boots");
    162. boots11m.setColor(Color.YELLOW);
    163. boots11.setItemMeta(boots11m);
    164. this.inv.setItem(32, boots11);
    165.  
    166. ItemStack boots12 = new ItemStack(Material.LEATHER_BOOTS);
    167. LeatherArmorMeta boots12m = (LeatherArmorMeta)boots12.getItemMeta();
    168. boots12m.setDisplayName(ChatColor.RED + "Leather Boots");
    169. boots12m.setColor(Color.RED);
    170. boots12.setItemMeta(boots12m);
    171. this.inv.setItem(33, boots12);
    172.  
    173. p.openInventory(this.inv);
    174. return true;
    175. }
    176.  
    177. return false;
    178. }
    179. }
    180.  
     
  7. Offline

    Nici900800

    AHH!
    It is helpful if you make this:
    Code:java
    1. package me.BIGAL117.HubWardrobe;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Color;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.inventory.Inventory;
    12. import org.bukkit.inventory.ItemStack;
    13. import org.bukkit.inventory.meta.LeatherArmorMeta;
    14. import org.bukkit.plugin.java.JavaPlugin;
    15.  
    16. public final class Main extends JavaPlugin
    17. implements Listener
    18. {
    19. public Inventory inv = null;
    20.  
    21. public void onEnable() {
    22. System.out.println("Plugin Enabled");
    23. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    24. }
    25.  
    26. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    27. Player p = (Player)sender;
    28. if (cmd.getName().equalsIgnoreCase("wardrobe")) {
    29. if (p.hasPermission("wardrobe.use")) {
    30. this.inv = p.getServer().createInventory(null, 36, "Choose your outfit");
    31. }
    32.  
    33. ItemStack hat2 = new ItemStack(Material.DIAMOND_HELMET);
    34. LeatherArmorMeta meta2 = (LeatherArmorMeta)hat2.getItemMeta();
    35. meta2.setDisplayName(ChatColor.AQUA + "Diamond Helmet");
    36. meta2.setColor(Color.AQUA);
    37. hat2.setItemMeta(meta2);
    38. this.inv.setItem(2, hat2);
    39.  
    40. ItemStack hat3 = new ItemStack(Material.IRON_HELMET);
    41. LeatherArmorMeta meta3 = (LeatherArmorMeta)hat3.getItemMeta();
    42. meta3.setDisplayName(ChatColor.WHITE + "Iron Helmet");
    43. meta3.setColor(Color.WHITE);
    44. hat3.setItemMeta(meta3);
    45. this.inv.setItem(3, hat3);
    46.  
    47. ItemStack hat4 = new ItemStack(Material.CHAINMAIL_HELMET);
    48. LeatherArmorMeta meta4 = (LeatherArmorMeta)hat4.getItemMeta();
    49. meta4.setDisplayName(ChatColor.GRAY + "ChainMail Helmet");
    50. meta4.setColor(Color.GRAY);
    51. hat4.setItemMeta(meta4);
    52. this.inv.setItem(4, hat4);
    53.  
    54. ItemStack hat5 = new ItemStack(Material.GOLD_HELMET);
    55. LeatherArmorMeta meta5 = (LeatherArmorMeta)hat5.getItemMeta();
    56. meta5.setDisplayName(ChatColor.YELLOW + "GOLD HELMET");
    57. meta5.setColor(Color.YELLOW);
    58. hat5.setItemMeta(meta5);
    59. this.inv.setItem(5, hat5);
    60.  
    61. ItemStack hat6 = new ItemStack(Material.LEATHER_HELMET);
    62. LeatherArmorMeta meta6 = (LeatherArmorMeta)hat6.getItemMeta();
    63. meta6.setDisplayName(ChatColor.RED + "Leather Helmet");
    64. meta6.setColor(Color.RED);
    65. hat6.setItemMeta(meta6);
    66. this.inv.setItem(6, hat6);
    67.  
    68. ItemStack shirt3 = new ItemStack(Material.DIAMOND_CHESTPLATE);
    69. LeatherArmorMeta shirt3m = (LeatherArmorMeta)shirt3.getItemMeta();
    70. shirt3m.setDisplayName(ChatColor.AQUA + "Diamond Chestplate");
    71. shirt3m.setColor(Color.AQUA);
    72. shirt3.setItemMeta(shirt3m);
    73. this.inv.setItem(11, shirt3);
    74.  
    75. ItemStack shirt4 = new ItemStack(Material.IRON_CHESTPLATE);
    76. LeatherArmorMeta shirt4m = (LeatherArmorMeta)shirt4.getItemMeta();
    77. shirt4m.setDisplayName(ChatColor.WHITE + "Iron Chestplate");
    78. shirt4m.setColor(Color.WHITE);
    79. shirt4.setItemMeta(shirt4m);
    80. this.inv.setItem(12, shirt4);
    81.  
    82. ItemStack shirt5 = new ItemStack(Material.CHAINMAIL_CHESTPLATE);
    83. LeatherArmorMeta shirt5m = (LeatherArmorMeta)shirt5.getItemMeta();
    84. shirt5m.setDisplayName(ChatColor.GRAY + "Chainmail Chestplate");
    85. shirt5m.setColor(Color.GRAY);
    86. shirt5.setItemMeta(shirt5m);
    87. this.inv.setItem(13, shirt5);
    88.  
    89. ItemStack shirt6 = new ItemStack(Material.GOLD_CHESTPLATE);
    90. LeatherArmorMeta shirt6m = (LeatherArmorMeta)shirt6.getItemMeta();
    91. shirt6m.setDisplayName(ChatColor.YELLOW + "Gold Chestplate");
    92. shirt6m.setColor(Color.YELLOW);
    93. shirt6.setItemMeta(shirt6m);
    94. this.inv.setItem(14, shirt6);
    95.  
    96. ItemStack shirt7 = new ItemStack(Material.LEATHER_CHESTPLATE);
    97. LeatherArmorMeta shirt7m = (LeatherArmorMeta)shirt7.getItemMeta();
    98. shirt7m.setDisplayName(ChatColor.RED + "Leather Chestplate");
    99. shirt7m.setColor(Color.RED);
    100. shirt7.setItemMeta(shirt7m);
    101. this.inv.setItem(15, shirt7);
    102.  
    103. ItemStack leggings4 = new ItemStack(Material.DIAMOND_LEGGINGS);
    104. LeatherArmorMeta leggings4m = (LeatherArmorMeta)leggings4.getItemMeta();
    105. leggings4m.setDisplayName(ChatColor.AQUA + "Diamond Leggings");
    106. leggings4m.setColor(Color.AQUA);
    107. leggings4.setItemMeta(leggings4m);
    108. this.inv.setItem(20, leggings4);
    109.  
    110. ItemStack leggings5 = new ItemStack(Material.IRON_LEGGINGS);
    111. LeatherArmorMeta leggings5m = (LeatherArmorMeta)leggings5.getItemMeta();
    112. leggings5m.setDisplayName(ChatColor.WHITE + "Iron Leggings");
    113. leggings5m.setColor(Color.WHITE);
    114. leggings5.setItemMeta(leggings5m);
    115. this.inv.setItem(21, leggings5);
    116.  
    117. ItemStack leggings6 = new ItemStack(Material.CHAINMAIL_LEGGINGS);
    118. LeatherArmorMeta leggings6m = (LeatherArmorMeta)leggings6.getItemMeta();
    119. leggings6m.setDisplayName(ChatColor.GRAY + "Chainmail Leggings");
    120. leggings6m.setColor(Color.GRAY);
    121. leggings6.setItemMeta(leggings6m);
    122. this.inv.setItem(22, leggings6);
    123.  
    124. ItemStack leggings7 = new ItemStack(Material.GOLD_LEGGINGS);
    125. LeatherArmorMeta leggings7m = (LeatherArmorMeta)leggings7.getItemMeta();
    126. leggings7m.setDisplayName(ChatColor.YELLOW + "Gold Leggings");
    127. leggings7m.setColor(Color.YELLOW);
    128. leggings7.setItemMeta(leggings7m);
    129. this.inv.setItem(23, leggings7);
    130.  
    131. ItemStack leggings8 = new ItemStack(Material.LEATHER_LEGGINGS);
    132. LeatherArmorMeta leggings8m = (LeatherArmorMeta)leggings8.getItemMeta();
    133. leggings8m.setDisplayName(ChatColor.RED + "Leather Leggings");
    134. leggings8m.setColor(Color.RED);
    135. leggings8.setItemMeta(leggings8m);
    136. this.inv.setItem(24, leggings8);
    137.  
    138. ItemStack boots8 = new ItemStack(Material.DIAMOND_BOOTS);
    139. LeatherArmorMeta boots8m = (LeatherArmorMeta)boots8.getItemMeta();
    140. boots8m.setDisplayName(ChatColor.AQUA + "Diamond Boots");
    141. boots8m.setColor(Color.AQUA);
    142. boots8.setItemMeta(boots8m);
    143. this.inv.setItem(29, boots8);
    144.  
    145. ItemStack boots9 = new ItemStack(Material.IRON_BOOTS);
    146. LeatherArmorMeta boots9m = (LeatherArmorMeta)boots9.getItemMeta();
    147. boots9m.setDisplayName(ChatColor.WHITE + "Iron Boots");
    148. boots9m.setColor(Color.WHITE);
    149. boots9.setItemMeta(boots9m);
    150. this.inv.setItem(30, boots9);
    151.  
    152. ItemStack boots10 = new ItemStack(Material.CHAINMAIL_BOOTS);
    153. LeatherArmorMeta boots10m = (LeatherArmorMeta)boots10.getItemMeta();
    154. boots10m.setDisplayName(ChatColor.GRAY + "Chainmail Boots");
    155. boots10m.setColor(Color.GRAY);
    156. boots10.setItemMeta(boots10m);
    157. this.inv.setItem(31, boots10);
    158.  
    159. ItemStack boots11 = new ItemStack(Material.GOLD_BOOTS);
    160. LeatherArmorMeta boots11m = (LeatherArmorMeta)boots11.getItemMeta();
    161. boots11m.setDisplayName(ChatColor.YELLOW + "Gold Boots");
    162. boots11m.setColor(Color.YELLOW);
    163. boots11.setItemMeta(boots11m);
    164. this.inv.setItem(32, boots11);
    165.  
    166. ItemStack boots12 = new ItemStack(Material.LEATHER_BOOTS);
    167. LeatherArmorMeta boots12m = (LeatherArmorMeta)boots12.getItemMeta();
    168. boots12m.setDisplayName(ChatColor.RED + "Leather Boots");
    169. boots12m.setColor(Color.RED);
    170. boots12.setItemMeta(boots12m);
    171. this.inv.setItem(33, boots12);
    172.  
    173. p.openInventory(this.inv);
    174. return true;
    175. }
    176. return false;
    177. }
    178. }
     
  8. Offline

    DoctorDark

    BIG AL 117

    You are trying to cast non leather items as leather;

    Try using these itemstacks I have provided for you:
    Code:java
    1. ItemStack hat2 = new ItemStack(Material.DIAMOND_HELMET);
    2. ItemMeta meta2 = hat2.getItemMeta();
    3. meta2.setDisplayName(ChatColor.AQUA + "Diamond Helmet");
    4. hat2.setItemMeta(meta2);
    5. this.inv.setItem(2, hat2);
    6.  
    7. ItemStack hat3 = new ItemStack(Material.IRON_HELMET);
    8. ItemMeta meta3 = hat3.getItemMeta();
    9. meta3.setDisplayName(ChatColor.WHITE + "Iron Helmet");
    10. hat3.setItemMeta(meta3);
    11. this.inv.setItem(3, hat3);
    12.  
    13. ItemStack hat4 = new ItemStack(Material.CHAINMAIL_HELMET);
    14. ItemMeta meta4 = hat4.getItemMeta();
    15. meta4.setDisplayName(ChatColor.GRAY + "ChainMail Helmet");
    16. hat4.setItemMeta(meta4);
    17. this.inv.setItem(4, hat4);
    18.  
    19. ItemStack hat5 = new ItemStack(Material.GOLD_HELMET);
    20. ItemMeta meta5 = hat5.getItemMeta();
    21. meta5.setDisplayName(ChatColor.YELLOW + "GOLD HELMET");
    22. hat5.setItemMeta(meta5);
    23. this.inv.setItem(5, hat5);
    24.  
    25. ItemStack hat6 = new ItemStack(Material.LEATHER_HELMET);
    26. LeatherArmorMeta meta6 = (LeatherArmorMeta)hat6.getItemMeta();
    27. meta6.setDisplayName(ChatColor.RED + "Leather Helmet");
    28. meta6.setColor(Color.RED);
    29. hat6.setItemMeta(meta6);
    30. this.inv.setItem(6, hat6);
    31.  
    32. ItemStack shirt3 = new ItemStack(Material.DIAMOND_CHESTPLATE);
    33. ItemMeta shirt3m = shirt3.getItemMeta();
    34. shirt3m.setDisplayName(ChatColor.AQUA + "Diamond Chestplate");
    35. shirt3.setItemMeta(shirt3m);
    36. this.inv.setItem(11, shirt3);
    37.  
    38. ItemStack shirt4 = new ItemStack(Material.IRON_CHESTPLATE);
    39. ItemMeta shirt4m = shirt4.getItemMeta();
    40. shirt4m.setDisplayName(ChatColor.WHITE + "Iron Chestplate");
    41. shirt4.setItemMeta(shirt4m);
    42. this.inv.setItem(12, shirt4);
    43.  
    44. ItemStack shirt5 = new ItemStack(Material.CHAINMAIL_CHESTPLATE);
    45. ItemMeta shirt5m = shirt5.getItemMeta();
    46. shirt5m.setDisplayName(ChatColor.GRAY + "Chainmail Chestplate");
    47. shirt5.setItemMeta(shirt5m);
    48. this.inv.setItem(13, shirt5);
    49.  
    50. ItemStack shirt6 = new ItemStack(Material.GOLD_CHESTPLATE);
    51. ItemMeta shirt6m = shirt6.getItemMeta();
    52. shirt6m.setDisplayName(ChatColor.YELLOW + "Gold Chestplate");
    53. shirt6.setItemMeta(shirt6m);
    54. this.inv.setItem(14, shirt6);
    55.  
    56. ItemStack shirt7 = new ItemStack(Material.LEATHER_CHESTPLATE);
    57. LeatherArmorMeta shirt7m = (LeatherArmorMeta) shirt7.getItemMeta();
    58. shirt7m.setDisplayName(ChatColor.RED + "Leather Chestplate");
    59. shirt7m.setColor(Color.RED);
    60. shirt7.setItemMeta(shirt7m);
    61. this.inv.setItem(15, shirt7);
    62.  
    63. ItemStack leggings4 = new ItemStack(Material.DIAMOND_LEGGINGS);
    64. ItemMeta leggings4m = leggings4.getItemMeta();
    65. leggings4m.setDisplayName(ChatColor.AQUA + "Diamond Leggings");
    66. leggings4.setItemMeta(leggings4m);
    67. this.inv.setItem(20, leggings4);
    68.  
    69. ItemStack leggings5 = new ItemStack(Material.IRON_LEGGINGS);
    70. LeatherArmorMeta leggings5m = (LeatherArmorMeta)leggings5.getItemMeta();
    71. leggings5m.setDisplayName(ChatColor.WHITE + "Iron Leggings");
    72. leggings5m.setColor(Color.WHITE);
    73. leggings5.setItemMeta(leggings5m);
    74. this.inv.setItem(21, leggings5);
    75.  
    76. ItemStack leggings6 = new ItemStack(Material.CHAINMAIL_LEGGINGS);
    77. LeatherArmorMeta leggings6m = (LeatherArmorMeta)leggings6.getItemMeta();
    78. leggings6m.setDisplayName(ChatColor.GRAY + "Chainmail Leggings");
    79. leggings6m.setColor(Color.GRAY);
    80. leggings6.setItemMeta(leggings6m);
    81. this.inv.setItem(22, leggings6);
    82.  
    83. ItemStack leggings7 = new ItemStack(Material.GOLD_LEGGINGS);
    84. LeatherArmorMeta leggings7m = (LeatherArmorMeta)leggings7.getItemMeta();
    85. leggings7m.setDisplayName(ChatColor.YELLOW + "Gold Leggings");
    86. leggings7m.setColor(Color.YELLOW);
    87. leggings7.setItemMeta(leggings7m);
    88. this.inv.setItem(23, leggings7);
    89.  
    90. ItemStack leggings8 = new ItemStack(Material.LEATHER_LEGGINGS);
    91. LeatherArmorMeta leggings8m = (LeatherArmorMeta)leggings8.getItemMeta();
    92. leggings8m.setDisplayName(ChatColor.RED + "Leather Leggings");
    93. leggings8m.setColor(Color.RED);
    94. leggings8.setItemMeta(leggings8m);
    95. this.inv.setItem(24, leggings8);
    96.  
    97. ItemStack boots8 = new ItemStack(Material.DIAMOND_BOOTS);
    98. LeatherArmorMeta boots8m = (LeatherArmorMeta)boots8.getItemMeta();
    99. boots8m.setDisplayName(ChatColor.AQUA + "Diamond Boots");
    100. boots8m.setColor(Color.AQUA);
    101. boots8.setItemMeta(boots8m);
    102. this.inv.setItem(29, boots8);
    103.  
    104. ItemStack boots9 = new ItemStack(Material.IRON_BOOTS);
    105. LeatherArmorMeta boots9m = (LeatherArmorMeta)boots9.getItemMeta();
    106. boots9m.setDisplayName(ChatColor.WHITE + "Iron Boots");
    107. boots9m.setColor(Color.WHITE);
    108. boots9.setItemMeta(boots9m);
    109. this.inv.setItem(30, boots9);
    110.  
    111. ItemStack boots10 = new ItemStack(Material.CHAINMAIL_BOOTS);
    112. LeatherArmorMeta boots10m = (LeatherArmorMeta)boots10.getItemMeta();
    113. boots10m.setDisplayName(ChatColor.GRAY + "Chainmail Boots");
    114. boots10m.setColor(Color.GRAY);
    115. boots10.setItemMeta(boots10m);
    116. this.inv.setItem(31, boots10);
    117.  
    118. ItemStack boots11 = new ItemStack(Material.GOLD_BOOTS);
    119. LeatherArmorMeta boots11m = (LeatherArmorMeta)boots11.getItemMeta();
    120. boots11m.setDisplayName(ChatColor.YELLOW + "Gold Boots");
    121. boots11m.setColor(Color.YELLOW);
    122. boots11.setItemMeta(boots11m);
    123. this.inv.setItem(32, boots11);
    124.  
    125. ItemStack boots12 = new ItemStack(Material.LEATHER_BOOTS);
    126. LeatherArmorMeta boots12m = (LeatherArmorMeta)boots12.getItemMeta();
    127. boots12m.setDisplayName(ChatColor.RED + "Leather Boots");
    128. boots12m.setColor(Color.RED);
    129. boots12.setItemMeta(boots12m);
    130. this.inv.setItem(33, boots12);
     
  9. Offline

    BIG AL 117

    DoctorDark I tried that and it still gave me an error. Here is the log:

    [01:50:36] [Server thread/INFO]: BIG_AL_117 issued server command: /wardrobe
    [01:50:36] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'wardrobe' in plugin HubWardrobe v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:175) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:683) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerConnection.java:952) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:814) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_7_R1.inventory.CraftMetaItem cannot be cast to org.bukkit.inventory.meta.LeatherArmorMeta
    at me.BIGAL117.HubWardrobe.Main.onCommand(Main.java:34) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-2-g85f5776-b3024jnks]
    ... 13 more
     
  10. Offline

    clmcd42

    What is at line 34 of your main class when you put it into the compiler?
     
  11. Offline

    BIG AL 117

    clmcd42 It is: LeatherArmorMeta meta2 =(LeatherArmorMeta)hat2.getItemMeta();
     
  12. Offline

    clmcd42

    BIG AL 117 I don't know very much about ItemStacks and stuff so i could be totally off, but you're casting a Diamond helmet meta into leather armor meta. That may be a problem?
     
  13. Offline

    Funergy

    You are adding the items when he has not the permission and the inventory isn't made.
    and that will give an error.
    try to add the items when he has the permission.
     
  14. Offline

    BIG AL 117

    Funergy well if he is OP wouldn't it not matter? right?

    @clmcd42 I changed it to this:
    1. ItemMeta meta2 = hat2.getItemMeta();

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  15. Offline

    Funergy

    You don't understand me
     
  16. Offline

    Slikey

    You cannot change the color of non-leather items. Make sure to check if the ItemMeta is an instance of LeatherItemMeta.

    Code:
    ItemMeta meta = item.getItemMeta();
    if (meta instanceof LeatherItemMeta) {
        ((LeatherItemMeta) meta).setColor(Color.AQUA);
    }
     
Thread Status:
Not open for further replies.

Share This Page