Internal Server Error upon command send.

Discussion in 'Plugin Development' started by Gabezter4, Aug 30, 2014.

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

    Gabezter4

    When I issue my command(/ca) it disconnects me with the internal server error. I have think I have found my error in the way I am getting the player config, but not 100% sure becuase the error I am getting is not stating where in my code it says the error is. The error is giving me the null exceptions and the only thing I find null in my code is my config accessor which is null out of the onCommand Method and I set it to something in the method. I ask you am I correct on my finding of the error? If so I ask can you guide me in the way of fixing it. Also if I am wrong can you please tell me what I have done wrong and also guide me in the way of fixing it. I don't expect you to just give me the answer with the code. Here is my full source code: https://github.com/Gabezter/Chest-Access

    My Error:
    Code:
    Player Disconnected
    
    
    30.08 16:48:45 [Disconnect] User Gabezter4 has disconnected, reason: Internal server error
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:469) [craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.u(MinecraftServer.java:558) [craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.DedicatedServer.v(DedicatedServer.java:260) [craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.v(MinecraftServer.java:667) [craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.ServerConnection.c(SourceFile:134) [craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.NetworkManager.a(NetworkManager.java:157) ~[craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.PacketPlayInChat.handle(PacketPlayInChat.java:47) ~[craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.PacketPlayInChat.a(PacketPlayInChat.java:28) ~[craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.PlayerConnection.a(PlayerConnection.java:817) ~[craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at net.minecraft.server.v1_7_R3.PlayerConnection.handleCommand(PlayerConnection.java:961) ~[craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at java.util.logging.Logger.log(Unknown Source) ~[?:1.7.0_55]
    30.08 16:48:45 [Server] INFO at java.util.logging.Logger.doLog(Unknown Source) ~[?:1.7.0_55]
    30.08 16:48:45 [Server] INFO at java.util.logging.Logger.log(Unknown Source) ~[?:1.7.0_55]
    30.08 16:48:45 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.util.ForwardLogHandler.publish(ForwardLogHandler.java:33) ~[craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:609) [craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at org.apache.logging.log4j.core.Logger.log(Logger.java:110) [craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:367) [craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:406) ~[craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:425) ~[craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:101) ~[craftbukkit-dev.jar:git-Bukkit-1.7.9-R0.2-11-g3fd9db2-b3098jnks]
    30.08 16:48:45 [Server] INFO java.lang.NullPointerException
    
    
    Command Entered
    My onCommand Method:
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label,
    2. String[] args) {
    3. if (cmd.getName().equalsIgnoreCase("chestaccess")) {
    4. if (sender.hasPermission("ca.main")) {
    5. String name = args[0];
    6. if (args[0].equalsIgnoreCase("")) {
    7. userFile = new File(folder, sender.getName() + ".yml");
    8. userconfig = YamlConfiguration.loadConfiguration(userFile);
    9. if (userconfig.getConfigurationSection("Chests")
    10. .getKeys(false).size() == 0) {
    11. sender.sendMessage(ChatColor.GOLD
    12. + "You have 0 chests!!!");
    13. } else if (userconfig.getConfigurationSection("Chests")
    14. .getKeys(false).size() > 0) {
    15. sender.sendMessage(ChatColor.GOLD + "You have "
    16. + userconfig.getKeys(true).size() + "chests.");
    17. sender.sendMessage(ChatColor.GOLD + "You have "
    18. + userconfig.getKeys(false));
    19. }
    20. return true;
    21. }
    22.  
    23. else if (!(args[0].equalsIgnoreCase(""))) {
    24. if (userconfig.contains(name)) {
    25. Block chest = (Block) getChest(name);
    26. Inventory i = getChestInventory(chest);
    27. Player player = (Player) sender;
    28. player.openInventory(i);
    29. }
    30. return true;
    31. }
    32. }
    33. }
    34. return false;

    Note I have changed the code inside of the method to just send text when issued, and I received no errors. And I have had the return trues in side the brackets also and still received errors upon issuing.
     
  2. Offline

    Totom3

    Gabezter4 Stack traces most of the time actually do tell you where the error is. Check out this page to know how to find it. In your case we can't help you since you removed most of the important part, which consists of the error itself, and the first few lines after it...
     
  3. Offline

    Gabezter4

    Totom3 That is all I am getting in the way of my error.
     
  4. Offline

    Totom3

    Gabezter4 Did you check if userconfig.getConfigurationSection("Chests") is null ?
     
    Gabezter4 likes this.
  5. Offline

    Skionz

    Thats probably it, Gabezter4 do this before you check for a value.
    Code:
    if(userconfig.contains("Chests") {
     
    Gabezter4 likes this.
  6. Offline

    Totom3

    Skionz Gabezter4 And don't forget to close the condition with another ')'
     
    Gabezter4 and Skionz like this.
  7. Offline

    Gabezter4

    Totom3 Skionz Ok guys thanks I will try that when I get back to my laptop. Also when I was looking at the ConfigurationSection on the java docs. And I have Chests as a path, but not as a section. So that might be where I am going wrong. I will try what you guys said then try what I have found out, and get back to you.
     
  8. Offline

    Gabezter4

    Totom3 Skionz Hey guys I have found my null variable……… It is my userFile that returns null. But I don't get an error upon writing to the same path.

    Newer onCommand:
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label,
    2. String[] args) {
    3. if (cmd.getName().equalsIgnoreCase("chestaccess")) {
    4. if (sender.hasPermission("ca.main")) {
    5. String name = args[0];
    6. String playerName = sender.getName();
    7. if (args[0].equalsIgnoreCase("")) {
    8. sender.sendMessage(ChatColor.DARK_GREEN + "Command WIP");
    9. sender.sendMessage(ChatColor.DARK_GREEN
    10. + "Use /ca [Chest Name]");
    11. return true;
    12. }
    13. if (!(args[0].equalsIgnoreCase(""))) {
    14. userFile = new File(folder, playerName + ".yml");
    15. userconfig = YamlConfiguration.loadConfiguration(userFile);
    16. if (!(userFile == null)) {
    17. if (userconfig.contains(name)) {
    18. sender.sendMessage(ChatColor.DARK_GREEN + "Opening"
    19. + name);
    20. Block chest = (Block) getChest(name);
    21. Inventory i = getChestInventory(chest);
    22. Player player = (Player) sender;
    23. player.openInventory(i);
    24. return true;
    25. }
    26. sender.sendMessage(ChatColor.RED + userFile.getPath());
    27. return true;
    28. }
    29. }
    30. }
    31. }
    32. return false;
    33. }
     
  9. Offline

    Necrodoom

    Gabezter4 if the args length is 0, this would produce an array out of bounds exception, not empty string. You should also learn how to use else.
     
  10. Offline

    Gabezter4

    Necrodoom Ok thanks. I will try that to see if my problem is that.
     
Thread Status:
Not open for further replies.

Share This Page