geforkt von Mirrors/Paper
[Bleeding] Implemented command aliases in help. Addresses BUKKIT-1028
By: rmichela <deltahat@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
2a35131c2a
Commit
944fe0c27d
@ -16,7 +16,7 @@ import org.bukkit.help.HelpTopic;
|
|||||||
*/
|
*/
|
||||||
public class GenericCommandHelpTopic extends HelpTopic {
|
public class GenericCommandHelpTopic extends HelpTopic {
|
||||||
|
|
||||||
private Command command;
|
protected Command command;
|
||||||
|
|
||||||
public GenericCommandHelpTopic(Command command) {
|
public GenericCommandHelpTopic(Command command) {
|
||||||
this.command = command;
|
this.command = command;
|
||||||
|
@ -2,6 +2,7 @@ package org.bukkit.help;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.help.HelpTopic;
|
import org.bukkit.help.HelpTopic;
|
||||||
import org.bukkit.util.ChatPaginator;
|
import org.bukkit.util.ChatPaginator;
|
||||||
@ -10,35 +11,44 @@ import java.util.Collection;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This help topic generates a list of other help topics. This class is useful for adding your own
|
* This help topic generates a list of other help topics. This class is useful for adding your own
|
||||||
* index help topics.
|
* index help topics. To enforce a particular order, use a sorted collection.
|
||||||
*/
|
*/
|
||||||
public class IndexHelpTopic extends HelpTopic {
|
public class IndexHelpTopic extends HelpTopic {
|
||||||
|
|
||||||
|
private String permission;
|
||||||
|
private String preamble;
|
||||||
private Collection<HelpTopic> allTopics;
|
private Collection<HelpTopic> allTopics;
|
||||||
|
|
||||||
/**
|
public IndexHelpTopic(String name, String shortText, String permission, Collection<HelpTopic> topics) {
|
||||||
* Creates an index help topic from a collection of help topics. The index is displayed in the order of the
|
this(name, shortText, permission, topics, null);
|
||||||
* topic collection's iterator. To enforce a particular order, use a sorted collection.
|
}
|
||||||
* @param topics The collection of topics to use display in an index.
|
|
||||||
*/
|
public IndexHelpTopic(String name, String shortText, String permission, Collection<HelpTopic> topics, String preamble) {
|
||||||
public IndexHelpTopic(Collection<HelpTopic> topics) {
|
this.name = name;
|
||||||
|
this.shortText = shortText;
|
||||||
|
this.permission = permission;
|
||||||
this.allTopics = topics;
|
this.allTopics = topics;
|
||||||
|
this.preamble = preamble;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSee(CommandSender sender) {
|
public boolean canSee(CommandSender sender) {
|
||||||
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (permission == null) {
|
||||||
public String getName() {
|
return true;
|
||||||
return "Overall";
|
|
||||||
}
|
}
|
||||||
|
return sender.hasPermission(permission);
|
||||||
public String getShortText() {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullText(CommandSender sender) {
|
public String getFullText(CommandSender sender) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
if (preamble != null) {
|
||||||
|
sb.append(preamble);
|
||||||
|
sb.append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
for (HelpTopic topic : allTopics) {
|
for (HelpTopic topic : allTopics) {
|
||||||
if (topic.canSee(sender)) {
|
if (topic.canSee(sender)) {
|
||||||
StringBuilder line = new StringBuilder();
|
StringBuilder line = new StringBuilder();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren