Use text files not Yaml files.

Discussion in 'Plugin Development' started by Hello Minecraft World, Jan 15, 2012.

Thread Status:
Not open for further replies.
  1. My plugin uses a config.yml file with this in it:
    Code:YAML
    1. MOTD: Someshit
    2. Use Permissions: true

    but i want the MOTD: to be in a MOTD.txt file how can i do this easy?
     
  2. Offline

    randomman159

  3. mayby something like:
    Code:
    		ArrayList<String> motd = new ArrayList<String>();
    		RandomAccessFile file = null;
    		try
    		{
    			file = new RandomAccessFile(new File("motd.txt"), "r");
    			try
    			{
    				String line;
    				while ((line = file.readLine()) != null)
    				{
    					motd.add(line);
    				}
    			}
    			catch (EOFException discard)
    			{
    			}
    		}
    		catch (IOException ex)
    		{
    			motd.add("Unable to read the motd.txt, thats why you see this motd.");
    			log.log(Level.SEVERE, "Error", ex);
    		}
    		finally
    		{
    			if (file != null)
    			{
    				try
    				{
    					file.close();
    				}
    				catch (IOException ex)
    				{
    					log.log(Level.SEVERE, "Error", ex);
    				}
    			}
    		}
    
     
  4. Didn't work and if i need atleast that much code I'll wait sometime before i release that
     
  5. Offline

    tommykins20

    Easily done by BufferedReader, FileWriter, PrintWriter and an ArrayList and obviously your main File variablewhich is the motd.txt. I'm on a mobile device, but if you need help. Add me on skype or msn..
    Skype: tommykins20
    MSN: [email protected]
     
  6. the file motd.txt was't existing at the server root?
     
  7. Offline

    tommykins20

    Yes, you don't actually need PrintWriter or FileWriter, I was on the move in the car with a mobile device and was hard to think lol
     
Thread Status:
Not open for further replies.

Share This Page