Need Help

Discussion in 'Plugin Development' started by SuperOmegaCow, Jul 11, 2013.

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

    SuperOmegaCow

    Error with this code
    Code:java
    1. if ((cmd.getName().equalsIgnoreCase("guard")) &&
    2. (args.length == 0))
    3. {
    4. ItemStack dis = new ItemStack(Material.DIAMOND_SWORD);
    5. dis.addEnchantment(Enchantment.DAMAGE_ALL,5);
    6. dis.addEnchantment(Enchantment.FIRE_ASPECT,2);
    7. player.getInventory().addItem(dis);
    8. ItemStack sis = new ItemStack(Material.BOW);
    9. sis.addEnchantment(Enchantment.ARROW_DAMAGE,5);
    10. sis.addEnchantment(Enchantment.ARROW_INFINITE,1);
    11. player.getInventory().addItem(sis);
    12. ItemStack uis = new ItemStack(Material.ARROW);
    13. player.getInventory().addItem(uis);
    14. ItemStack qis = new ItemStack(Material.DIAMOND_HELMET);
    15. player.getInventory().addItem(qis);
    16. ItemStack xis = new ItemStack(Material.DIAMOND_CHESTPLATE);
    17. player.getInventory().addItem(xis);
    18. ItemStack kis = new ItemStack(Material.DIAMOND_LEGGINGS);
    19. player.getInventory().addItem(kis);
    20. ItemStack vis = new ItemStack(Material.DIAMOND_BOOTS);
    21. player.getInventory().addItem(vis);
    22. player.sendMessage( ChatColor.AQUA + "Here is your guard armour! To jail a player type" + ChatColor.RED + "./guard (player) (reason)");
    23. }


    Error:

    Code:
    2013-07-11 14:05:12 [INFO] MLG_KICK issued server command: /guard
    2013-07-11 14:05:12 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'guard' in plugin Chat v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:189)
        at org.bukkit.craftbukkit.v1_6_R2.CraftServer.dispatchCommand(CraftServer.java:523)
        at net.minecraft.server.v1_6_R2.PlayerConnection.handleCommand(PlayerConnection.java:964)
        at net.minecraft.server.v1_6_R2.PlayerConnection.chat(PlayerConnection.java:882)
        at net.minecraft.server.v1_6_R2.PlayerConnection.a(PlayerConnection.java:839)
        at net.minecraft.server.v1_6_R2.Packet3Chat.handle(SourceFile:49)
        at net.minecraft.server.v1_6_R2.NetworkManager.b(NetworkManager.java:296)
        at net.minecraft.server.v1_6_R2.PlayerConnection.e(PlayerConnection.java:118)
        at net.minecraft.server.v1_6_R2.ServerConnection.b(SourceFile:37)
        at net.minecraft.server.v1_6_R2.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:590)
        at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)
        at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
        at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
        at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    Caused by: java.lang.IllegalArgumentException: Specified enchantment cannot be applied to this itemstack
        at org.bukkit.inventory.ItemStack.addEnchantment(ItemStack.java:416)
        at me.mackenzie.Chat.Commands.onCommand(Commands.java:51)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
        ... 15 more
     
  2. Offline

    Tirelessly

    It may be that it starts at 0, but you're acting as if it starts at 1, i.e. you're adding sharp 6, fire aspect 3, etc
     
  3. Offline

    SuperOmegaCow

    so for example:
    sis.addEnchantment(Enchantment.ARROW_INFINITE);
    Edit: I tried that still error.
     
  4. Offline

    Sessional

    SuperOmegaCow
    What line is the error? The numbers are different in the code box then your script. What item stack and what enchantment exactly are not working?
     
  5. Offline

    SuperOmegaCow

    Weirdly it has started working :D
     
Thread Status:
Not open for further replies.

Share This Page