blob: 64ba60a7bd584fcd448ccb0628aac4307d5b6fb5 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
package org.bukkit.craftbukkit.help;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.help.HelpTopic;
import org.bukkit.util.ChatPaginator;
import java.util.Collection;
/**
* This help topic generates the list of all other help topics.
*/
public class DefaultHelpTopic extends HelpTopic {
private Collection<HelpTopic> allTopics;
public DefaultHelpTopic(Collection<HelpTopic> allTopics) {
this.allTopics = allTopics;
}
public boolean canSee(CommandSender sender) {
return true;
}
public String getName() {
return "Overall";
}
public String getShortText() {
return "";
}
public String getFullText(CommandSender sender) {
StringBuilder sb = new StringBuilder();
for (HelpTopic topic : allTopics) {
if (topic.canSee(sender)) {
StringBuilder line = new StringBuilder();
line.append(ChatColor.GOLD);
line.append(topic.getName());
line.append(": ");
line.append(ChatColor.WHITE);
line.append(topic.getShortText());
String lineStr = line.toString().replace("\n", ". ");
if (sender instanceof Player && lineStr.length() > ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH) {
sb.append(lineStr.substring(0, ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH - 3));
sb.append("...");
} else {
sb.append(lineStr);
}
sb.append("\n");
}
}
return sb.toString();
}
}
|