Solved Naming object

Discussion in 'Plugin Help/Development/Requests' started by 0verFull, Apr 7, 2015.

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

    0verFull

    Hi everyone,

    In my plugin, I want to create a new object (with a defined constructor in another class) but I want this object take the name of the first args of the command
    The probleme is with the "args[0]"

    code :


    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){

    // Player p = (Player) sender;

    if(cmd.getName().equalsIgnoreCase("cgcreate")){

    ChatGroupPluginGroup args[0] = new ChatGroupPluginGroup(ChatColor.valueOf(args[1]), new ArrayList<Player>(), args[2]);
    return true;
    }
    return false;
    }
     
  2. You can't set the variable name to a variable. Why do you even want to do this?
     
  3. Offline

    cnc4

    @0verFull
    Dont know what you are trying to do but maybe you can use HahMap? or something like that...
     
  4. Offline

    nverdier

    What does that have to do with anything?
     
  5. Offline

    cnc4

    @nverdier

    dont know what he is trying to do,I Just suggested it maybe it will help him maybe not. you dont have to jump every time u see something that you dont think its relevant/related...
     
  6. Offline

    0verFull

    If You want, I want to create a plugin that when a Player use the command /cgcreate , it created a chat group in game. I create the group with my constructor ChatGroupPluginGroup
     
  7. Offline

    cnc4

    @0verFull

    So you want to store all the player the belong to a chat group by name? you can use config to store chat groups
    for example:
    Code:
    ArrayList <String>  chatGroupList=new ArrayList<String>();
    //add your players by:
    chatGroupList.add(p.getUniqueId().toString());
    getConfig().set("ChatGroupPluginGroup." +args[0],chatGroupList); //args[0]: your name i guess...
    saveConfig();
    
     
  8. Offline

    0verFull

Thread Status:
Not open for further replies.

Share This Page