New Plugin Dev Looking for Chat help

Discussion in 'Plugin Development' started by Aclimator, Feb 23, 2011.

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

    Aclimator

    So basically, I want to make it so that a player will type something.

    For instance:

    /a Hello World

    And "Hello World" will only be sent to a certain group of players who are in the same group as the player sending the message. I've seen this done in faction plugins etc, and I would like to know how it is done.

    So I need to create a group of players, which will be stored in a .txt and make sure that the message only goes to the players who are in the each others group.
    I know that there are probably plugins out there that do this, but I would really like to make one of my own, and I have heard this is the place to ask for help. I am new to Java, been learning for about a month, and any help at all would be really appreciated.

    Thanks. :D
     
  2. Offline

    Edward Hand

    I believe bukkit has built in .yml support, which is what everyone else uses for config files, so that would be better than .txt files if you can work out how to use them. (I haven't tried it myself so maybe someone else can give you some pointers on that)

    If you're just getting started making plugins, its a good idea to start by looking at other peoples source code and getting a feel for how they fit together. Learning how to make a plugin from examples is the easiest and quickest way to learn.

    A word of advice: your post is somewhat vague... People are far more likely to respond to your post if you ask specific questions rather than just "How do I make this plugin?". I'd suggest having a go making it yourself and coming back when you start encountering problems.
     
  3. Offline

    Nohup

    Bukkit provides a nice Configuration object that you can use, and you can build your configuration tool on the fly if needed. For example, in my first plugin that I put together to play with I had this code:

    Code:
        protected void buildConfiguration()
        {
            Configuration c = getConfiguration();
            c.setProperty("propertyA", true);
            c.setProperty("propertyB", true);
    
            if (!getConfiguration().save())
            {
                getServer().getLogger().warning("Unable to persist configuration files, changes will not be saved.");
            }
        }
    
    I had a test around it that checked for the existing configuration file first, and if it didn't exist it would create it on the fly.

    Now, as far as structure of the properties goes, I suggest reading up on YAML (snakeyaml is what Bukkit is using) and also looking at the classes in the source under the org.bukkit.util.config package. The setProperty method accounts for dot-notation for determining groupings and what not so you can see that in the parsing.

    As far as the raw YML, I believe you would be after something similar to how plugin authors are listed in the plugin.yml:

    authors:
    - Nohup
    - Other Person

    The YAML Wikipedia Page is very helpful as well
     
Thread Status:
Not open for further replies.

Share This Page