Added info how to read the next page to /info /help /motd /rules

This commit is contained in:
snowleo 2011-11-28 20:52:15 +01:00
parent 5e24584bf7
commit 7db7fd4136
13 changed files with 31 additions and 11 deletions

View File

@ -173,7 +173,7 @@ public class EssentialsPlayerListener extends PlayerListener
final IText input = new TextInput(user, "motd", true, ess);
final IText output = new KeywordReplacer(input, user, ess);
final TextPager pager = new TextPager(output, true);
pager.showPage("1", null, user);
pager.showPage("1", null, "motd", user);
}
catch (IOException ex)
{

View File

@ -41,7 +41,7 @@ public class Commandhelp extends EssentialsCommand
output = new KeywordReplacer(input, user, ess);
}
final TextPager pager = new TextPager(output);
pager.showPage(pageStr, chapterPageStr, user);
pager.showPage(pageStr, chapterPageStr, "help", user);
}
@Override

View File

@ -21,6 +21,6 @@ public class Commandinfo extends EssentialsCommand
final IText input = new TextInput(sender, "info", true, ess);
final IText output = new KeywordReplacer(input, sender, ess);
final TextPager pager = new TextPager(output);
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, sender);
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, "info", sender);
}
}

View File

@ -21,6 +21,6 @@ public class Commandmotd extends EssentialsCommand
final IText input = new TextInput(sender, "motd", true, ess);
final IText output = new KeywordReplacer(input, sender, ess);
final TextPager pager = new TextPager(output);
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, sender);
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, "motd", sender);
}
}

View File

@ -21,6 +21,6 @@ public class Commandrules extends EssentialsCommand
final IText input = new TextInput(sender, "rules", true, ess);
final IText output = new KeywordReplacer(input, sender, ess);
final TextPager pager = new TextPager(output);
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, sender);
pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, "rules", sender);
}
}

View File

@ -23,7 +23,7 @@ public class TextPager
this.onePage = onePage;
}
public void showPage(final String pageStr, final String chapterPageStr, final CommandSender sender)
public void showPage(final String pageStr, final String chapterPageStr, final String commandName, final CommandSender sender)
{
List<String> lines = text.getLines();
List<String> chapters = text.getChapters();
@ -45,16 +45,20 @@ public class TextPager
page = 1;
}
int start = onePage ? 0 : (page - 1) * 9;
final int start = onePage ? 0 : (page - 1) * 9;
final int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
if (!onePage)
{
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
sender.sendMessage(_("infoPages", page, pages));
}
for (int i = start; i < lines.size() && i < start + (onePage ? 20 : 9); i++)
{
sender.sendMessage(lines.get(i));
}
if (!onePage && page < pages)
{
sender.sendMessage(_("readNextPage", commandName, page + 1));
}
return;
}
@ -108,15 +112,20 @@ public class TextPager
}
}
int pages = end / 9 + (end % 9 > 0 ? 1 : 0);
if (!onePage)
{
int pages = end / 9 + (end % 9 > 0 ? 1 : 0);
sender.sendMessage(_("infoPages", page, pages));
}
for (int i = start; i < end && i < start + (onePage ? 20 : 9); i++)
{
sender.sendMessage(lines.get(i));
}
if (!onePage && page < pages)
{
sender.sendMessage(_("readNextPage", commandName, page + 1));
}
return;
}
}
@ -155,15 +164,19 @@ public class TextPager
}
final int start = chapterstart + (onePage ? 0 : chapterpage * 9);
final int page = chapterpage + 1;
final int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0);
if (!onePage)
{
final int page = chapterpage + 1;
final int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0);
sender.sendMessage(_("infoChapterPages", pageStr, page, pages));
}
for (int i = start; i < chapterend && i < start + (onePage ? 20 : 9); i++)
{
sender.sendMessage(lines.get(i));
}
if (!onePage && page < pages)
{
sender.sendMessage(_("readNextPage", commandName, pageStr + " " + (page + 1)));
}
}
}

View File

@ -269,6 +269,7 @@ powerToolsDisabled=All of your power tools have been disabled.
powerToolsEnabled=All of your power tools have been enabled.
protectionOwner=\u00a76[EssentialsProtect] Protection owner: {0}
questionFormat=\u00a77[Question]\u00a7f {0}
readNextPage=Type /{0} {1} to read the next page
reloadAllPlugins=\u00a77Reloaded all plugins.
repair=You have successfully repaired your: \u00a7e{0}.
repairAlreadyFixed=\u00a77This item does not need repairing.

View File

@ -269,6 +269,7 @@ powerToolsDisabled= All of your power tools have been disabled.
powerToolsEnabled= All of your power tools have been enabled.
protectionOwner=\u00a76[EssentialsProtect] Beskyttelses ejer: {0}
questionFormat=\u00a77[Sp\u00f8rgsm\u00e5l]\u00a7f {0}
readNextPage=Type /{0} {1} to read the next page
reloadAllPlugins=\u00a77Genindl\u00e6ste alle tilf\u00f8jelser.
repair=You have successfully repaired your: \u00a7e{0}.
repairAlreadyFixed=\u00a77This item does not need repairing.

View File

@ -269,6 +269,7 @@ powerToolsDisabled=Alle deine Powertools wurden deaktiviert.
powerToolsEnabled=Alle deine Powertools wurden aktiviert.
protectionOwner=\u00a76[EssentialsProtect] Besitzer dieses Blocks: {0}
questionFormat=\u00a77[Frage]\u00a7f {0}
readNextPage=Type /{0} {1} to read the next page
reloadAllPlugins=\u00a77Alle plugins neu geladen.
repair=Du hast erfolgreich deine {0} repariert.
repairAlreadyFixed=\u00a77Dieser Gegenstand ben\u00f6tigt keine Reparatur.

View File

@ -269,6 +269,7 @@ powerToolsDisabled=All of your power tools have been enabled.
powerToolsEnabled=All of your power tools have been enabled.
protectionOwner=\u00a76[EssentialsProtect] Protection owner: {0}
questionFormat=\u00a77[Question]\u00a7f {0}
readNextPage=Type /{0} {1} to read the next page
reloadAllPlugins=\u00a77Reloaded all plugins.
repair=You have successfully repaired your: \u00a7e{0}.
repairAlreadyFixed=\u00a77This item does not need repairing.

View File

@ -269,6 +269,7 @@ powerToolsDisabled=All of your power tools have been disabled.
powerToolsEnabled=All of your power tools have been enabled.
protectionOwner=\u00a76[EssentialsProtect] Due&ntilde;o de la proteccion: {0}
questionFormat=\u00a77[Pregunta]\u00a7f {0}
readNextPage=Type /{0} {1} to read the next page
reloadAllPlugins=\u00a77Todos los plugins recargados.
repair=Has reparado satisfactoriamente tu: \u00a7e{0}.
repairAlreadyFixed=\u00a77Este objeto no necesita de reparado.

View File

@ -269,6 +269,7 @@ powerToolsDisabled=Toutes vos commandes assign\u00e9es ont \u00e9t\u00e9 retir\u
powerToolsEnabled=Toutes vos commandes assign\u00e9es ont \u00e9t\u00e9 activ\u00e9es.
protectionOwner=\u00a76[EssentialsProtect] Propri\u00e9taire de la protection : {0}
questionFormat=\u00a77[Question]\u00a7f {0}
readNextPage=Type /{0} {1} to read the next page
reloadAllPlugins=\u00a77Toutes les extensions ont \u00e9t\u00e9 recharg\u00e9es.
repair=Vous avez r\u00e9par\u00e9 votre : \u00a7e{0}.
repairAlreadyFixed=\u00a77Cet objet n''a pas besoin de r\u00e9paration.

View File

@ -269,6 +269,7 @@ powerToolsDisabled=All of your power tools have been disabled.
powerToolsEnabled=All of your power tools have been enabled.
protectionOwner=\u00a76[EssentialsProtect] Beschermingeigenaar: {0}
questionFormat=\u00a77[Vraag]\u00a7f {0}
readNextPage=Type /{0} {1} to read the next page
reloadAllPlugins=\u00a77Alle plugins zijn herladen.
repair=You have successfully repaired your: \u00a7e{0}.
repairAlreadyFixed=\u00a77This item does not need repairing.