summaryrefslogtreecommitdiffstats
path: root/EssentialsUpdate/src/com/earth2me/essentials/update/chat/ConfigCommand.java
blob: de2c6a8308c81100cf4684d037e98f49a70ed499 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package com.earth2me.essentials.update.chat;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;


public class ConfigCommand extends AbstractFileCommand implements Command
{
	public ConfigCommand(final Plugin plugin)
	{
		super(plugin);
	}

	@Override
	public void run(final IrcBot ircBot, final Player player)
	{
		BufferedReader page = null;
		try
		{
			page = getPluginConfig("Essentials", "config.yml");
			final StringBuilder input = new StringBuilder();
			do
			{
				final String line = page.readLine();
				if (line == null)
				{
					break;
				}
				else
				{
					input.append(line).append("\n");
				}
			}
			while (true);
			page.close();
			final String message = "Essentials config.yml: " + uploadToPastie(input);
			player.sendMessage("§6" + ircBot.getNick() + ": §7" + message);
			ircBot.sendMessage(message);
		}
		catch (IOException ex)
		{
			Bukkit.getLogger().log(Level.SEVERE, null, ex);
			player.sendMessage(ex.getMessage());
		}
		finally
		{
			try
			{
				if (page != null)
				{
					page.close();
				}
			}
			catch (IOException ex)
			{
				Bukkit.getLogger().log(Level.SEVERE, null, ex);
				player.sendMessage(ex.getMessage());
			}
		}

	}
}