An internal error occured.

Discussion in 'Plugin Development' started by AlpacaKyle, Mar 4, 2020.

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

    AlpacaKyle

    Hello! I am coding my own plugin, and I get an error in Minecraft when I run the command. The error is: An internal error occurred while trying to perform this command. And I don't know whats wrong. Here's my code:
    Code:
     
            if (command.getName().equalsIgnoreCase("setHunger")) {
                Player p = (Player) sender;
                if (args == null || args.length == 0) {
                    p.setFoodLevel(20);
                    sender.sendMessage("Your Appetite Has Been Sated.");
                }
                if (args[0] != null) {
                    p.setFoodLevel(Integer.valueOf(args[0]));
                    sender.sendMessage("Your Hunger Has Been Set To: " + args[0]);
                }
                return true;
            }
     
  2. Online

    timtower Administrator Administrator Moderator

    @AlpacaKyle args will never be null.
    args[0] needs to be checked with a length check, not with == null, that will throw an IndexOutOfBounds error.
     
  3. Offline

    Machine Maker

    @AlpacaKyle typically when you see that message, "An internal error has occurred..." there will be an associated error message in the console. When you ask questions about those errors in the future, please provide that message as it gives a lot more information.
     
  4. Offline

    AlpacaKyle

    I have solved the issue.
     
  5. Offline

    Machine Maker

    That is good to hear! Please mark this thread as Solved by clicking the Thread Tools link near the top of the page.
     
Thread Status:
Not open for further replies.

Share This Page