Solved Internal Error Occurred?

Discussion in 'Plugin Development' started by BuuR, Jul 5, 2015.

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

    BuuR

    when ever i try and use a command in-game, i get this error: "An internal error occurred while attempting to preform this command"

    wondering if anyone could help me figure out whats wrong?

    thanks,
    - BuuR

    Code:
    package me.buur.main;
    
    import static org.bukkit.ChatColor.*;
    
    import org.bukkit.Material;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.*;
    import org.bukkit.command.*;
    import org.bukkit.command.Command;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.inventory.*;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.entity.*;
    
    public class rpgpluginmain extends JavaPlugin {
    
        public void onEnable() {
    
        }
    
        public void onDisable() {
    
        }
       
       
    
    
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
           
    
            Player p = (Player) sender;
           
            if (label.equalsIgnoreCase("class")) {
                if (args.length == 0) {
                    p.sendMessage(RED + "No arguments. Try /class ?");
                }
               
                //CHARACTER CLASSES
               
                //WARRIOR
                if (args[0].equalsIgnoreCase("Choose")) {
                    if (args[1].equalsIgnoreCase("warrior")) {
                        Inventory inv = p.getInventory();
    
                        ItemStack warriorWeap = new ItemStack(Material.IRON_SWORD);
                        warriorWeap.addEnchantment(Enchantment.KNOCKBACK, 0);
                        ItemMeta warriorWeapMeta = warriorWeap.getItemMeta();
                        warriorWeapMeta.setDisplayName("Long Sword");
                        warriorWeap.setItemMeta(warriorWeapMeta);
                        ItemStack warriorHelm = new ItemStack(Material.IRON_HELMET);
                        ItemStack warriorChest = new ItemStack(Material.IRON_CHESTPLATE);
                        ItemStack warriorLegs = new ItemStack(Material.IRON_LEGGINGS);
                        ItemStack warriorFeet = new ItemStack(Material.IRON_BOOTS);
                        inv.addItem(warriorWeap);
                        inv.addItem(warriorHelm);
                        inv.addItem(warriorChest);
                        inv.addItem(warriorLegs);
                        inv.addItem(warriorFeet);
                        p.sendMessage(GREEN + "Fight hard, brave one!");
                    }
                   
                    //ARCHER
                   
                    if (args[1].equalsIgnoreCase("archer")) {
                        Inventory inv = p.getInventory();
    
                        ItemStack archerWeap = new ItemStack(Material.BOW);
                        ItemStack archerAmmo = new ItemStack(Material.ARROW, 128);
                        archerWeap.addEnchantment(Enchantment.ARROW_DAMAGE, 0);
                        ItemStack archerHelm = new ItemStack(Material.LEATHER_HELMET);
                        ItemStack archerChest = new ItemStack(Material.LEATHER_CHESTPLATE);
                        ItemStack archerLegs = new ItemStack(Material.LEATHER_LEGGINGS);
                        ItemStack archerFeet = new ItemStack(Material.LEATHER_BOOTS);
                        inv.addItem(archerWeap);
                        inv.addItem(archerAmmo);
                        inv.addItem(archerHelm);
                        inv.addItem(archerChest);
                        inv.addItem(archerLegs);
                        inv.addItem(archerFeet);
                        p.sendMessage(GREEN + "Fight hard, brave one!");
                    }
                   
                    //ROGUE
                   
                    if (args[0].equalsIgnoreCase("Choose")) {
                        if (args[1].equalsIgnoreCase("rogue")) {
                            Inventory inv = p.getInventory();
                            ItemStack rogueWeap = new ItemStack(Material.GOLD_SWORD);
                            rogueWeap.addEnchantment(Enchantment.DAMAGE_ALL, 0);
                            inv.addItem(rogueWeap);
                            p.sendMessage(GREEN + "Fight hard, brave one!");
    
                        }
           
                    }
    
                }
                if (args[0].equalsIgnoreCase("?")) {
                    p.sendMessage("Use /class choose [class name]");
                }
                if (args[0].equalsIgnoreCase("list")) {
                    p.sendMessage("List of classes: Warrior, Rogue, Archer.");
                }
               
               
            }
           
            if (p.getInventory().getItemInHand().getType() == Material.GOLD_SWORD){
                p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 0));
               
            }else if (p.getInventory().getItemInHand().getType() == Material.IRON_SWORD) {
                p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 999999, 0));
               
            }
           
            return true;
        }
    
       
    
    }
    Figured it out! i had the enchant levels set to "0", instead of "1"!

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

    WesJD

    @BuuR Please mark the thread as solved.
     
  3. Offline

    BuuR

    I actually have another question about my code. I want the bottom part to be continuously checking the player. how would i go about doing that?

    Code:
            }
          
            if (p.getInventory().getItemInHand().getType() == Material.GOLD_SWORD){
                p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 0));
              
            }else if (p.getInventory().getItemInHand().getType() == Material.IRON_SWORD) {
                p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 999999, 0));
              
            }
          
            return true;
        }
      
    }
     
Thread Status:
Not open for further replies.

Share This Page