Help for me

Discussion in 'Plugin Development' started by Ziddia, Mar 17, 2011.

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


    So. I started making a plugin about two or three days ago- my first one!- and it's now finished, as a basic MOTD plugin. However, that's not everything I want it to do. I want it to create a configuration file that reads like this:
    Then it would hook into permissions and use the nodes through motd.five to decide which rank gets what motd.

    Can anyone help me?

    Heres my main class:
    package ca.ziddia.motd;
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    public class MOTDAdvanced extends JavaPlugin{
     public static MOTDAdvanced instance;
     private final MOTDAdvancedPlayerListener playerListener = new MOTDAdvancedPlayerListener();
    PluginDescriptionFile pdfFile;
     public void onEnable() {
         pdfFile = this.getDescription();
          PluginManager pm = getServer().getPluginManager();
          pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
          System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
     public void onDisable() {
         System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is disabled!");
    Here's my listener:
    package ca.ziddia.motd;
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.event.player.PlayerEvent;
    public class MOTDAdvancedPlayerListener extends PlayerListener{
        public void onPlayerJoin(PlayerEvent event) {
            Player player = event.getPlayer();
            player.sendMessage("WELCOME TO AN AWESOME SERVER!!!");
    And my plugin.yml reads like this:
    name: MOTDAdvanced
    main: ca.ziddia.motd.MOTDAdvanced
    version: 0.1
  2. Where specifically do you need help ?
  3. Offline


    Firstly, tO make the plugin generate the aforementioned config file, so the admin can change what each message is.

    Second, to add permissions hooks and permissions nodes.

    Eg on the generated configuration file I make it

    Motd-three= you are an admin!

    Then I give my admin rank the permissions node motd.three

    And upon an admins login, it displays that message.
  4. Offline


    Ok. What in specific do I do with the read and write? Where do i put it? I'm not familiar with this piece of java/bukkit
  5. Reader :
    BufferedReader in    = new BufferedReader(new FileReader("plugins/MOTD/config.cfg"));
    System.out.println("First line: " + in.readLine());
     System.out.println("Second line: " + in.readLine());

    Writer :
    BufferedWriter out = new BufferedWriter(new FileWriter("plugin/MOTD/config.cfg"));
    out.write("motd-one=", 0, 9);
    out.write("motd-two=", 0, 9);

    Edit : Fixed typo errors
  6. Offline


    Thanks. This goes in the main class?
  7. This goes wherever you need to write or read into a text file. I'm not going to write the plugin for you btw, so try to think about this before copy/pasting them stupidly ;)
  8. Offline


    Ok then

    Thanks for the help
  9. You're welcome.
  10. Offline


    Okay... I've done the imports for permissions, and the bit which declares it as a variable, but I can't see where in my onEnable I should put the setupPermissions();
  11. Wherever it's better for you. Sometimes it doesn't matter, depends of your plugin. The best in your case, should be to setupPermissions before you register events or make your command processor.
  12. Offline


    It comes up with an error in Eclipse that it is undefined for the type MOTDAdvanced. Is something else meant to come after that? Am i meant to register an event? I wouldn't have thought so but yeah, it seems something has gone wrong with it.

    It has an option for quick fix to create the method, should I do that?

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

Share This Page