Teams - Setting a players rank

Discussion in 'Spigot Plugin Development' started by GeppiOMG, May 28, 2016.

  1. Hey, guys, I have come across an issue that I have talked with multiple devs about and still can't seem to get an answer. Heres the Issue:

    <KEY>
    Player1 is leader of the team
    Player2 is member of the team
    <KEY>

    if Player1 did "/team setrank Player2 General" -- in the config, it would set there rank as general. HOWEVER, it will keep them as a Member of the team as well :(

    What it should do: if I did "/team setrank <player> General" in the config they should just be General and if I did "/team setrank <player> Member" In the config they should be set as just Member Rank

    SetRank:
    Code (Text):
    public void setRank(Rank rank) {
        this.rank = rank;

        List<String> members = team.getTeams().getConfig().getStringList("team." + team.getName() + ".members");

        members.remove(getRank().name() + " " + kills + " " + deaths + " " + uniqueId.toString());
        members.add(rank.name() +  " " + kills + " " + deaths + " " + uniqueId.toString());

        team.getTeams().getConfig().set("team." + team.getName() + ".members", members);

        team.getTeams().save();
        save();
    }
    Config <WITHOUT SETTING A PLAYERS RANK>:
    Code (Text):
    messages:
      prefix: '&c[&6Teams&c] &7'
    team:
      hi:
        creation-time: May 28, 2016
        max: 5
        coins: 0
        members:
        - LEADER 0 0 a34eeabf-1b65-4c45-89fd-cbb065e2bf5d
        - MEMBER 0 0 f19ac4c6-9a67-494d-a34c-a0c68b1bc8c2
     
    Config <AFTER SETTING THE PLAYERS RANK TO GENERAL>
    Code (Text):
    messages:
      prefix: '&c[&6Teams&c] &7'
    team:
      hi:
        creation-time: May 28, 2016
        max: 5
        coins: 0
        members:
        - LEADER 0 0 a34eeabf-1b65-4c45-89fd-cbb065e2bf5d
        - MEMBER 0 0 f19ac4c6-9a67-494d-a34c-a0c68b1bc8c2
        - GENERAL 0 0 f19ac4c6-9a67-494d-a34c-a0c68b1bc8c2
     
    As you can see It adds them as a General but keeps them as a Member.
    But if they are a General and I try to set them as a Member it will keep them as General. The issue is with Removing the last players rank.

    If you could reply with a smarter way to do this or you know what the cause is, please comment down below!

    Thanks,

    Tom
     
  2. Well it looks like your setting the new rank before remove the old try changing your code to
    Code (Text):
    public void setRank(Rank rank) {
        List<String> members = team.getTeams().getConfig().getStringList("team." + team.getName() + ".members");

        members.remove(getRank().name() + " " + kills + " " + deaths + " " + uniqueId.toString());
    this.rank = rank;
        members.add(rank.name() +  " " + kills + " " + deaths + " " + uniqueId.toString());

        team.getTeams().getConfig().set("team." + team.getName() + ".members", members);

        team.getTeams().save();
        save();
    }
    Keep in mind I can't see the rest of your code so this is only a guess.
     
    • Like Like x 1
  3. Do you have a skype?
     
  4. You should keep it all in this thread, or on the forums.
    When done, please show your solution to the few or many who are experiencing the same problem.
     
  5. spoonfed isn't allowed in spigot.
    Now how about giving you the whole plate ?