mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-24 11:54:35 +08:00
Add support for multiple bookmarks/chapter names
Clean up info file handling
This commit is contained in:
parent
3ccefb49c0
commit
a29e1bfe51
@ -6,9 +6,12 @@ import java.util.Map;
|
||||
|
||||
public interface IText
|
||||
{
|
||||
// Contains the raw text lines
|
||||
List<String> getLines();
|
||||
|
||||
// Chapters contain the names that are displayed automatically if the file doesn't contain a introduction chapter.
|
||||
List<String> getChapters();
|
||||
|
||||
// Bookmarks contains the string mappings from 'chapters' to line numbers.
|
||||
Map<String, Integer> getBookmarks();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.earth2me.essentials.textreader;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import com.earth2me.essentials.utils.StringUtil;
|
||||
import java.io.*;
|
||||
import java.lang.ref.SoftReference;
|
||||
@ -73,12 +74,15 @@ public class TextInput implements IText
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
if (line.length() > 1 && line.charAt(0) == '#')
|
||||
{
|
||||
bookmarks.put(line.substring(1).toLowerCase(Locale.ENGLISH).replaceAll("&[0-9a-fk]", ""), lineNumber);
|
||||
chapters.add(line.substring(1).replace('&', '§').replace("§§", "&").trim().replace(" ", "_"));
|
||||
String[] titles = line.substring(1).trim().replace(" ", "_").split(",");
|
||||
chapters.add(FormatUtil.replaceFormat(titles[0]));
|
||||
for (String title : titles) {
|
||||
bookmarks.put(FormatUtil.stripEssentialsFormat(title.toLowerCase(Locale.ENGLISH)), lineNumber);
|
||||
}
|
||||
}
|
||||
lines.add(line.replace('&', '§').replace("§§", "&"));
|
||||
lines.add(FormatUtil.replaceFormat(line));
|
||||
lineNumber++;
|
||||
}
|
||||
}
|
||||
|
@ -95,11 +95,6 @@ public class TextPager
|
||||
content.append(I18n.capitalCase(title[0])).append(": ");
|
||||
content.append(title[1]);
|
||||
}
|
||||
else if (chapterPageStr != null)
|
||||
{
|
||||
content.append(I18n.capitalCase(commandName)).append(": ");
|
||||
content.append(chapterPageStr);
|
||||
}
|
||||
else
|
||||
{
|
||||
content.append(I18n.capitalCase(commandName));
|
||||
@ -161,7 +156,10 @@ public class TextPager
|
||||
final int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0);
|
||||
if (!onePage && commandName != null)
|
||||
{
|
||||
sender.sendMessage(_("infoChapterPages", pageStr, page, pages));
|
||||
StringBuilder content = new StringBuilder();
|
||||
content.append(I18n.capitalCase(commandName)).append(": ");
|
||||
content.append(pageStr);
|
||||
sender.sendMessage(_("infoChapterPages", content, page, pages));
|
||||
}
|
||||
for (int i = start; i < chapterend && i < start + (onePage ? 20 : 9); i++)
|
||||
{
|
||||
|
@ -161,10 +161,10 @@ hour=hour
|
||||
hours=hours
|
||||
ignorePlayer=\u00a76You ignore player\u00a7c {0} \u00a76from now on.
|
||||
illegalDate=Illegal date format.
|
||||
infoChapter=Select chapter\:
|
||||
infoChapterPages=\u00a76Chapter {0}, page \u00a7c{1}\u00a76 of \u00a7c{2}\u00a76\:
|
||||
infoChapter=\u00a76Select chapter\:
|
||||
infoChapterPages=\u00a7e ---- \u00a76{0} \u00a7e--\u00a76 Page \u00a7c{1}\u00a76 of \u00a7c{2} \u00a7e----
|
||||
infoPages=\u00a7e ---- \u00a76{2} \u00a7e--\u00a76 Page \u00a7c{0}\u00a76/\u00a7c{1} \u00a7e----
|
||||
infoUnknownChapter=Unknown chapter.
|
||||
infoUnknownChapter=\u00a74Unknown chapter.
|
||||
insufficientFunds=\u00a74Insufficient funds available.
|
||||
invalidCharge=\u00a74Invalid charge.
|
||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}\u00a76.
|
||||
|
@ -161,10 +161,10 @@ hour=hour
|
||||
hours=hours
|
||||
ignorePlayer=\u00a76You ignore player\u00a7c {0} \u00a76from now on.
|
||||
illegalDate=Illegal date format.
|
||||
infoChapter=Select chapter\:
|
||||
infoChapterPages=\u00a76Chapter {0}, page \u00a7c{1}\u00a76 of \u00a7c{2}\u00a76\:
|
||||
infoChapter=\u00a76Select chapter\:
|
||||
infoChapterPages=\u00a7e ---- \u00a76{0} \u00a7e--\u00a76 Page \u00a7c{1}\u00a76 of \u00a7c{2} \u00a7e----
|
||||
infoPages=\u00a7e ---- \u00a76{2} \u00a7e--\u00a76 Page \u00a7c{0}\u00a76/\u00a7c{1} \u00a7e----
|
||||
infoUnknownChapter=Unknown chapter.
|
||||
infoUnknownChapter=\u00a74Unknown chapter.
|
||||
insufficientFunds=\u00a74Insufficient funds available.
|
||||
invalidCharge=\u00a74Invalid charge.
|
||||
invalidFireworkFormat=\u00a76The option \u00a74{0} \u00a76is not a valid value for \u00a74{1}\u00a76.
|
||||
|
Loading…
Reference in New Issue
Block a user