当前位置: 首页>>代码示例>>Java>>正文


Java PlayerChatTabCompleteEvent.getLastToken方法代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerChatTabCompleteEvent.getLastToken方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerChatTabCompleteEvent.getLastToken方法的具体用法?Java PlayerChatTabCompleteEvent.getLastToken怎么用?Java PlayerChatTabCompleteEvent.getLastToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.player.PlayerChatTabCompleteEvent的用法示例。


在下文中一共展示了PlayerChatTabCompleteEvent.getLastToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tabCompleteChat

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入方法依赖的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: tabCompleteChat

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入方法依赖的package包/类
public List<String> tabCompleteChat(Player player, String message) {
    Player[] players = getOnlinePlayers();
    List<String> completions = new ArrayList<String>();
    PlayerChatTabCompleteEvent event = new PlayerChatTabCompleteEvent(player, message, completions);
    String token = event.getLastToken();
    for (Player p : players) {
        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:AlmuraDev,项目名称:Almura-Server,代码行数:24,代码来源:CraftServer.java

示例3: playerTabComplete

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void playerTabComplete(PlayerChatTabCompleteEvent event) {
	Collection <String> res = event.getTabCompletions();
	res.clear();
	String lower = event.getLastToken() != null ? event.getLastToken() : "";
	for(String player : MercuryAPI.getAllPlayers()) {
		if (player.toLowerCase().startsWith(lower)) {
			res.add(player);
		}
	}
}
 
开发者ID:Civcraft,项目名称:BetterShards,代码行数:12,代码来源:BetterShardsListener.java

示例4: tabCompleteChat

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入方法依赖的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

示例5: atTagTabComplete

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void atTagTabComplete(final PlayerChatTabCompleteEvent event) {
    final String message = event.getChatMessage();
    final String token = event.getLastToken();
    if (!message.equals(token) && !token.startsWith("@")) return;
    final String partialChannelTag = token.substring(1).toLowerCase();
    event.getTabCompletions().addAll(
        this.chatterbox.getAPI().getChannelAPI().getAllChannelTags().stream()
            .filter(tag -> tag.toLowerCase().startsWith(partialChannelTag))
            .map(tag -> "@" + tag)
            .collect(Collectors.toSet())
    );
}
 
开发者ID:Chatterbox,项目名称:Chatterbox,代码行数:14,代码来源:ChatterboxListener.java


注:本文中的org.bukkit.event.player.PlayerChatTabCompleteEvent.getLastToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。