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