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