Why im getting error in this code ?

Discussion in 'Plugin Development' started by CrossBowerMan, Aug 22, 2015.

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

    CrossBowerMan

    I'm creating a mini hunger games plugin but
    I get an error when creating the arena


    ----------------------------------------
    CODE:
    Code:
                if (args.length == 2 && args[0].equalsIgnoreCase("yarat")){
                    saveConfig();
                    getConfig().set("Arenas.", args[1]);
                    saveConfig();
                    sender.sendMessage(prefix + ChatColor.GOLD + args[1] +ChatColor.DARK_GRAY +  "The Arena Has Been Added!");
                    return true;
                }
     
    Last edited by a moderator: Aug 23, 2015
  2. Offline

    xMrPoi

    What is your error?
     
  3. Offline

    CrossBowerMan

    Eror is arena does not creating
     
  4. @CrossBowerMan
    My guess would be that "Arenas." is an invalid path, and therefor it might throw an error. But YAML may have an auto-fix for it, but I'm not sure. Also, why are you saving the config twice? I recommend only calling saveConfig() in onDisable(), because each time you call saveConfig() it opens a new file stream which is not very efficient.
     
    Last edited: Aug 23, 2015
    Shortninja66 likes this.
  5. Offline

    CARR0T

    Is there a stacktrace?
     
  6. @CrossBowerMan Why do you save, set, save? Why not just set and save?
     
    au2001, SkyleTyler1337 and mine-care like this.
  7. But if the server crashes everything is gone..
     
  8. @FisheyLP
    The server shouldn't crash as long as you don't make silly mistakes or create a lag machine.
     
  9. Offline

    xMrPoi

    @megamichiel
    That's a somewhat bad way to handle saving things in the config lol. Unless you're saving something like every second, it won't be too big of a toll on the server. Also, you should always expect the unexpected. Although it's not likely, servers will still randomly crash due to multiple reasons.
     
Thread Status:
Not open for further replies.

Share This Page