[UNSOLVED]Need Some Config Help

Discussion in 'Plugin Development' started by leimekiller, Oct 4, 2013.

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

    leimekiller

    Hello, I am trying to make a kits plugin and store their kits in the config, but how would I do something like this:

    Code:
    PlayerName:
        Kit
        Kit
        Kit
    Thanks in advance!
     
  2. Offline

    __ImTheMoney__

    huh can u be more clear ike give us part of the code etc​
     
  3. Offline

    leimekiller

    __ImTheMoney__ Why should you need a part of my code in this question?
     
  4. Offline

    jimuskin

    so you basically want to store player kits into a config and check if they have the kit in a config?
     
  5. Offline

    3ptO

  6. Offline

    leimekiller

  7. Offline

    3ptO

    leimekiller I'd imagine something along the lines getConfig().set(player, kit)
     
    jimuskin likes this.
  8. Offline

    leimekiller

    3ptO How would that do something like:
    PlayerName
    - Kit
    - Kit2
    - Kit3
     
  9. Offline

    jimuskin

    leimekiller I would assume you need to add the class into an arraylist and then add all the classes into the config through that.
     
    3ptO likes this.
  10. Offline

    3ptO

    leimekiller Because that is exactly what it does?

    getConfig().set("PlayerName", Kit);

    I won't feed you the code, the above will work assuming you know how to create a list.
     
  11. Offline

    leimekiller

    3ptO No that just sets the line to the kit so this does:

    player: kit

    And when you buy kit1 it does:

    player: kit1
     
  12. Offline

    Ultimate_n00b

    We won't hand feed you code.

    Go out and look at kit plugins and see how they do it. It's very simple to do.
     
  13. Offline

    jimuskin

    Try something like this.
    NOTE: untested but should work.

    Code:java
    1. public Map<String, ArrayList<String>> classes = new HashMap<String, ArrayList<String>>();
    2.  
    3. public boolean oncommand(CommandSender sender, Command cmd, String label, String args[]){
    4. if(label.equalsIgnoreCase("addkit")){
    5. Player player = (Player) sender;
    6. String playerName = player.getName();
    7. if(args.length == 1){
    8. if(args.equals("kit1")){
    9. addClass(player, args[0]);
    10. }
    11. }
    12. }
    13. return false;
    14. }
    15.  
    16. public void addClass(Player player, String args){
    17. String playerName = player.getName();
    18. ArrayList<String> classes1 = this.classes.get(playerName);
    19. classes1.add(args);
    20. classes.put(playerName, classes1);
    21. plugin.getConfig().set("kits", classes);
    22. }
     
  14. Offline

    3ptO

Thread Status:
Not open for further replies.

Share This Page