public abstract class HelpTopic extends Object
Custom implementations of this class can work at two levels. A simple
implementation only needs to set the value of name
, shortText
, and fullText
in the constructor. This base class will
take care of the rest.
Complex implementations can be created by overriding the behavior of all the methods in this class.
Modifier and Type | Field and Description |
---|---|
protected String |
amendedPermission |
protected String |
fullText |
protected String |
name |
protected String |
shortText |
Constructor and Description |
---|
HelpTopic() |
Modifier and Type | Method and Description |
---|---|
void |
amendCanSee(@Nullable String amendedPermission)
Allows the server administrator to override the permission required to
see a help topic.
|
void |
amendTopic(@Nullable String amendedShortText,
@Nullable String amendedFullText)
Allows the server admin (or another plugin) to add or replace the
contents of a help topic.
|
protected @NotNull String |
applyAmendment(@NotNull String baseText,
@Nullable String amendment)
Developers implementing their own custom HelpTopic implementations can
use this utility method to ensure their implementations comply with the
expected behavior of the
amendTopic(String, String)
method. |
abstract boolean |
canSee(@NotNull CommandSender player)
Determines if a
Player is allowed to see this help topic. |
@NotNull String |
getFullText(@NotNull CommandSender forWho)
Returns the full description of this help topic that is displayed when
the user requests this topic's details.
|
@NotNull String |
getName()
Returns the name of this help topic.
|
@NotNull String |
getShortText()
Returns a brief description that will be displayed in the topic index.
|
protected String name
protected String shortText
protected String fullText
protected String amendedPermission
public abstract boolean canSee(@NotNull @NotNull CommandSender player)
Player
is allowed to see this help topic.
HelpTopic implementations should take server administrator wishes into
account as set by the amendCanSee(String)
function.
player
- The Player in question.public void amendCanSee(@Nullable @Nullable String amendedPermission)
HelpTopic implementations should take this into account when
determining topic visibility on the canSee(org.bukkit.command.CommandSender)
function.
amendedPermission
- The permission node the server administrator
wishes to apply to this topic.@NotNull public @NotNull String getName()
@NotNull public @NotNull String getShortText()
@NotNull public @NotNull String getFullText(@NotNull @NotNull CommandSender forWho)
The result will be paginated to properly fit the user's client.
forWho
- The player or console requesting the full text. Useful
for further security trimming the command's full text based on
sub-permissions in custom implementations.public void amendTopic(@Nullable @Nullable String amendedShortText, @Nullable @Nullable String amendedFullText)
A null in either parameter will leave that part of the topic unchanged. In either amending parameter, the string <text> is replaced with the existing contents in the help topic. Use this to append or prepend additional content into an automatically generated help topic.
amendedShortText
- The new topic short text to use, or null to
leave alone.amendedFullText
- The new topic full text to use, or null to leave
alone.@NotNull protected @NotNull String applyAmendment(@NotNull @NotNull String baseText, @Nullable @Nullable String amendment)
amendTopic(String, String)
method.baseText
- The existing text of the help topic.amendment
- The amending text from the amendTopic() method.Copyright © 2021. All rights reserved.