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: PHP: motd-one=motd-two=motd-three=motd-four=motd-five= Then it would hook into permissions and use the nodes motd.one through motd.five to decide which rank gets what motd. Can anyone help me? Heres my main class: Code: 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; import org.bukkit.plugin.java.JavaPlugin; public class MOTDAdvanced extends JavaPlugin{ public static MOTDAdvanced instance; private final MOTDAdvancedPlayerListener playerListener = new MOTDAdvancedPlayerListener(); PluginDescriptionFile pdfFile; @Override 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!"); } @Override public void onDisable() { System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is disabled!"); }} Here's my listener: Code: 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{ @Override public void onPlayerJoin(PlayerEvent event) { Player player = event.getPlayer(); player.sendMessage("WELCOME TO AN AWESOME SERVER!!!"); } } And my plugin.yml reads like this: Code: name: MOTDAdvanced main: ca.ziddia.motd.MOTDAdvanced version: 0.1
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.
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
Reader : Code: BufferedReader in = new BufferedReader(new FileReader("plugins/MOTD/config.cfg")); System.out.println("First line: " + in.readLine()); System.out.println("Second line: " + in.readLine()); FileReader Writer : Code: BufferedWriter out = new BufferedWriter(new FileWriter("plugin/MOTD/config.cfg")); out.write("motd-one=", 0, 9); out.newLine(); out.write("motd-two=", 0, 9); FileWriter Edit : Fixed typo errors
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
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();
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.
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.