當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtil.startsWithIgnoreCase方法代碼示例

本文整理匯總了Java中org.bukkit.util.StringUtil.startsWithIgnoreCase方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtil.startsWithIgnoreCase方法的具體用法?Java StringUtil.startsWithIgnoreCase怎麽用?Java StringUtil.startsWithIgnoreCase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.util.StringUtil的用法示例。


在下文中一共展示了StringUtil.startsWithIgnoreCase方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: tabCompleteChat

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
public List<String> tabCompleteChat(Player player, String message) {
    List<String> completions = new ArrayList<String>();
    PlayerChatTabCompleteEvent event = new PlayerChatTabCompleteEvent(player, message, completions);
    String token = event.getLastToken();
    for (Player p : getOnlinePlayers()) {
        if (player.canSee(p) && StringUtil.startsWithIgnoreCase(p.getName(), token)) {
            completions.add(p.getName());
        }
    }
    pluginManager.callEvent(event);

    Iterator<?> it = completions.iterator();
    while (it.hasNext()) {
        Object current = it.next();
        if (!(current instanceof String)) {
            // Sanity
            it.remove();
        }
    }
    Collections.sort(completions, String.CASE_INSENSITIVE_ORDER);
    return completions;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:23,代碼來源:CraftServer.java

示例2: tabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 1) {
        List<String> completions = new ArrayList<String>();
        for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
            String playerName = player.getName();
            if (player.isOp() && StringUtil.startsWithIgnoreCase(playerName, args[0])) {
                completions.add(playerName);
            }
        }
        return completions;
    }
    return ImmutableList.of();
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:19,代碼來源:DeopCommand.java

示例3: tabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 1) {
        List<String> completions = new ArrayList<String>();
        for (OfflinePlayer player : Bukkit.getBannedPlayers()) {
            String name = player.getName();
            if (StringUtil.startsWithIgnoreCase(name, args[0])) {
                completions.add(name);
            }
        }
        return completions;
    }
    return ImmutableList.of();
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:19,代碼來源:PardonCommand.java

示例4: tabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 1) {
        List<String> completions = new ArrayList<String>();
        String toComplete = args[0].toLowerCase();
        for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
            if (StringUtil.startsWithIgnoreCase(plugin.getName(), toComplete)) {
                completions.add(plugin.getName());
            }
        }
        return completions;
    }
    return ImmutableList.of();
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:19,代碼來源:VersionCommand.java

示例5: tabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
/**
 * Executed on tab completion for this command, returning a list of
 * options the player can tab through.
 *
 * @param sender Source object which is executing this command
 * @param alias the alias being used
 * @param args All arguments passed to the command, split via ' '
 * @return a list of tab-completions for the specified arguments. This
 *     will never be null. List may be immutable.
 * @throws IllegalArgumentException if sender, alias, or args is null
 */
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 0) {
        return ImmutableList.of();
    }

    String lastWord = args[args.length - 1];

    Player senderPlayer = sender instanceof Player ? (Player) sender : null;

    ArrayList<String> matchedPlayers = new ArrayList<String>();
    for (Player player : sender.getServer().getOnlinePlayers()) {
        String name = player.getName();
        if ((senderPlayer == null || senderPlayer.canSee(player)) && StringUtil.startsWithIgnoreCase(name, lastWord)) {
            matchedPlayers.add(name);
        }
    }

    Collections.sort(matchedPlayers, String.CASE_INSENSITIVE_ORDER);
    return matchedPlayers;
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:36,代碼來源:Command.java

示例6: tabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
/**
 * Executed on tab completion for this command, returning a list of options
 * the player can tab through.
 *
 * @param sender Source object which is executing this command
 * @param alias the alias being used
 * @param args All arguments passed to the command, split via ' '
 * @return a list of tab-completions for the specified arguments. This will never be null. List may be immutable.
 * @throws IllegalArgumentException if sender, alias, or args is null
 */
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 0) {
        return ImmutableList.of();
    }

    String lastWord = args[args.length - 1];

    Player senderPlayer = sender instanceof Player ? (Player) sender : null;

    ArrayList<String> matchedPlayers = new ArrayList<String>();
    for (Player player : sender.getServer().getOnlinePlayers()) {
        String name = player.getName();
        if ((senderPlayer == null || senderPlayer.canSee(player)) && StringUtil.startsWithIgnoreCase(name, lastWord)) {
            matchedPlayers.add(name);
        }
    }

    Collections.sort(matchedPlayers, String.CASE_INSENSITIVE_ORDER);
    return matchedPlayers;
}
 
開發者ID:AlmuraDev,項目名稱:Almura-API,代碼行數:35,代碼來源:Command.java

示例7: onTabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd,
		String alias, String[] args) {
	ArrayList<String> matchedSubCommands = new ArrayList<String>();
	for (SubCommand command : commands.values().toArray(new SubCommand[0])) {
		if (args[0].equalsIgnoreCase(command.toString()))
			return command.onTabComplete(sender, cmd, alias,
					Utils.removeFirst(args));

		if (StringUtil.startsWithIgnoreCase(command.toString(), args[0])
				|| args.length < 0) {
			matchedSubCommands.add(command.toString());
		}
	}

	Collections.sort(matchedSubCommands, String.CASE_INSENSITIVE_ORDER);
	return matchedSubCommands;
}
 
開發者ID:Tommsy64,項目名稱:Bash-Multi-Command,代碼行數:19,代碼來源:BMCCommandExecutor.java

示例8: tabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 1) {
        return super.tabComplete(sender, alias, args);
    }
    if (args.length == 2) {
        final String arg = args[1];
        final List<String> materials = GiveCommand.materials;
        List<String> completion = new ArrayList<String>();

        final int size = materials.size();
        int i = Collections.binarySearch(materials, arg, String.CASE_INSENSITIVE_ORDER);

        if (i < 0) {
            // Insertion (start) index
            i = -1 - i;
        }

        for ( ; i < size; i++) {
            String material = materials.get(i);
            if (StringUtil.startsWithIgnoreCase(material, arg)) {
                completion.add(material);
            } else {
                break;
            }
        }

        return Bukkit.getUnsafe().tabCompleteInternalMaterialName(arg, completion);
    }
    return ImmutableList.of();
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:36,代碼來源:GiveCommand.java

示例9: tabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 1) {
        if (!(sender instanceof Player)) {
            return ImmutableList.of();
        }

        String lastWord = args[0];
        if (lastWord.length() == 0) {
            return ImmutableList.of();
        }

        Player senderPlayer = (Player) sender;

        ArrayList<String> matchedPlayers = new ArrayList<String>();
        for (Player player : sender.getServer().getOnlinePlayers()) {
            String name = player.getName();
            if (!senderPlayer.canSee(player) || player.isOp()) {
                continue;
            }
            if (StringUtil.startsWithIgnoreCase(name, lastWord)) {
                matchedPlayers.add(name);
            }
        }

        Collections.sort(matchedPlayers, String.CASE_INSENSITIVE_ORDER);
        return matchedPlayers;
    }
    return ImmutableList.of();
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:35,代碼來源:OpCommand.java

示例10: tabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 1) {
        return super.tabComplete(sender, alias, args);
    }
    if (args.length == 2) {
        final String arg = args[1];
        final List<String> materials = ClearCommand.materials;
        List<String> completion = null;

        final int size = materials.size();
        int i = Collections.binarySearch(materials, arg, String.CASE_INSENSITIVE_ORDER);

        if (i < 0) {
            // Insertion (start) index
            i = -1 - i;
        }

        for ( ; i < size; i++) {
            String material = materials.get(i);
            if (StringUtil.startsWithIgnoreCase(material, arg)) {
                if (completion == null) {
                    completion = new ArrayList<String>();
                }
                completion.add(material);
            } else {
                break;
            }
        }

        if (completion != null) {
            return completion;
        }
    }
    return ImmutableList.of();
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:41,代碼來源:ClearCommand.java

示例11: tabCompleteChat

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
public List<String> tabCompleteChat(Player player, String message) {
    List<String> completions = new ArrayList<String>();
    PlayerChatTabCompleteEvent event = new PlayerChatTabCompleteEvent(player, message, completions);
    String token = event.getLastToken();
    for (Player p : getOnlinePlayers()) {
        if (player.canSee(p) && StringUtil.startsWithIgnoreCase(p.getName(), token)) {
        	if (event.isPinging())
        	{
        		StringBuilder sb = new StringBuilder(1 + p.getName().length());
        		sb.append('@'); sb.append(p.getName());
        		completions.add(sb.toString());
        	}
        	else
        		completions.add(p.getName());
        }
    }
    pluginManager.callEvent(event);

    Iterator<?> it = completions.iterator();
    while (it.hasNext()) {
        Object current = it.next();
        if (!(current instanceof String)) {
            // Sanity
            it.remove();
        }
    }
    Collections.sort(completions, String.CASE_INSENSITIVE_ORDER);
    return completions;
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos,代碼行數:30,代碼來源:CraftServer.java

示例12: fromDisplayText

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
/**
 * Parses a profile from the text displayed on a sign. Used for newly
 * created signs and for signs created by Lockette/Deadbolt.
 *
 * @param text
 *            The text on a single line.
 * @return The profile.
 */
public Profile fromDisplayText(String text) {
    text = ChatColor.stripColor(text.trim());

    if (text.length() > 2) {
        // [Everyone]
        if (text.equalsIgnoreCase(everyoneTagString)) {
            return this.everyoneProfile;
        }

        // [Redstone]
        if (text.equalsIgnoreCase(redstoneTagString)) {
            return this.redstoneProfile;
        }

        // [Timer:X]
        if (StringUtil.startsWithIgnoreCase(text, timerTagStart) && text.endsWith("]")) {
            return readTimerProfile(text);
        }

        // [GroupName]
        if (text.startsWith("[") && text.endsWith("]")) {
            return new GroupProfileImpl(groupSystem, text.substring(1, text.length() - 1));
        }

        // +GroupName+
        if (text.startsWith("+") && text.endsWith("+")) {
            return new GroupLeaderProfileImpl(groupSystem, text.substring(1, text.length() - 1));
        }
    }

    return new PlayerProfileImpl(text, Optional.<UUID> absent());
}
 
開發者ID:rutgerkok,項目名稱:BlockLocker,代碼行數:41,代碼來源:ProfileFactoryImpl.java

示例13: onTabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd,
		String alias, String[] args) {
	ArrayList<String> matchedSubCommands = new ArrayList<String>();
	for (SubCommand command : BashMultiCommand.plugin.commandExecutor.commands
			.values().toArray(new SubCommand[0])) {
		if (StringUtil.startsWithIgnoreCase(command.toString(), args[0])
				|| args.length < 0) {
			matchedSubCommands.add(command.toString());
		}
	}

	Collections.sort(matchedSubCommands, String.CASE_INSENSITIVE_ORDER);
	return matchedSubCommands;
}
 
開發者ID:Tommsy64,項目名稱:Bash-Multi-Command,代碼行數:16,代碼來源:Help.java

示例14: tabComplete

import org.bukkit.util.StringUtil; //導入方法依賴的package包/類
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
    Validate.notNull(sender, "Sender cannot be null");
    Validate.notNull(args, "Arguments cannot be null");
    Validate.notNull(alias, "Alias cannot be null");

    if (args.length == 1) {
        return super.tabComplete(sender, alias, args);
    }
    if (args.length == 2) {
        final String arg = args[1];
        final List<String> materials = GiveCommand.materials;
        List<String> completion = null;

        final int size = materials.size();
        int i = Collections.binarySearch(materials, arg, String.CASE_INSENSITIVE_ORDER);

        if (i < 0) {
            // Insertion (start) index
            i = -1 - i;
        }

        for ( ; i < size; i++) {
            String material = materials.get(i);
            if (StringUtil.startsWithIgnoreCase(material, arg)) {
                if (completion == null) {
                    completion = new ArrayList<String>();
                }
                completion.add(material);
            } else {
                break;
            }
        }

        if (completion != null) {
            return completion;
        }
    }
    return ImmutableList.of();
}
 
開發者ID:AlmuraDev,項目名稱:Almura-API,代碼行數:41,代碼來源:GiveCommand.java


注:本文中的org.bukkit.util.StringUtil.startsWithIgnoreCase方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。