config names

Discussion in 'Plugin Development' started by Juancomaster1998, Nov 28, 2014.

Thread Status:
Not open for further replies.
  1. how to name a .yml like arena(args[2]) ?
    I have the settingsManager and the commands on different clases, it`s possible to obtain a value (like args) from 1 class and use them on another one? how?
     
  2. Offline

    Skionz

  3. Thanks!

    how to get the args[2] on the constructor?
    I dont know what method call.
    Code:java
    1. Public String ?????? {
    2. return args[2];
    3. }


    How to get the args of a command on a constructor?

    <Edit by mrCookieSlime: Merged posts. Please do not triple post. There is an Edit-Button right next to the Date.>
     
  4. Offline

    Skionz

  5. I want to create a file for each arena, but the file should have the name given in the command
    / bc admin create (arena)
    I want that (arena) to be the filename
     
  6. Juancomaster1998
    Pass the string (args[2]) to the class through its constructor. Like this
    Code:
    public Arena(String name) {
    // something
    }
    then in your command, when you create a new instance of the Arena class, put args[2] in the constructor.
     
  7. Offline

    ChipDev

    You mean create a file with the arena name.?
     
  8. yes

    Code:java
    1. package me.Juanco.bombercraft;
    2.  
    3. import java.io.File;
    4.  
    5. import org.bukkit.configuration.file.FileConfiguration;
    6. import org.bukkit.plugin.Plugin;
    7.  
    8. public class Config {
    9.  
    10. private Config() { }
    11.  
    12. static Config instance = new Config();
    13.  
    14. public static Config getInstance() {
    15. return instance;
    16. }
    17.  
    18. Plugin p;
    19.  
    20. FileConfiguration arenas;
    21. static File afile;
    22.  
    23. public static boolean onCommand(String arg2, Plugin p) {
    24. afile = new File(p.getDataFolder().getAbsolutePath(), "/arenas/" + "arena" + arg2 );
    25.  
    26. if (!p.getDataFolder().exists()) {
    27. p.getDataFolder().mkdir();
    28. }
    29.  
    30. return true;
    31. }
    32.  
    33.  
    34. }
    35.  


    [​IMG]
    Why it creates an config.yml instead of "/arenas/" + "arena" + arg2 ?

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

Share This Page