org.bukkit.command.Command.getUsage()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中org.bukkit.command.Command.getUsage()方法的一些代码示例,展示了Command.getUsage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Command.getUsage()方法的具体详情如下:
包路径:org.bukkit.command.Command
类名称:Command
方法名:getUsage

Command.getUsage介绍

[英]Gets an example usage of this command
[中]获取此命令的示例用法

代码示例

代码示例来源:origin: Bukkit/Bukkit

sb.append("Usage: ");
sb.append(ChatColor.WHITE);
sb.append(command.getUsage().replace("<command>", name.substring(1)));

代码示例来源:origin: EngineHub/CommandHelper

@Override
public String getUsage() {
  return cmd.getUsage();
}

代码示例来源:origin: EngineHub/CommandBook

@Override
  public String format(org.bukkit.command.Command entry) {
    return entry.getUsage() + " - "
        + entry.getDescription();
  }
}.display(sender, serverCommands, args.getFlagInteger('p', 1));

代码示例来源:origin: NoCheatPlus/NoCheatPlus

public CommandsCommand(JavaPlugin plugin) {
  super(plugin, "commands", Permissions.COMMAND_COMMANDS, new String[]{"cmds"});
  for (int i = 0; i < moreCommands.length; i++){
    moreCommands[i] = moreCommands[i].replace("<command>", "ncp");
  }
  String all = TAG + "All commands info:\n";
  Command cmd = plugin.getCommand("nocheatplus");
  if (cmd != null){
    all += cmd.getUsage().replace("<command>", "ncp");
  }
  all += StringUtil.join(Arrays.asList(moreCommands), "\n");
  allCommands = all;
}

代码示例来源:origin: TotalFreedom/TotalFreedomMod

private static String buildDescription(Command command)
{
  StringBuilder sb = new StringBuilder();
  sb.append(
      "<li><span class=\"commandName\">{$CMD_NAME}</span> - Usage: <span class=\"commandUsage\">{$CMD_USAGE}</span>"
      .replace("{$CMD_NAME}", escapeHtml4(command.getName().trim()))
      .replace("{$CMD_USAGE}", escapeHtml4(command.getUsage().trim())));
  if (!command.getAliases().isEmpty())
  {
    sb.append(
        " - Aliases: <span class=\"commandAliases\">{$CMD_ALIASES}</span>"
        .replace("{$CMD_ALIASES}", escapeHtml4(StringUtils.join(command.getAliases(), ", "))));
  }
  sb.append(
      "<br><span class=\"commandDescription\">{$CMD_DESC}</span></li>\r\n"
      .replace("{$CMD_DESC}", escapeHtml4(command.getDescription().trim())));
  return sb.toString();
}

代码示例来源:origin: SpigotMC/Spigot-API

sb.append("Usage: ");
sb.append(ChatColor.WHITE);
sb.append(command.getUsage().replace("<command>", name.substring(1)));

代码示例来源:origin: EngineHub/CommandBook

public void printCommandHelp(CommandSender sender, org.bukkit.command.Command cmd) {
  sender.sendMessage(ChatColor.YELLOW + "Command: " + cmd.getName());
  final String aliases = cmd.getAliases().toString().replaceAll("\\[(.*)\\]", "$1");
  if (aliases.length() > 0) {
    sender.sendMessage(ChatColor.YELLOW + "Aliases: " + aliases);
  }
  sender.sendMessage(ChatColor.YELLOW + "Description: " + cmd.getDescription());
  sender.sendMessage(ChatColor.YELLOW + "Usage: " + cmd.getUsage());
  if (cmd instanceof PluginCommand) {
    sender.sendMessage(ChatColor.YELLOW + "Plugin: " +
        ((PluginCommand)cmd).getPlugin().getDescription().getName());
  } else if (cmd instanceof DynamicPluginCommand) {
    sender.sendMessage(ChatColor.YELLOW + "Owner: " +
        ((DynamicPluginCommand) cmd).getOwner().getClass().getSimpleName());
  } else if (cmd instanceof VanillaCommand) {
    sender.sendMessage(ChatColor.YELLOW + "Vanilla command");
  }
}

相关文章