diff options
author | Dico200 <dico.karssiens@gmail.com> | 2018-07-25 01:53:23 +0100 |
---|---|---|
committer | Dico200 <dico.karssiens@gmail.com> | 2018-07-25 01:53:23 +0100 |
commit | 44587e49ff1840219d9bc44844d4a3a6cd8ac5de (patch) | |
tree | 276ae9625795e9d79fc7db8592dbcb3a1af60928 /dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/DefaultPageLayout.java | |
parent | 5e168847c2624b767deb9da310ecfdf169e0f43c (diff) |
Add dicore3-command
Diffstat (limited to 'dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/DefaultPageLayout.java')
-rw-r--r-- | dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/DefaultPageLayout.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/DefaultPageLayout.java b/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/DefaultPageLayout.java new file mode 100644 index 0000000..e8f9bce --- /dev/null +++ b/dicore3/command/src/main/java/io/dico/dicore/command/chat/help/defaults/DefaultPageLayout.java @@ -0,0 +1,40 @@ +package io.dico.dicore.command.chat.help.defaults; + +import io.dico.dicore.command.EMessageType; +import io.dico.dicore.command.ExecutionContext; +import io.dico.dicore.command.ICommandAddress; +import io.dico.dicore.command.ModifiableCommandAddress; +import io.dico.dicore.command.chat.Formatting; +import io.dico.dicore.command.chat.IChatController; +import io.dico.dicore.command.chat.help.IPageBorder; +import io.dico.dicore.command.chat.help.IPageLayout; +import io.dico.dicore.command.chat.help.PageBorders; +import org.bukkit.permissions.Permissible; + +public class DefaultPageLayout implements IPageLayout { + + @Override + public PageBorders getPageBorders(ICommandAddress target, Permissible viewer, ExecutionContext context, int pageNum) { + IChatController c = context.getAddress().getChatController(); + String prefix = c.getMessagePrefixForType(EMessageType.INFORMATIVE); + Formatting informative = c.getChatFormatForType(EMessageType.INFORMATIVE); + Formatting number = c.getChatFormatForType(EMessageType.NEUTRAL); + + String nextPageCommand; + ICommandAddress executor = context.getAddress(); + if (((ModifiableCommandAddress) executor).hasHelpCommand()) { + nextPageCommand = ((ModifiableCommandAddress) executor).getHelpCommand().getAddress() + ' ' + (pageNum + 1); + } else { + nextPageCommand = executor.getAddress() + ' ' + (pageNum + 1); + } + + String header = prefix + informative + "Help page " + number + pageNum + informative + + '/' + number + "%pageCount%" + informative + " for /" + target.getAddress(); + String footer = informative + "Type /" + nextPageCommand + " for the next page"; + + IPageBorder headerBorder = PageBorders.simpleBorder("", header); + IPageBorder footerBorder = PageBorders.disappearingBorder(pageNum, footer); + return new PageBorders(headerBorder, footerBorder); + } + +} |