[trunk] Help: first test for help_username.txt, then help_groupname.txt and then help.txt, to allow help files for seperate groups and users.

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1376 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
snowleo 2011-05-08 22:37:38 +00:00
parent fb82943f29
commit 02a9909e8b

View file

@ -12,8 +12,8 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
public class Commandhelp extends EssentialsCommand
@ -59,10 +59,18 @@ public class Commandhelp extends EssentialsCommand
private List<String> getHelpLines(User user) throws Exception
{
List<String> retval = new ArrayList<String>();
File file = new File(ess.getDataFolder(), "help.txt");
if (file.exists())
File helpFile = new File(ess.getDataFolder(), "help_"+Util.sanitizeFileName(user.getName()) +".txt");
if (!helpFile.exists())
{
BufferedReader rx = new BufferedReader(new FileReader(file));
helpFile = new File(ess.getDataFolder(), "help_"+Util.sanitizeFileName(user.getGroup()) +".txt");
}
if (!helpFile.exists())
{
helpFile = new File(ess.getDataFolder(), "help.txt");
}
if (helpFile.exists())
{
BufferedReader rx = new BufferedReader(new FileReader(helpFile));
for (String l = null; rx.ready() && (l = rx.readLine()) != null;)
{
retval.add(l.replace('&', '§'));