mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
Add support for info_username.txt and info_groupname.txt.
Fix color in chapter names. Use &[0-9a-f] as color codes. git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1412 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
300f9c33cc
commit
bcd4ed0fdb
1 changed files with 19 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.Util;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
@ -9,6 +11,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public class Commandinfo extends EssentialsCommand
|
public class Commandinfo extends EssentialsCommand
|
||||||
|
@ -26,7 +29,20 @@ public class Commandinfo extends EssentialsCommand
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<String>();
|
||||||
List<String> chapters = new ArrayList<String>();
|
List<String> chapters = new ArrayList<String>();
|
||||||
Map<String, Integer> bookmarks = new HashMap<String, Integer>();
|
Map<String, Integer> bookmarks = new HashMap<String, Integer>();
|
||||||
File file = new File(ess.getDataFolder(), "info.txt");
|
File file = null;
|
||||||
|
if (sender instanceof Player)
|
||||||
|
{
|
||||||
|
User user = ess.getUser(sender);
|
||||||
|
file = new File(ess.getDataFolder(), "info_"+Util.sanitizeFileName(user.getName()) +".txt");
|
||||||
|
if (!file.exists())
|
||||||
|
{
|
||||||
|
file = new File(ess.getDataFolder(), "info_"+Util.sanitizeFileName(user.getGroup()) +".txt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file == null || !file.exists())
|
||||||
|
{
|
||||||
|
file = new File(ess.getDataFolder(), "info.txt");
|
||||||
|
}
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
{
|
{
|
||||||
BufferedReader rx = new BufferedReader(new FileReader(file));
|
BufferedReader rx = new BufferedReader(new FileReader(file));
|
||||||
|
@ -35,8 +51,8 @@ public class Commandinfo extends EssentialsCommand
|
||||||
{
|
{
|
||||||
if (l.startsWith("#"))
|
if (l.startsWith("#"))
|
||||||
{
|
{
|
||||||
bookmarks.put(l.substring(1).toLowerCase(), i);
|
bookmarks.put(l.substring(1).toLowerCase().replaceAll("&[0-9a-f]", ""), i);
|
||||||
chapters.add(l.substring(1));
|
chapters.add(l.substring(1).replace('&', '§'));
|
||||||
}
|
}
|
||||||
lines.add(l.replace('&', '§'));
|
lines.add(l.replace('&', '§'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue