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