Class HelpTopic

java.lang.Object
org.bukkit.help.HelpTopic
Direct Known Subclasses:
GenericCommandHelpTopic, IndexHelpTopic

public abstract class HelpTopic
extends java.lang.Object
HelpTopic implementations are displayed to the user when the user uses the /help command.

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.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.lang.String amendedPermission  
    protected java.lang.String fullText  
    protected java.lang.String name  
    protected java.lang.String shortText  
  • Constructor Summary

    Constructors 
    Constructor Description
    HelpTopic()  
  • Method Summary

    Modifier and Type Method Description
    void amendCanSee​(java.lang.String amendedPermission)
    Allows the server administrator to override the permission required to see a help topic.
    void amendTopic​(java.lang.String amendedShortText, java.lang.String amendedFullText)
    Allows the server admin (or another plugin) to add or replace the contents of a help topic.
    protected java.lang.String applyAmendment​(java.lang.String baseText, java.lang.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​(CommandSender player)
    Determines if a Player is allowed to see this help topic.
    java.lang.String getFullText​(CommandSender forWho)
    Returns the full description of this help topic that is displayed when the user requests this topic's details.
    java.lang.String getName()
    Returns the name of this help topic.
    java.lang.String getShortText()
    Returns a brief description that will be displayed in the topic index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • name

      protected java.lang.String name
    • shortText

      protected java.lang.String shortText
    • fullText

      protected java.lang.String fullText
    • amendedPermission

      protected java.lang.String amendedPermission
  • Constructor Details

  • Method Details

    • canSee

      public abstract boolean canSee​(CommandSender player)
      Determines if a Player is allowed to see this help topic.

      HelpTopic implementations should take server administrator wishes into account as set by the amendCanSee(String) function.

      Parameters:
      player - The Player in question.
      Returns:
      True of the Player can see this help topic, false otherwise.
    • amendCanSee

      public void amendCanSee​(java.lang.String amendedPermission)
      Allows the server administrator to override the permission required to see a help topic.

      HelpTopic implementations should take this into account when determining topic visibility on the canSee(org.bukkit.command.CommandSender) function.

      Parameters:
      amendedPermission - The permission node the server administrator wishes to apply to this topic.
    • getName

      public java.lang.String getName()
      Returns the name of this help topic.
      Returns:
      The topic name.
    • getShortText

      public java.lang.String getShortText()
      Returns a brief description that will be displayed in the topic index.
      Returns:
      A brief topic description.
    • getFullText

      public java.lang.String getFullText​(CommandSender forWho)
      Returns the full description of this help topic that is displayed when the user requests this topic's details.

      The result will be paginated to properly fit the user's client.

      Parameters:
      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.
      Returns:
      A full topic description.
    • amendTopic

      public void amendTopic​(java.lang.String amendedShortText, java.lang.String amendedFullText)
      Allows the server admin (or another plugin) to add or replace the contents of a help topic.

      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.

      Parameters:
      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.
    • applyAmendment

      protected java.lang.String applyAmendment​(java.lang.String baseText, java.lang.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.
      Parameters:
      baseText - The existing text of the help topic.
      amendment - The amending text from the amendTopic() method.
      Returns:
      The application of the amending text to the existing text, according to the expected rules of amendTopic().