Config Help

Discussion in 'Plugin Development' started by Epicballzy, Apr 24, 2014.

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

    Epicballzy

    I'm working on configurable messages.. But I'm not sure how to get variables such as (%AMOUNT = acount taken) or something... I've already got the stuff all setup, but I'm just not sure how to make the variables.

    Code:java
    1. public static void buyKit(Player p, int i) {
    2. Main.config.set(p.getName() + ".Coins", Main.config.getInt(p.getName() + ".Coins", 0) - i);
    3. Main.saveFile();
    4. p.sendMessage("§b§l► " + ChatColor.translateAlternateColorCodes("&".charAt(0), Main.messageConf.getString("butKit").replaceAll("%AMOUNT", i)));
    5. }


    I want "i" to be the variable for the amount. Any help..? :) If you need more info, just ask and I'll post it.
     
  2. Offline

    CraftCreeper6

  3. Offline

    Epicballzy

    Ok, so I have a set of things like giveCoins(), takeCoins(), buyKit().... and I'd like to make the messages configurable. But I'm not sure how to make the variables.. like %AMOUNT will equal to the amount typed in the command.
    Example
    Code:
    Config:
    buyKit: 'You bought Mage for %AMOUNT coins!'
     
    Message sent to player:
    You bought Mage for 25 coins!
     
  4. Offline

    CraftCreeper6

    Epicballzy
    So you want to set %AMOUNT to a specific int?
    I will do some research (try) and try get you a link to a thread of Bukkit API

    Epicballzy
    I cannot find a thing but I would take a guess and say:

    Check if the config message contains %AMOUNT
    If it does set %AMOUNT to __
    Done! Put this in the onCommand :)

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

    Epicballzy

    Hmmm... It's going to be tough cause I'm not the neatest coder. Lol, but I'll do my best :) Thanks for the help though. Very much appreciated!
     
  6. Offline

    CraftCreeper6

    Epicballzy
    No problem!
    If it does not work then just put CraftCreeper6 in your message and ill be there as soon as I can get here!
     
  7. Offline

    BillyBobJoe168

    just do Main.getConfig().set("buyKit", "You bought a kit for " + args[0] + " dollars!"); where args[0] is an int. obviously, you would want to check if args[0] is an int firstXD
     
Thread Status:
Not open for further replies.

Share This Page