Solved An internal error occoured while attemting to perfom this command

Discussion in 'Plugin Development' started by Azeron, Mar 24, 2016.

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

    Azeron

    org.bukkit.command.CommandException: Unhandled exception executing command 'bloc
    ks' in plugin Rewards v1.0
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spi
    got.jar:git-Spigot-550ebac-7019900]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:14
    1) ~[spigot.jar:git-Spigot-550ebac-7019900]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServe
    r.java:646) ~[spigot.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerCon
    nection.java:1115) [spigot.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java
    :950) [spigot.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java
    :26) [spigot.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java
    :53) [spigot.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spi
    got.jar:git-Spigot-550ebac-7019900]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [
    ?:1.8.0_73]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_73]
    at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:6
    96) [spigot.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:3
    16) [spigot.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:6
    34) [spigot.jar:git-Spigot-550ebac-7019900]
    at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java
    :537) [spigot.jar:git-Spigot-550ebac-7019900]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_73]
    Caused by: java.lang.IllegalArgumentException: Enchantment level is either too l
    ow or too high (given 15, bounds are 1 to 3)
    at org.bukkit.inventory.ItemStack.addEnchantment(ItemStack.java:438) ~[s
    pigot.jar:git-Spigot-550ebac-7019900]
    at me.azeron.rewards.Blocks.onCommand(Blocks.java:25) ~[?:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spi
    got.jar:git-Spigot-550ebac-7019900]
    ... 14 more


    Code:
    package me.azeron.rewards;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Core extends JavaPlugin{
     
     
     
    @Override
        public void onEnable() {
            getLogger().info("Rewards has been enabled");
            getCommand("blocks").setExecutor(new Blocks());
         
    }
    
        public void onDisable() {
            getLogger().info("Rewards has been disabled");
         
         
         
        }
     
    
        }
    
    

    Code:
    package me.azeron.rewards;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    
    public class Blocks implements CommandExecutor {
    
    //BLOCKS
        public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args) {
            if (sender instanceof Player){
                Player p = (Player)sender;
                if (commandlabel.equalsIgnoreCase("blocks")){
                ItemStack BloxPickaxe = new ItemStack(Material.DIAMOND_PICKAXE);
                ItemMeta m = BloxPickaxe.getItemMeta();
                BloxPickaxe.setItemMeta(m);
                p.getInventory().addItem(BloxPickaxe);
                m.setDisplayName("" + ChatColor.AQUA + ChatColor.BOLD + "BloxPickaxe");
                BloxPickaxe.addEnchantment(Enchantment.DURABILITY, 15);
                BloxPickaxe.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10);
                BloxPickaxe.addEnchantment(Enchantment.DIG_SPEED, 15);
                p.sendMessage(ChatColor.DARK_PURPLE + "Congratulations! You have broken the required blocks you'll get awarded with a" + ChatColor.AQUA + ChatColor.BOLD + BloxPickaxe);
                }
               
            return true;
        }
            return false;
           
    
        }
    
    
       
       
    
    }
    Please help idk what occours this error
     
  2. Offline

    Jetsinsu

    Caused by: java.lang.IllegalArgumentException: Enchantment level is either too l
    ow or too high (given 15, bounds are 1 to 3)

    You gave a higher enchantment lvl than the own game itself. You have to change it to a lower lvl like 1-5 depending on what lvl is possible to give to that specific item or enchantment.
     
  3. Offline

    Azeron

    @Jetsinsu Thanks, but do you know why it says this? [​IMG]
     
  4. Offline

    Kilorbine

    Hi, @Azeron
    As said by Jetsinu, the probleme is that you set a too higher level for an enchant.

    Code:
    BloxPickaxe.addEnchantment(Enchantment.DURABILITY, 15);
    BloxPickaxe.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10);
    BloxPickaxe.addEnchantment(Enchantment.DIG_SPEED, 15);
    Here, you set Dig_speed and Durability to 15.
    As I've seen on internet, max level are 5.

    Try this instead :
    Code:
    BloxPickaxe.addEnchantment(Enchantment.DURABILITY, 5);
    BloxPickaxe.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10);
    BloxPickaxe.addEnchantment(Enchantment.DIG_SPEED, 5);
     
  5. Offline

    _loco_

    Alternatively, if you want level 15 enchantments, you can do this:

    Code:
    BloxPickaxe.addUnsafeEnchantment(Enchantment.DURABILITY, 15);
    BloxPickaxe.addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 10);
    BloxPickaxe.addUnsafeEnchantment(Enchantment.DIG_SPEED, 15);
     
  6. Offline

    Azeron

    Can someone help please? I've fixed alot but it enchantments doesn't work and the name is still diamond pickaxe, it also says "Congratulations! You have broken the required blocks you'll get awarded with a and now here's the enchantment code and rename code"
     
    Last edited by a moderator: Mar 24, 2016
  7. Offline

    mcdorli

    You need to give the player the pickaxe after you set all the echantments and name
     
  8. Offline

    Azeron

    @mcdorli Thanks alot, btw do you know how to make it like they have to break 7.5k blocks before they can do this command?
     
  9. Offline

    ComputerTurtle

    You can try using the BlockBreakEvent. On each break, +1 to the players blocks broken.
    Use this to send to a player storage file (config or whatever)

    Then you can check the config (get if the int is >= 7500)
    and then adding the permission to the player.
     
  10. Offline

    Azeron

  11. Offline

    ComputerTurtle

    Block break event:
    Code:
    @EventHandler
        public void onBlockBreak(BlockBreakEvent e) {
    }
    Use this to check if the block is not AIR
    Code:
    @EventHandler
    public void onBlockBreak(BlockBreakEvent e) {
        if (e.getBlock().getType() != Material.AIR) { 
        }
    }
    Now you can then add the player to the config, aswell as adding +1 blocks broken.
    Code:
        @EventHandler
        public void onBlockBreak(BlockBreakEvent e) {
            if (e.getBlock().getType() != Material.AIR) {
             
            }else{
                //This will get the players name, and then add a blocksbroken with the blocks broken value under the player's name in the config.
                this.getConfig().addDefault(e.getPlayer().getName() + ".blocksbroken", +1);
            }
        }
     
  12. Offline

    Azeron

Thread Status:
Not open for further replies.

Share This Page