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; }
@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)); } } }
@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)); } }
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; }
@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); }
/** * 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()); } } } } }
@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"); }
@Override protected String[] get(Event event) { if (event instanceof PlayerChatTabCompleteEvent) { return ((PlayerChatTabCompleteEvent) event).getTabCompletions().toArray(new String[0]); } return new String[0]; }
@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; }
@Override protected String[] get(Event event) { if (event instanceof PlayerChatTabCompleteEvent) { return new String[]{((PlayerChatTabCompleteEvent) event).getLastToken()}; } return null; }
@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; }
@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; }
@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; }
@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]; }
@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; }
public static boolean complete(PlayerChatTabCompleteEvent e) { if (!e.getChatMessage().startsWith("@")) return false; if (e.getChatMessage().contains(" ")) return false; String message = e.getChatMessage().split(" ")[0].substring(1).trim(); List<String> list = new ArrayList<>(); Bukkit.getOnlinePlayers().forEach((p) -> { if (p.getName().toLowerCase().contains(message.toLowerCase())) list.add("@" + p.getName()); }); e.getTabCompletions().clear(); e.getTabCompletions().addAll(list); return true; }
@EventHandler public void TabCompleteEvent(PlayerChatTabCompleteEvent e) { String[] Args = e.getChatMessage().split(" "); Player Player2 = e.getPlayer(); if (Args[0].startsWith(".") && Args[0].substring(1, 2).equalsIgnoreCase("/")) { return; } if (Args.length > 1 && (Args[0].startsWith(".") || Args[0].startsWith("-") || Args[0].startsWith("#") || Args[0].startsWith("*"))) { if (this.TabComplete.containsKey(Player2.getUniqueId()) && System.currentTimeMillis() < this.TabComplete.get(Player2.getUniqueId()) + 1000) { return; } this.getJanitor().logCheat(this, Player2, null, e.getChatMessage()); this.TabComplete.put(Player2.getUniqueId(), System.currentTimeMillis()); } }
@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); } } }
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; }
@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()) ); }
@EventHandler public void onTabComplete(PlayerChatTabCompleteEvent event) { String uncomplete = event.getChatMessage(); if (uncomplete.contains("@") && !uncomplete.endsWith(" ")) { List<Player> allplayers = new ArrayList<Player>(); allplayers.addAll(Arrays.asList(Bukkit.getServer() .getOnlinePlayers())); String at = uncomplete.substring(uncomplete.lastIndexOf("@") + 1); List<String> fit = new ArrayList<String>(); for (Player p : allplayers) { if (p.getName().toLowerCase().startsWith(at.toLowerCase())) { if (uncomplete.contains(" ")) { fit.add(uncomplete.substring( uncomplete.lastIndexOf(" ") + 1, uncomplete.lastIndexOf("@")) + "@" + p.getName()); // event.getPlayer().sendMessage(ChatColor.RED+event.getTabCompletions().toString()+ChatColor.GREEN+event.getLastToken()); } else { fit.add(uncomplete.substring(0, uncomplete.lastIndexOf("@")) + "@" + p.getName()); // event.getPlayer().sendMessage(ChatColor.RED+event.getTabCompletions().toString()+ChatColor.GREEN+event.getLastToken()); } } } event.getTabCompletions().clear(); event.getTabCompletions().addAll(fit); // event.getPlayer().sendMessage(ChatColor.RED+event.getTabCompletions().toString()+ChatColor.GREEN+event.getLastToken()); } }
@EventHandler public void tabcomplete(PlayerChatTabCompleteEvent e) { TregminePlayer p = plugin.getPlayer(e.getPlayer()); if (p.getRank().canGetTrueTab()) { return; } e.getTabCompletions().clear(); String[] args = e.getChatMessage().split(" "); if (args.length == 0) { return; } List<String> nonOps = new ArrayList<String>(); List<String> result = new ArrayList<String>(); for (TregminePlayer player : plugin.getOnlinePlayers()) { if (!player.hasFlag(TregminePlayer.Flags.INVISIBLE)) { nonOps.add(player.getName()); } } for (String name : nonOps) { if (name.toLowerCase().startsWith(args[args.length - 1].toLowerCase())) { result.add(name); } } e.getTabCompletions().addAll(result); }
@EventHandler public void onTabComplete(PlayerChatTabCompleteEvent e) { e.getTabCompletions().clear(); for(XOfflinePlayer off : pl.getManagers().getPlayerManager().getOfflinePlayers()) { if(off.getName().toUpperCase().startsWith(e.getLastToken().toUpperCase())) { e.getTabCompletions().add(off.getName()); } } }
@EventHandler(priority = EventPriority.LOW) public void onTab(PlayerChatTabCompleteEvent event) { if (!plugin.getCore().isInputtingKorean(event.getPlayer().getUniqueId()) && plugin.getCore().useTab && event.getPlayer().hasPermission("inteliautomatabukkit.tab")) { event.getTabCompletions().add(InteliAutomata.convert(event.getLastToken())); } }