Reload Config & Command Errors

Discussion in 'Plugin Development' started by Pink__Slime, Jun 1, 2013.

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

    Pink__Slime

    So just to make this easier to read, I'll put the two different problems in their own spoiler.

    Reload Config:
    Show Spoiler
    So basically, I need a way to reload the config. I have looked around a LOT and can't seem to find a way that will actually work for me.


    Command Errors:
    Show Spoiler
    So I'm getting this error: http://pastebin.com/9PgJsdwk
    I'm not sure what exactly it means... My source is at https://github.com/Spedwards/SKits (src.com.theaetherserver.kits.ConfigCmds.java)


    I should have mentioned, my config is at https://github.com/Spedwards/SKits/...heaetherserver/kits/configuration/Config.java

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  2. This is how to reload your config I think.
    Code:
    this.reloadConfig();
     
  3. Offline

    Pink__Slime

    InspectorFacepalm
    Tried that. I'm not using the default bukkit configuration by the way.
     
  4. Ahh, I'll try to check something then.
     
  5. Offline

    UnlikeAny

    Pink__Slime
    Regarding commands error.

    You are getting ArrayIndexOutOfBoundsException.
    Code:
    01.06 23:05:59 [Server] INFO Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    01.06 23:05:59 [Server] INFO at com.theaetherserver.kits.ConfigCmds.onCommand(ConfigCmds.java:24)
    At ConfigCmds you are trying to use args[1] without having one.
     
  6. Offline

    Pink__Slime

    UnlikeAny
    I only use "/slimekits config" and this happens... If you could please look at the code, I'm not trying to use args[1].
     
  7. Offline

    themadman300

    Bukkit starts at args[0] so /foo bar the foo is the command and bar is args[0] and say we add pie onto the end that would be args[1]

    That's how the args thing works.
     
    Pink__Slime likes this.
  8. Offline

    UnlikeAny

    themadman300
    What the hell are you talking about? Did you even look at the code?

    Pink__Slime
    You are trying to use args[1] in the code, not by typing a command.

    Line 24 at com.theaetherserver.kits.ConfigCmds.
    Code:
    if(args[1].equalsIgnoreCase("set"))
    throws an exception, because args[1] doesn't exist when you only type "/slimekits config".

    Hint: Check if index in array is not out of bounds, before using it in the array.
     
  9. Offline

    Pink__Slime

    UnlikeAny
    More like what the hell are you talking about?

    Notice how it says "if"...

    If you went all the way down I added an "}else{"

    Maybe you should re-look at the code and not be rude.
     
  10. Offline

    UnlikeAny

    I'm not trying to be rude, I'm trying to help you and it seems that you are not listening. Sorry, but I don't want to waste any more of my time. If you are asking for help, you should at least try to do what you are suggested.

    Even if you don't believe me, how can you not believe a stack trace? It shows the exact same problem, that I explained. You can just Google the exception yourself and not just sit waiting to be spoon fed.

    P.S. If you don't know how to read a stack trace there is sticky thread for that.
     
  11. Offline

    Pink__Slime

    UnlikeAny
    I wasn't being rude even though it might of been portrayed that way.

    I don't believe you because you were wrong. Stack trace doesn't prove anything you said.

    I know how to read a stack trace thanks.


    I'm here asking for help because I've tried everything else.
     
  12. Offline

    davejavu

    Pink__Slime - the reason you're getting the ArrrayIndexOutOfBoundsException is because args doesn't contain args[1], which throws the exception. The way to avoid this is to add a simple check to check whether the sender actually sent the correct amount of arguments, so if the String[] args contains enough values, basically.
    Code:java
    1. if (args.length > 1) {
    2. if (args[1].equalsIgnoreCase("...")) {
    3.  
    4. } else if (..) {
    5.  
    6. }
    7. //And so on.
    8. }
    9.  

    But yes, Pink you should really learn how to read stack traces properly, because (and this isn't an attack on you whatsoever, it's advice) if you could, you wouldn't be posting here.
     
    UnlikeAny likes this.
  13. Offline

    UnlikeAny

    Pink__Slime

    Can you please explain why you think that I'm wrong?

    Here is my proof, if you don't believe me:

    Your exception
    Code:
    01.06 23:05:59 [Server] INFO Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
    01.06 23:05:59 [Server] INFO at com.theaetherserver.kits.ConfigCmds.onCommand(ConfigCmds.java:24)
    Explanation for this exception in java documentation.

    args[1]throws exception, because you only write "/slimekits config", so args.length < 1. The only "explanation" of yours is that you use if (), and it doesn't make any sense, because it still has to access args[1].

    EDIT: davejavu , I was trying to explain him the same with hints, so he would figure a solution himself. But when it comes to this, your way is a lot better :D.
     
    davejavu likes this.
  14. Offline

    davejavu

    UnlikeAny Lol, I've been helping here for over a year now, from the start of the post you can tell who will get the hints and who won't listen and requires the 'straight up' option :)

    Just so anyone who reads this who I've helped; I'm not starting an argument here - if you want to hate on my methods, PM me.
     
    UnlikeAny likes this.
Thread Status:
Not open for further replies.

Share This Page