From 02a9909e8be18d50354d7d9ed9683d0e800f2daf Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 8 May 2011 22:37:38 +0000 Subject: [PATCH] [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 --- .../essentials/commands/Commandhelp.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index 8bd4d6a5e..c992eda19 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -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 getHelpLines(User user) throws Exception { List retval = new ArrayList(); - 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('&', 'ยง'));