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


Java PlayerChatTabCompleteEvent类代码示例

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


PlayerChatTabCompleteEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerChatTabCompleteEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: set

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@Override
public void set(Event event, String[] value) {
    if (event instanceof PlayerChatTabCompleteEvent) {
        Collection<String> completions = ((PlayerChatTabCompleteEvent) event).getTabCompletions();
        ArrayList<String> newcompletions = new ArrayList<String>(Arrays.asList(value));
        String[] completionsarray = completions.toArray(new String[0]);
        for (int i = 0; i < completionsarray.length; i++) {
            if (newcompletions.contains(completionsarray[i])) {
                newcompletions.remove(completionsarray[i]);
            } else {
                completions.remove(completionsarray[i]);
            }
        }
        for (int i = 0; i < newcompletions.size(); i++) {
            completions.add(newcompletions.get(i));
        }
    }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:19,代码来源:ExprCompletionsOld.java

示例3: set

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@Override
public void set(Event event, String[] value) {
    if (event instanceof PlayerChatTabCompleteEvent) {
        Collection<String> completions = ((PlayerChatTabCompleteEvent) event).getTabCompletions();
        ArrayList<String> newcompletions = new ArrayList<String>(Arrays.asList(value));
        String[] completionsarray = completions.toArray(new String[0]);
        for (int i = 0; i < completionsarray.length; i++) {
            if (newcompletions.contains(completionsarray[i])) {
                newcompletions.remove(completionsarray[i]);
            } else {
                completions.remove(completionsarray[i]);
            }
        }
        for (int i = 0; i < newcompletions.size(); i++) {
            completions.add(newcompletions.get(i));
        }
    } else if (event instanceof TabCompleteEvent) {
        ((TabCompleteEvent) event).setCompletions(Arrays.asList(value));
    }
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:21,代码来源:ExprCompletions.java

示例4: 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

示例5: onPlayerTabComplete

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerTabComplete(PlayerChatTabCompleteEvent event) {
	List<String> results = new ArrayList<String>();
	if (event.getLastToken().startsWith("@")) {
		for (Player p: getServer().getOnlinePlayers()) {
			if (p.getName().toLowerCase().startsWith(event.getLastToken().substring(1).toLowerCase())
					&& !event.getPlayer().getName().equals(p.getName()) && event.getPlayer().canSee(p)) {
				results.add("@" + p.getName());
			}
		}
	} else if (event.getLastToken().startsWith("#") && event.getChatMessage().equals(event.getLastToken())) {
		for (Channel c: channelManager.getPlayerChannels(event.getPlayer())) {
			if (c.getName().toLowerCase().startsWith(event.getLastToken().substring(1).toLowerCase())) {
				results.add("#" + c.getName());
			}
		}
	}
	event.getTabCompletions().clear();
	event.getTabCompletions().addAll(results);
}
 
开发者ID:ulchm,项目名称:RedisChat,代码行数:21,代码来源:RedisChat.java

示例6: onTabComplete

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
/**
 * Adds autocompletion for spectators even if the player can't see them.
 */
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTabComplete(PlayerChatTabCompleteEvent ev)
{
	if ((Toggles.AUTOCOMPLETE_SPECTATORS_FOR_PLAYERS.get() && !SpectatorPlus.get().getPlayerData(ev.getPlayer()).isSpectating()) || Toggles.AUTOCOMPLETE_SPECTATORS_FOR_SPECTATORS.get())
	{
		final String lowerCaseLastToken = ev.getLastToken().toLowerCase();

		for (Player player : Bukkit.getOnlinePlayers())
		{
			if (SpectatorPlus.get().getPlayerData(player).isSpectating() && !ev.getTabCompletions().contains(player.getName()))
			{
				if (player.getName().toLowerCase().startsWith(lowerCaseLastToken))
				{
					ev.getTabCompletions().add(player.getName());
				}
			}
		}
	}
}
 
开发者ID:pgmann,项目名称:SpectatorPlus,代码行数:23,代码来源:SpectatorsChatListener.java

示例7: onTabList

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@EventHandler
public void onTabList(PlayerChatTabCompleteEvent event) {
	/*for (String s : event.getTabCompletions()) {
		Player ap = PlayerUtil.getPlayer(s);
		if (ap == null)
			continue;
		if (!event.getPlayer().canSee(ap))
			event.getTabCompletions().remove(s);
	}*/
	event.getTabCompletions().add("@everyone");
}
 
开发者ID:GigaGamma,项目名称:McLink,代码行数:12,代码来源:Chat.java

示例8: get

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@Override
protected String[] get(Event event) {
    if (event instanceof PlayerChatTabCompleteEvent) {
        return ((PlayerChatTabCompleteEvent) event).getTabCompletions().toArray(new String[0]);
    }
    return new String[0];
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:8,代码来源:ExprCompletionsOld.java

示例9: subInit

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@Override
public boolean subInit(Expression<?>[] expression, int matchedPattern, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
    if (!ScriptLoader.isCurrentEvent(PlayerChatTabCompleteEvent.class)) {
        Skript.error("The 'completions' expression can only be used in the 'on chat tab complete' event!");
        return false;
    }
    return true;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:9,代码来源:ExprCompletionsOld.java

示例10: get

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@Override
protected String[] get(Event event) {
    if (event instanceof PlayerChatTabCompleteEvent) {
        return new String[]{((PlayerChatTabCompleteEvent) event).getLastToken()};
    }
    return null;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:8,代码来源:ExprLastTokenOld.java

示例11: init

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@Override
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
    if (!ScriptLoader.isCurrentEvent(PlayerChatTabCompleteEvent.class)) {
        Skript.error("The 'last token' expression can only be used in the 'on chat tab complete' event!");
        return false;
    }
    return true;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:9,代码来源:ExprLastTokenOld.java

示例12: get

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@Override
protected String[] get(Event event) {
    if (event instanceof PlayerChatTabCompleteEvent) {
        return new String[]{((PlayerChatTabCompleteEvent) event).getLastToken()};
    } else if (event instanceof TabCompleteEvent) {
        String buffer = ((TabCompleteEvent) event).getBuffer();
        if (buffer.endsWith(" ")) {
            return new String[]{""};
        }
        String[] tokens = buffer.split(" ");
        return new String[]{tokens[tokens.length - 1]};
    }
    return null;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:15,代码来源:ExprLastToken.java

示例13: init

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@Override
public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
    if (!ScriptLoader.isCurrentEvent(PlayerChatTabCompleteEvent.class) && !ScriptLoader.isCurrentEvent(TabCompleteEvent.class)) {
        Skript.error("The 'last token' expression can only be used in the 'on chat tab complete' event and the 'on tab complete' event!");
        return false;
    }
    return true;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:9,代码来源:ExprLastToken.java

示例14: get

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@Override
protected String[] get(Event event) {
    if (event instanceof PlayerChatTabCompleteEvent) {
        return ((PlayerChatTabCompleteEvent) event).getTabCompletions().toArray(new String[0]);
    } else if (event instanceof TabCompleteEvent) {
        return ((TabCompleteEvent) event).getCompletions().toArray(new String[0]);
    }
    return new String[0];
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:10,代码来源:ExprCompletions.java

示例15: subInit

import org.bukkit.event.player.PlayerChatTabCompleteEvent; //导入依赖的package包/类
@Override
public boolean subInit(Expression<?>[] expression, int matchedPattern, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
    if (!ScriptLoader.isCurrentEvent(PlayerChatTabCompleteEvent.class) && !ScriptLoader.isCurrentEvent(TabCompleteEvent.class)) {
        Skript.error("The 'completions' expression can only be used in the 'on chat tab complete' event or the 'on tab complete' event!");
        return false;
    }
    return true;
}
 
开发者ID:MundoSK,项目名称:MundoSK,代码行数:9,代码来源:ExprCompletions.java


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