Solved Updating Configuration

Discussion in 'Plugin Development' started by MineStein, Aug 17, 2014.

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

    MineStein

    Hey guys! I have recently finished the first version of my Survival Games plugin. I am now implementing some cool features. One of them is a built-in currency saved via a configuration file. I have gotten the whole purchasing thing figured out, but it doesn't reload itself.

    Here is what I have written so far:
    Code:java
    1. if (event.getCurrentItem().getType()==Material.ROTTEN_FLESH) {
    2. if (Core.plugin.getConfig().getInt("stats." + player.getName() + ".points") >= 50) {
    3. player.sendMessage(Core.PREFIX + "§6You purchased a §eMutation Pass§6!");
    4. Core.plugin.getConfig().set("stats." + player.getName() + ".points", Core.plugin.getConfig().getInt("stats." + player.getName() + ".points") - 50);
    5. return;
    6. } else {
    7. player.sendMessage(Core.PREFIX + "§4You don't have enough Novites §8(§c" + Core.plugin.getConfig().getInt("stats." + player.getName() + ".points") + "§8)");
    8. }
    9. }


    The reloadConfig method causes a problem. The problem being you can purchase the mutation pass an unlimited amount of times.

    Any help is greatly appreciated! Thanks :)
     
  2. Offline

    Dinosaurs

    Remember to save the config after editing it.
     
  3. Offline

    Garris0n

    Then stop using it...
     
  4. Offline

    MineStein

    Dinosaurs I'll test it.

    Garris0n I did

    MineStein M'kay, thanks :) It worked.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page