blob: d950b0989b38167bcb6eb6d20e3db82a55ac7c7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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.Formatting;
import io.dico.dicore.command.chat.IChatHandler;
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) {
IChatHandler c = context.getAddress().getChatHandler();
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);
}
}
|