Config files doesn't updates

Discussion in 'Plugin Development' started by Calamandrey, Jul 18, 2020.

Thread Status:
Not open for further replies.
  1. I'm developing a prison ranks plugin, so I made that the plugin create 3 config files. One for the config and the ranks list file, one to keep the rank of each player and the last for keep the tracks list. When I perform the command "rankup" in the config file of players data the player rank updates itself, but when i perform for the second time the command "rankup" plugin rank up me to the same rank. For example:
    Default track:
    1: Default
    2:Second
    3:Third

    Player Ranks:
    player: Default

    after performing command "rankup":

    Player Ranks:
    player: Second

    after performing command "rankup" for second time:

    Player Ranks:
    player: Second

    after performing command "rankup" and after reloading the plugin:

    Player Ranks:
    player: Third

    How can i solve this problem?
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. else if (cmd.getName().equalsIgnoreCase("rankup")) {
    UUID SenderID = (Bukkit.getServer().getPlayerExact(sender.getName())).getUniqueId();
    try {
    conf.load(config);
    track.load(Tracks);
    pdata.load(PlayerData);
    } catch (FileNotFoundException e1) {
    e1.printStackTrace();
    } catch (IOException e1) {
    e1.printStackTrace();
    } catch (InvalidConfigurationException e1) {
    e1.printStackTrace();
    }
    String Rank = Main.getPlayersData().getString("Players."+SenderID);
    String PlayerName = sender.getName();
    double balance;
    World Null = null;
    if(args.length == 0) {

    if (RankupwithoutspecifyTrack = true) {

    String DefaultTrack = Main.getConf().getString("Settings.DefaultTrack");
    int posintrack = Main.getConf().getInt("Rankslist."+Rank+".positionintrack"+DefaultTrack);
    int rankuprank = posintrack + 1;
    String NewRank = Main.getTracksConf().getString("Tracks."+DefaultTrack+"."+rankuprank);
    double Cost = Main.getConf().getDouble("Rankslist."+NewRank+".cost");
    String rankPermNode = "PrisonRanks.rank."+NewRank;
    if(Main.getTracksConf().getString("Tracks."+DefaultTrack+"."+rankuprank) != null) {
    if((econ.getBalance(PlayerName) - Cost)>= 0) {

    pdata.set("Players."+SenderID, NewRank);
    try {
    pdata.save(PlayerData);
    } catch (IOException e) {
    e.printStackTrace();
    }
    econ.withdrawPlayer(PlayerName, Cost);


    perms.playerAdd(Null, sender.getName(), rankPermNode);
    sender.sendMessage("§aYou ranked up to "+NewRank+"!");
    return false;
    }else {
    sender.sendMessage("§cYou don't have enough money!");
    return false;

    }
    }else {

    sender.sendMessage("§cYou reached the end of the track!");
    return false;
    }
    }else {
    sender.sendMessage("§cSorry you have to specify track!");
    return false;

    }
    }
     
  4. Offline

    timtower Administrator Administrator Moderator

    @Calamandrey Why are you not keeping it in the cache? You keep loading and saving the files.
     
  5. How i make that the plugin keep that in the cache?
     
  6. Offline

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page