Class CommandNode

java.lang.Object
top.magstar.framework.commands.CommandNode

public class CommandNode extends Object
  • Constructor Details

  • Method Details

    • addChild

      public void addChild(CommandNode child)
      添加子节点
      Parameters:
      child - 要添加的子节点
    • findChild

      public CommandNode findChild(String name)
      查找子节点(忽略大小写)
      Parameters:
      name - 子节点名称或别名
      Returns:
      找到的子节点,如果不存在则返回null
    • getMatchingChildNames

      public List<String> getMatchingChildNames(String prefix)
      获取所有匹配前缀的子命令名称(忽略大小写)
      Parameters:
      prefix - 前缀
      Returns:
      匹配的子命令名称列表
    • getMatchingAllChildNames

      public List<String> getMatchingAllChildNames(String prefix)
      获取所有匹配前缀的子命令名称和别名(忽略大小写)
      Parameters:
      prefix - 前缀
      Returns:
      匹配的所有可用名称列表
    • removeChild

      public void removeChild(CommandNode child)
      移除子节点
      Parameters:
      child - 要移除的子节点
    • hasChildren

      public boolean hasChildren()
      检查是否有子节点
      Returns:
      如果有子节点返回true
    • getChildNames

      public Set<String> getChildNames()
      获取所有子节点的名称(不包括别名)
      Returns:
      子节点名称集合
    • getAllChildNames

      public Set<String> getAllChildNames()
      获取所有子节点的名称和别名
      Returns:
      所有可用的子命令名称
    • getFullPath

      public String getFullPath()
      获取完整的命令路径
      Returns:
      从根节点到当前节点的完整路径
    • getDepth

      public int getDepth()
      计算当前节点在命令树中的深度
      Returns:
      深度值,根节点为0
    • isRoot

      public boolean isRoot()
      检查是否是根节点
      Returns:
      如果是根节点返回true
    • isLeaf

      public boolean isLeaf()
      检查是否是叶子节点(没有子节点)
      Returns:
      如果是叶子节点返回true
    • getAncestors

      public List<CommandNode> getAncestors()
      获取所有祖先节点
      Returns:
      从根节点到父节点的路径列表
    • getDescendants

      public List<CommandNode> getDescendants()
      获取所有后代节点
      Returns:
      所有子节点及其子节点的列表
    • isMainCommand

      public boolean isMainCommand()
    • isSubCommand

      public boolean isSubCommand()
    • getPermission

      public String getPermission()
    • isPlayerOnly

      public boolean isPlayerOnly()
    • getMinArgs

      public int getMinArgs()
    • getMaxArgs

      public int getMaxArgs()
    • getUsage

      public String getUsage()
    • getDescription

      public String getDescription()
    • getName

      public String getName()
    • getAliases

      public String[] getAliases()
    • getMethod

      public Method getMethod()
    • getHandler

      public Object getHandler()
    • getChildren

      public Map<String,CommandNode> getChildren()
    • getParent

      public CommandNode getParent()
    • getSubCommandAnnotation

      public MagstarSubCommand getSubCommandAnnotation()
    • getMainCommandAnnotation

      public MagstarCommandRegister getMainCommandAnnotation()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object