mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-14 10:34:41 +02:00
New Sign: Info
Syntax: [info] / [chapter] / [page number] / [cost]
This commit is contained in:
54
Essentials/src/com/earth2me/essentials/signs/SignInfo.java
Normal file
54
Essentials/src/com/earth2me/essentials/signs/SignInfo.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.textreader.TextInput;
|
||||
import com.earth2me.essentials.textreader.TextPager;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class SignInfo extends EssentialsSign
|
||||
{
|
||||
public SignInfo()
|
||||
{
|
||||
super("Info");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
validateTrade(sign, 3, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
String chapter = sign.getLine(1);
|
||||
String page = sign.getLine(2);
|
||||
|
||||
final IText input;
|
||||
try
|
||||
{
|
||||
input = new TextInput(player, "info", true, ess);
|
||||
final IText output = new KeywordReplacer(input, player, ess);
|
||||
final TextPager pager = new TextPager(output);
|
||||
pager.showPage(chapter, page, null, player);
|
||||
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -10,6 +10,7 @@ public enum Signs
|
||||
FREE(new SignFree()),
|
||||
GAMEMODE(new SignGameMode()),
|
||||
HEAL(new SignHeal()),
|
||||
INFO(new SignInfo()),
|
||||
KIT(new SignKit()),
|
||||
MAIL(new SignMail()),
|
||||
PROTECTION(new SignProtection()),
|
||||
|
@@ -48,7 +48,7 @@ public class TextPager
|
||||
|
||||
final int start = onePage ? 0 : (page - 1) * 9;
|
||||
final int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
if (!onePage)
|
||||
if (!onePage && commandName != null)
|
||||
{
|
||||
StringBuilder content = new StringBuilder();
|
||||
final String[] title = commandName.split(" ", 2);
|
||||
@@ -72,7 +72,7 @@ public class TextPager
|
||||
{
|
||||
sender.sendMessage(lines.get(i));
|
||||
}
|
||||
if (!onePage && page < pages)
|
||||
if (!onePage && page < pages && commandName != null)
|
||||
{
|
||||
sender.sendMessage(_("readNextPage", commandName, page + 1));
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class TextPager
|
||||
}
|
||||
|
||||
int pages = end / 9 + (end % 9 > 0 ? 1 : 0);
|
||||
if (!onePage)
|
||||
if (!onePage && commandName != null)
|
||||
{
|
||||
|
||||
sender.sendMessage(_("infoPages", page, pages, I18n.capitalCase(commandName)));
|
||||
@@ -139,7 +139,7 @@ public class TextPager
|
||||
{
|
||||
sender.sendMessage(lines.get(i));
|
||||
}
|
||||
if (!onePage && page < pages)
|
||||
if (!onePage && page < pages && commandName != null)
|
||||
{
|
||||
sender.sendMessage(_("readNextPage", commandName, page + 1));
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public class TextPager
|
||||
|
||||
final int page = chapterpage + 1;
|
||||
final int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0);
|
||||
if (!onePage)
|
||||
if (!onePage && commandName != null)
|
||||
{
|
||||
sender.sendMessage(_("infoChapterPages", pageStr, page, pages));
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class TextPager
|
||||
{
|
||||
sender.sendMessage(lines.get(i));
|
||||
}
|
||||
if (!onePage && page < pages)
|
||||
if (!onePage && page < pages && commandName != null)
|
||||
{
|
||||
sender.sendMessage(_("readNextPage", commandName, pageStr + " " + (page + 1)));
|
||||
}
|
||||
|
@@ -218,6 +218,7 @@ enabledSigns:
|
||||
#- enchant
|
||||
#- gamemode
|
||||
#- heal
|
||||
#- info
|
||||
#- spawnmob
|
||||
#- repair
|
||||
#- time
|
||||
|
Reference in New Issue
Block a user