本文整理了Java中org.bukkit.command.Command.getName()
方法的一些代码示例,展示了Command.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Command.getName()
方法的具体详情如下:
包路径:org.bukkit.command.Command
类名称:Command
方法名:getName
[英]Returns the name of this command
[中]返回此命令的名称
代码示例来源:origin: Bukkit/Bukkit
/**
* {@inheritDoc}
*/
public boolean register(String fallbackPrefix, Command command) {
return register(command.getName(), fallbackPrefix, command);
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public String getShortText(Command command) {
CommandMapping mapping = dispatcher.get(command.getName());
if (mapping != null) {
return mapping.getDescription().getDescription();
} else {
logger.warning("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available";
}
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
// Add the command to the array because the underlying command handling
// code of WorldEdit expects it
String[] split = new String[args.length + 1];
System.arraycopy(args, 0, split, 1, args.length);
split[0] = cmd.getName();
CommandEvent event = new CommandEvent(wrapCommandSender(sender), Joiner.on(" ").join(split));
getWorldEdit().getEventBus().post(event);
return true;
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) {
// Add the command to the array because the underlying command handling
// code of WorldEdit expects it
String[] split = new String[args.length + 1];
System.arraycopy(args, 0, split, 1, args.length);
split[0] = cmd.getName();
CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), Joiner.on(" ").join(split));
getWorldEdit().getEventBus().post(event);
return event.getSuggestions();
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public String getFullText(Command command) {
CommandMapping mapping = dispatcher.get(command.getName());
if (mapping != null) {
Description description = mapping.getDescription();
return "Usage: " + description.getUsage() + (description.getHelp() != null ? "\n" + description.getHelp() : "");
} else {
logger.warning("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return "Help text not available";
}
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public boolean testPermission(CommandSender sender, Command command) {
CommandMapping mapping = dispatcher.get(command.getName());
if (mapping != null) {
CommandLocals locals = new CommandLocals();
locals.put(Actor.class, plugin.wrapCommandSender(sender));
return mapping.getCallable().testPermission(locals);
} else {
logger.warning("BukkitCommandInspector doesn't know how about the command '" + command + "'");
return false;
}
}
}
代码示例来源:origin: webbukkit/dynmap
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
DynmapCommandSender dsender;
if(sender instanceof Player) {
dsender = new BukkitPlayer((Player)sender);
}
else {
dsender = new BukkitCommandSender(sender);
}
return core.processCommand(dsender, cmd.getName(), commandLabel, args);
}
代码示例来源:origin: EngineHub/CommandHelper
@Override
public String getName() {
return cmd.getName();
}
代码示例来源:origin: CitizensDev/CitizensAPI
/**
* Checks to see whether there is a command handler for the given command at the root level. This will check aliases
* as well.
*
* @param cmd
* The command to check
* @param modifier
* The modifier to check (may be empty)
* @return Whether the command is handled
*/
public boolean hasCommand(org.bukkit.command.Command cmd, String modifier) {
String cmdName = cmd.getName().toLowerCase();
return commands.containsKey(cmdName + " " + modifier.toLowerCase()) || commands.containsKey(cmdName + " *");
}
代码示例来源:origin: PyvesB/AdvancedAchievements
private boolean shouldReturnPlayerList(Command command, String[] args) {
return !"aach".equals(command.getName())
|| args.length == 3 && StringUtils.equalsAnyIgnoreCase(args[0], "give", "reset", "check", "delete")
|| args.length == 4 && "add".equalsIgnoreCase(args[0]);
}
}
代码示例来源:origin: SpigotMC/Spigot-API
/**
* {@inheritDoc}
*/
public boolean register(String fallbackPrefix, Command command) {
return register(command.getName(), fallbackPrefix, command);
}
代码示例来源:origin: Co0sh/BetonQuest
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("cancelquest")) {
if (sender instanceof Player) {
Player player = (Player) sender;
String playerID = PlayerConverter.getID(player);
new Backpack(playerID, DisplayType.CANCEL);
}
return true;
}
return false;
}
}
代码示例来源:origin: Co0sh/BetonQuest
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("compass")) {
if (sender instanceof Player) {
Player player = (Player) sender;
String playerID = PlayerConverter.getID(player);
new Backpack(playerID, DisplayType.COMPASS);
}
return true;
}
return false;
}
}
代码示例来源:origin: Multiverse/Multiverse-Core
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!this.isEnabled()) {
sender.sendMessage("This plugin is Disabled!");
return true;
}
ArrayList<String> allArgs = new ArrayList<String>(args.length + 1);
allArgs.add(command.getName());
allArgs.addAll(Arrays.asList(args));
return this.getCore().getCommandHandler().locateAndRunCommand(sender, allArgs);
}
代码示例来源:origin: games647/LagMonitor
private boolean isCommandWhitelisted(Command cmd, CommandSender sender) {
if (!(sender instanceof Player)) {
return true;
}
FileConfiguration config = plugin.getConfig();
Collection<String> aliases = new ArrayList<>(cmd.getAliases());
aliases.add(cmd.getName());
for (String alias : aliases) {
List<String> aliasWhitelist = config.getStringList("whitelist-" + alias);
if (aliasWhitelist != null && !aliasWhitelist.isEmpty()) {
return aliasWhitelist.contains(sender.getName());
}
}
//whitelist doesn't exist
return true;
}
代码示例来源:origin: drtshock/PlayerVaults
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("pvreload")) {
reloadConfig();
loadConfig(); // To update blocked materials.
loadLang();
sender.sendMessage(ChatColor.GREEN + "Reloaded PlayerVault's configuration and lang files.");
}
return true;
}
代码示例来源:origin: Co0sh/BetonQuest
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("backpack")) {
// command sender must be a player, console can't have a backpack
if (sender instanceof Player) {
Debug.info("Executing /backpack command for " + sender.getName());
new Backpack(PlayerConverter.getID((Player) sender));
}
return true;
}
return false;
}
}
代码示例来源:origin: Co0sh/BetonQuest
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("journal")) {
// command sender must be a player, console can't have journal
if (sender instanceof Player) {
// giving the player his journal
BetonQuest.getInstance().getPlayerData(PlayerConverter.getID((Player) sender)).getJournal()
.addToInv(Integer.parseInt(Config.getString("config.default_journal_slot")));
}
return true;
}
return false;
}
代码示例来源:origin: SkyWars/SkyWars
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!enabledCorrectly) {
sender.sendMessage(SkyTrans.get(TransKey.NOT_FULLY_ENABLED));
} else {
sender.sendMessage(SkyTrans.get(TransKey.NO_CLUE_COMMAND, cmd.getName()));
}
return true;
}
代码示例来源:origin: DevLeoko/AdvancedBan
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (strings.length > 0) {
strings[0] = (Bukkit.getPlayer(strings[0]) != null ? Bukkit.getPlayer(strings[0]).getName() : strings[0]);
}
CommandManager.get().onCommand(commandSender, command.getName(), strings);
return true;
}
}
内容来源于网络,如有侵权,请联系作者删除!