本文整理匯總了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;
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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());
}
示例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;
}
示例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();
}