@Override public void call(Event event) { final Player player = profile.getPlayer(); if (event instanceof PlayerMoveEvent) { if ((player.isSprinting() || player.isBlocking() || player.isConversing()) && player.isSneaking()) { callback(true); return; } callback(false); } else if (event instanceof AsyncPlayerChatEvent) { if ((player.isBlocking() || player.isSprinting() || player.isSneaking())) { callback(true); return; } callback(false); } }
@EventHandler public void handle(AsyncPlayerChatEvent e) { PermissionGroup permissionGroup = permissionService ? CloudServer.getInstance() .getCachedPlayer(e.getPlayer().getUniqueId()).getPermissionEntity().getHighestPermissionGroup(CloudAPI.getInstance().getPermissionPool()) : null; e.setFormat( ChatPlugin.getPlugin(ChatPlugin.class).getConfig().getString("format") .replace("%display%", ChatColor.translateAlternateColorCodes('&', (permissionService ? permissionGroup.getDisplay() : ""))) .replace("%prefix%", ChatColor.translateAlternateColorCodes('&', (permissionService ? permissionGroup.getPrefix() : ""))) .replace("%group%", (permissionService ? permissionGroup.getName() : "")) .replace("%player%", e.getPlayer().getName()) .replace("%message%", e.getPlayer().hasPermission("cloudnet.chat.color") ? ChatColor.translateAlternateColorCodes('&', e.getMessage()) : e.getMessage()) ); }
@EventHandler(priority = EventPriority.HIGHEST) public void onChatHighPriority(AsyncPlayerChatEvent event) { PlayerContext playerContext = TGM.get().getPlayerManager().getPlayerContext(event.getPlayer()); if (!event.isCancelled()) { Bukkit.getOnlinePlayers().forEach(player -> { TextComponent message = new TextComponent(event.getFormat().replaceAll("%%", "%")); BaseComponent[] stats = new BaseComponent[]{new TextComponent(ChatColor.AQUA + "Level: " + playerContext.getLevelString().replace("[", "").replace("]", "")), new TextComponent("\n"), new TextComponent("\n" + ChatColor.AQUA + "Kills: " + ChatColor.RESET + playerContext.getUserProfile().getKills()), new TextComponent("\n" + ChatColor.AQUA + "Deaths: " + ChatColor.RESET + playerContext.getUserProfile().getDeaths()), new TextComponent("\n" + ChatColor.AQUA + "K/D: " + ChatColor.RESET + playerContext.getUserProfile().getKDR()), new TextComponent("\n"), new TextComponent("\n" + ChatColor.AQUA + "Wins: " + ChatColor.RESET + playerContext.getUserProfile().getWins()), new TextComponent("\n" + ChatColor.AQUA + "Losses: " + ChatColor.RESET + playerContext.getUserProfile().getLosses()), new TextComponent("\n" + ChatColor.AQUA + "W/L: " + ChatColor.RESET + playerContext.getUserProfile().getWLR())}; message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, stats)); player.spigot().sendMessage(message); }); Bukkit.getConsoleSender().sendMessage(event.getFormat().replace("%%", "%")); } event.setCancelled(true); }
@EventHandler(priority = EventPriority.HIGH) public void ChatCheckCrash(AsyncPlayerChatEvent event){ if (!ConfigPatch.noCrashChat) return; Player player = event.getPlayer(); String message = event.getMessage(); if(message.contains("İ")){ event.setCancelled(true); AzureAPI.log(player, ConfigPatch.AntiCrashChatSpecialStringWarnMessage); } if(HasEss == true){ if(message.contains("&")){ event.setCancelled(true); AzureAPI.log(player, ConfigPatch.AntiCrashChatSpecialStringWarnMessage); } } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void spamChecker(AsyncPlayerChatEvent evt) { if (!ConfigFunction.AntiSpamenable) return; Player player = evt.getPlayer(); if (AzureAPI.hasPerm(player, "EscapeLag.bypass.Spam")) { return; } long now = System.currentTimeMillis(); if (isSpamming(player, now)) { evt.setCancelled(true); AzureAPI.log(player, ConfigFunction.AntiSpamPeriodWarnMessage); } else { timeRecord.put(player, now); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void checkDirty(AsyncPlayerChatEvent evt) { if (ConfigFunction.AntiSpamenable && ConfigFunction.enableAntiDirty) { Player player = evt.getPlayer(); String message = evt.getMessage().toLowerCase(); if (AzureAPI.hasPerm(player, "EscapeLag.bypass.Spam")) { return; } for (String each : ConfigFunction.AntiSpamDirtyList) { boolean deny = true; for (char c : each.toLowerCase().toCharArray()) { if (!StringUtils.contains(message, c)) deny = false; } if (deny) { evt.setCancelled(true); AzureAPI.log(player, ConfigFunction.AntiSpamDirtyWarnMessage); } } } }
@EventHandler public void onPlayerChat(AsyncPlayerChatEvent event) { //event.getRecipients().clear(); if (!chatTimes.containsKey(event.getPlayer().getName())) { chatTimes.put(event.getPlayer().getName(), new Date()); return; } if (Gamer.get(event.getPlayer()).getRank().getLevel() >= 5) return; Date now = new Date(); Date before = chatTimes.get(event.getPlayer().getName()); if (now.getTime() - before.getTime() < 5000) { Chat.player(event.getPlayer(), "&cPlease wait 5 seconds between sending messages."); event.getRecipients().clear(); event.setCancelled(true); return; } chatTimes.put(event.getPlayer().getName(), now); }
@EventHandler public void onPlayerChat(AsyncPlayerChatEvent event) { Player p = event.getPlayer(); Gamer g = Hive.getInstance().getGamer(p); String prefix = ""; String name = p.getName(); String msg = event.getMessage(); if (g.getRank() != null) prefix = g.getRank().getType().getPrefix(); String result = Chat.colors(prefix + "&7" + name + "&f: ") + msg; if (g.getRank().getType().getLevel() >= 5) result = Chat.colors(result); // Symbol % has formatting issues event.setFormat(result.replace("%", "%%")); }
@EventHandler public void onChat(AsyncPlayerChatEvent event){ if(plugin.getConfig().getString("chatformat").equals("true")){ Player player = event.getPlayer(); String message = event.getMessage(); event.setCancelled(true); String playerNameWithPrefixSuffix = player.getName() + ": "; try { playerNameWithPrefixSuffix = ChatColor.translateAlternateColorCodes('&', (!RankManager.getRankPrefix(player).equals(" ")?RankManager.getRankPrefix(player) : "") + RankManager.getRankNameColor(player) +" "+ player.getName() +(!RankManager.getRankSuffix(player).equals(" ")? " "+ RankManager.getRankSuffix(player) : "") + ChatColor.GRAY + ": "); } catch (SQLException e) { e.printStackTrace(); } for(Player p : event.getRecipients()){ p.sendMessage(playerNameWithPrefixSuffix + ChatColor.WHITE + message); } } }
@EventHandler(priority = EventPriority.LOW) // Filter should happen after commands. public void onChat(AsyncPlayerChatEvent evt) { // Handle mutes. KCPlayer pw = KCPlayer.getWrapper(evt.getPlayer()); if (pw.isMuted() && !evt.isCancelled()) { evt.setCancelled(true); evt.getPlayer().sendMessage(ChatColor.RED + "You are muted for " + pw.getMute().untilExpiry()+ "."); evt.getPlayer().sendMessage(ChatColor.RED + "Reason: " + ChatColor.YELLOW + pw.getMute().getReason()); evt.getPlayer().sendMessage(ChatColor.RED + "Source: " + ChatColor.YELLOW + pw.getMute().getSource()); return; } evt.setMessage(applyAllFilters(evt.getPlayer(), evt.getMessage())); // Apply all filters. evt.setFormat(KCPlayer.getWrapper(evt.getPlayer()).getDisplayPrefix() + " %s:" + ChatColor.WHITE + " %s"); // Handle ignored players. if (!pw.getRank().isStaff()) new ArrayList<>(evt.getRecipients()).stream() .filter(p -> KCPlayer.getWrapper(p).getIgnored().containsIgnoreCase(evt.getPlayer().getName())) .forEach(evt.getRecipients()::remove); }
@EventHandler(priority = EventPriority.HIGH) void onChat(AsyncPlayerChatEvent event) { if (!event.getPlayer().hasPermission("emojichat.use") || !event.getPlayer().hasPermission("emojichat.use.chat")) return; // Don't do anything if they don't have permission String message = event.getMessage(); // Checks if the user disabled shortcuts via /emojichat toggle if (!plugin.getEmojiHandler().hasShortcutsOff(event.getPlayer())) { message = plugin.getEmojiHandler().translateShorthand(message); } // Replace shortcuts with emojis message = plugin.getEmojiHandler().toEmojiFromChat(message); // If the message contains a disabled character if (plugin.getEmojiHandler().containsDisabledCharacter(message)) { event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.RED + "Oops! You can't use disabled emoji characters!"); return; } event.setMessage(message); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onChat(AsyncPlayerChatEvent e) { // 忽略OP Player p = e.getPlayer(); if (p.isOp()) { return; } // 忽略免检权限 if (p.hasPermission("neverlag.bypass.cooldown.chat")) { return; } // 判断间隔时间 String username = p.getName(); long now = System.currentTimeMillis(); Long lastChatTime; if ((lastChatTime = chatCoolDown.get(username)) != null) { long remain = cm.commandCooldownTime - (now - lastChatTime); if (remain > 0) { e.setCancelled(true); p.sendMessage(i18n.tr("chat", Math.ceil(remain / 1000))); return; } } chatCoolDown.put(username, now); }
@EventHandler public void onPrivateTag(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); boolean enablation = config.getBoolean("enable.private-messenger"); String message = event.getMessage(); if (!(Main.chatHoldOn(player, "")) && enablation && message.startsWith("@")) { event.setCancelled(true); if (!(player.hasPermission("chatassets.msg"))) { Main.sendMessage(Main.noPermError("chat privately!"), player); } else { List<String> messagewords = new ArrayList<String>(); for (String x : message.split(" ")) { messagewords.add(x); } String targetname = messagewords.get(0).substring(1); Player target = Bukkit.getPlayer(targetname); if (target == null) { Main.sendMessage(ChatColor.RED + "Player cannot be found!", player); } else { messagewords.remove(0); target.sendMessage("[" + player.getDisplayName() + " -> You] " + AntiCurse.replaceBadWords(ChatAutoModifier.autoModifyString(String.join(" ", messagewords)))); player.sendMessage("[You -> " + target.getDisplayName() + "] " + AntiCurse.replaceBadWords(ChatAutoModifier.autoModifyString(String.join(" ", messagewords)))); } } } }
@EventHandler public void onPlayerChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); boolean enablation = config.getBoolean("enable.anticasespam"); String message = event.getMessage(); if (!(Main.chatHoldOn(player, "")) && enablation && (getUpperCases(message) > getMaxUpperCases())) { if (!(player.hasPermission("chatassets.anticasespam.bypass"))) { if (autolowercase) { event.setMessage(message.toLowerCase()); Main.sendMessage(ChatColor.YELLOW + "Your message is lower cased becuase the original amount of upper cased characters is beyond the maximum.", player); } else { event.setCancelled(true); Main.sendMessage(ChatColor.YELLOW + "Your message is blocked becuase the original amount of upper cased characters is beyond the maximum.", player); } } } }
@EventHandler public void setLine(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); String line = event.getMessage(); if (Commander.setjoinmessage.contains(player) || Commander.setquitmessage.contains(player) || Commander.setmotd.contains(player)) { if (!(Main.chatHoldOn(player, "setjoinmessage"))) { event.setCancelled(true); Commander.joinmessages.add(line); Main.sendMessage(line + ChatColor.GREEN + " has been added. " + ChatColor.YELLOW + "To stop adding lines to player join message, issue /chatassets loghandler done", player); } else if (!(Main.chatHoldOn(player, "setquitmessage"))) { event.setCancelled(true); Commander.quitmessages.add(line); Main.sendMessage(line + ChatColor.GREEN + " has been added. " + ChatColor.YELLOW + "To stop adding lines to player quit message, issue /chatassets loghandler done", player); } else if (!(Main.chatHoldOn(player, "setmotd"))) { event.setCancelled(true); Commander.motd.add(line); Main.sendMessage(line + ChatColor.GREEN + " has been added. " + ChatColor.YELLOW + "To stop adding lines to motd on join, issue /chatassets loghandler done", player); } } }
@EventHandler public void onPlayerChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); String message = event.getMessage(); if (!(Main.chatHoldOn(player, "addshortenmessagelist"))) { if (Commander.addshortenmessagelist.contains(player)) { event.setCancelled(true); Commander.addshortenmessagemessage = message; String addmessage = message, addkey = Commander.addshortenmessagekey; Commander.addshortenmessagelist.remove(player); setMessage(addkey, addmessage, true); Main.sendMessage(ChatColor.GREEN + "You have successfully added a new shorten message!", player); player.sendMessage("Key: " + Main.colorcode(addkey)); player.sendMessage("Message: " + Main.colorcode(addmessage)); } else { if (player.hasPermission("chatassets.messageshortener.use")) { event.setMessage(Main.colorcode(replaceKey(message))); } } } String output = String.join(" ", messagewords); return output; }
@EventHandler public void onChat(AsyncPlayerChatEvent e){ Player p = e.getPlayer(); if(PlayerManager.confirmationReady.contains(p)){ String message = e.getMessage(); if(message == null) return; String rep = UltimateTs.main().getConfig().getString("config.yesReponse"); if(rep == null) rep = "YES"; if(message.equalsIgnoreCase(rep.toString())){ BotManager.getBot().editClient(PlayerManager.convertDatabaseIdToClientId(PlayerManager.getLinkedWithDbId(p)), Collections.singletonMap(ClientProperty.CLIENT_DESCRIPTION, "")); p.sendMessage(UltimateTs.messages.getString("messages.unlinked.confirmation.yes").replace('&', '�')); PlayerManager.unlink(p); }else{ p.sendMessage(UltimateTs.messages.getString("messages.unlinked.confirmation.no").replace('&', '�')); } PlayerManager.confirmationReady.remove(p); e.setCancelled(true); } }
@SuppressWarnings( "deprecation" ) @Override public void handle( ConnectionHandler connectionHandler, MessageC02ChatMessage message ) { FlexPlayer player = connectionHandler.getPlayer(); if( player != null && message.getMessage().length() < 256 ) { if( message.getMessage().startsWith( "/" ) ) { String commandLine = message.getMessage().length() == 1 ? "" : message.getMessage().substring( 1 ); if( !Flex.getServer().getCommandMap().dispatch( player, commandLine ) ) { player.sendMessage( "Unknown command. Type /help for help" ); } return; } PlayerChatEvent oldEvent = EventFactory.call( new PlayerChatEvent( player, message.getMessage(), "<%1$s> %2$s", new HashSet<>( Flex.getServer().getPlayerManager().getOnlinePlayers() ) ) ); AsyncPlayerChatEvent event = new AsyncPlayerChatEvent( true, player, oldEvent.getMessage(), oldEvent.getRecipients() ); event.setFormat( oldEvent.getFormat() ); EventFactory.call( event ); if( !event.isCancelled() ) { for( Player target : event.getRecipients() ) { if( target.isOnline() ) { target.sendMessage( String.format( event.getFormat(), player.getDisplayName(), message.getMessage() ) ); } } } } }
@EventHandler public void onChat(AsyncPlayerChatEvent event) { event.setCancelled(true); Player player = event.getPlayer(); String message = event.getMessage(); String playerNameWithPrefixSuffix = ChatColor.RED + "(ERROR FORMATTING NAME) " + ChatColor.WHITE + player.getName() + ": "; try { if (RankManager.isPrisoner(player)) { RankManager.updateWantedLevel(player); } else if (RankManager.isGuard(player) || RankManager.isWarden(player)) { RankManager.setWantedLevel(player, 0); } playerNameWithPrefixSuffix = ChatColor.translateAlternateColorCodes('&', (!RankManager.getRankPrefix(player).equals(" ") ? RankManager.getRankPrefix(player) : "") + ChatColor.GRAY + RankManager.wantedLevelParser(RankManager.getWantedLevel(player)) + ChatColor.GOLD + RankManager.guardLevelParser(RankManager.getGuardLevel(player)) + RankManager.getRankNameColor(player) + " " + player.getName() + (!RankManager.getRankSuffix(player).equals(" ") ? " " + RankManager.getRankSuffix(player) : "") + ChatColor.GRAY + ": "); } catch (SQLException e) { e.printStackTrace(); } for (Player p : event.getRecipients()) { p.sendMessage(playerNameWithPrefixSuffix + ChatColor.WHITE + message); } }
@EventHandler public void onChat(AsyncPlayerChatEvent e) { if(e.getMessage().contains(".meep")) { e.getPlayer().sendMessage("Meep!"); for(Connection con : PocketCon.getPocketConnections()) { e.getPlayer().sendMessage("MEEEEEP!!"); PocketCon.sendModal(con, new SimpleForm("hoi", "hallo") .addButton(new ModalButton("Magbot").setImage(new ModalImage(ModalImageType.EXTERNAL_IMAGE, "http://magbot.nl/img/MagBot.png"))) .addButton(new ModalButton("Awesome").setImage(new ModalImage(ModalImageType.EXTERNAL_IMAGE, "http://yumamom.com/wp-content/uploads/2015/05/LEGO.jpg"))), new SimpleFormCallback() { @Override public void onSimpleFormResponse(Player player, String modalJSON, boolean isClosedByClient, int clickedButton) { player.sendMessage("Thanks for clicking! :wave:"); } }); } } }
/** * Spectator's chat * * @param event Event */ @EventHandler(ignoreCancelled = true) public void onPlayerChat(AsyncPlayerChatEvent event) { if (SamaGamesAPI.get().getGameManager().getGame() == null) return; else if (!SamaGamesAPI.get().getGameManager().getGame().getStatus().equals(Status.IN_GAME)) return; else if (!SamaGamesAPI.get().getGameManager().getGame().isSpectator(event.getPlayer())) return; else if (SamaGamesAPI.get().getGameManager().getGame().isModerator(event.getPlayer())) return; event.setCancelled(true); String finalMessage = ChatColor.GRAY + "[Spectateur] " + event.getPlayer().getName() + ": " + event.getMessage(); SamaGamesAPI.get().getGameManager().getGame().getSpectatorPlayers().values().stream().filter(spectator -> ((GamePlayer) spectator).getPlayerIfOnline() != null).forEach(spectator -> ((GamePlayer) spectator).getPlayerIfOnline().sendMessage(finalMessage)); Bukkit.getOnlinePlayers().stream().filter(player -> !SamaGamesAPI.get().getGameManager().getGame().hasPlayer(player)).forEach(player -> player.sendMessage(finalMessage)); }
public void forFormat(AsyncPlayerChatEvent e) { String format = ""; e.setFormat(format); /* * * Add the following to the parser: * {PLAYERNAME} * {DISPLAYNAME} * {RANK} * {BALANCE} (This will be implemented later) * {DATE} * {TIME} * {RANKLADDER} * */ }
/** * Intercept chat and apply changes. * 1. Limit messages to the current world, so they don't across arenas or the hub * 2. Apply team color to names if applicable */ @EventHandler public void onPlayerChat(AsyncPlayerChatEvent event) { event.setCancelled(true); String tag; Team team = PlayerUtil.getTeamForPlayer(plugin.getArenaHandler(), event.getPlayer()); if (team != null) { tag = String.format("<%s%s%s> ", team.getChatColor(), event.getPlayer().getName(), ChatColor.RESET); } else { tag = String.format("<%s%s%s> ", ChatColor.GRAY, event.getPlayer().getName(), ChatColor.RESET); } for (Player player : event.getPlayer().getWorld().getPlayers()) { player.sendMessage(tag + event.getMessage()); } }
/** Send a message from a channel as player. * @param sender {@code Player} * @param message {@code FancyMessage} - Message to send. * @param direct {@code boolean} - Send message direct to players on channel. */ public void sendMessage(Player sender, UltimateFancy message, boolean direct){ if (direct){ for (Player p:Bukkit.getOnlinePlayers()){ UCChannel chp = UChat.get().getPlayerChannel(p); if (UCPerms.channelReadPerm(p, this) && !this.isIgnoring(p.getName()) && (!this.neeFocus() || chp.equals(this))){ UChat.get().getUCLogger().timings(timingType.START, "UCChannel#sendMessage()|Direct Message"); message.send(p); } } message.send(sender); } else { Set<Player> pls = new HashSet<>(Bukkit.getOnlinePlayers()); UChat.get().tempChannels.put(sender.getName(), this.getAlias()); AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(true, sender, message.toOldFormat(), pls); Bukkit.getScheduler().runTaskAsynchronously(UChat.get(), () -> { UChat.get().getUCLogger().timings(timingType.START, "UCChannel#sendMessage()|Fire AsyncPlayerChatEvent"); UChat.get().getServer().getPluginManager().callEvent(event); }); } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(player.getLocation()); String prefix = regions.queryValue(WorldGuardUtils.wrapPlayer(player), FlagUtils.CHAT_PREFIX); //Not sure should we add bypass for this String suffix = regions.queryValue(WorldGuardUtils.wrapPlayer(player), FlagUtils.CHAT_SUFFIX); //Not sure should we add bypass for this if (prefix != null) { event.setFormat(prefix + event.getFormat()); } if (suffix != null) { event.setFormat(event.getFormat() + suffix); } }
public static boolean check(AsyncPlayerChatEvent e) { if (!e.getMessage().startsWith("@")) { return false; } boolean useReason = e.getMessage().contains(" "); String checked = useReason ? e.getMessage().split(" ")[0].substring(1) : e.getMessage().substring(1); Player p = Bukkit.getPlayer(checked); Messager.sendCenterMessage(p, "§c§l" + ChatColor.stripColor(e.getPlayer().getDisplayName()) + "§e님이 당신을 호출했습니다."); if (useReason) Messager.sendCenterMessage( p, "§a호출 사유: " + e.getMessage() .replaceFirst(e.getMessage().split(" ")[0], "").trim()); p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1.0f, 1.0f); e.setCancelled(true); return true; }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { if (event.isCancelled()) { return; } ArcadePlayer player = this.game.getPlugin().getPlayer(event.getPlayer()); ChatChannel channel = this.game.getChannel(player); if (!player.getChatState().chat()) { player.sendError("You may not chat because your chat is disabled."); event.setCancelled(true); return; } String message = event.getMessage(); if (message.startsWith(GlobalChatChannel.GLOBAL_CHANNEL_KEY)) { // global channel = this.game.getGlobalChannel(); message = message.substring(1); } channel.sendChatMessage(player, message.trim()); event.setCancelled(true); // this breaks other plugins :/ }
@Override public boolean onPlayerChat(AsyncPlayerChatEvent event, BPPlayer bpPlayer) { CTFProperties props = (CTFProperties) bpPlayer.getGameProperties(); Team team = props.getTeam(); if(team != null) { String message = event.getMessage(); if(message.charAt(0) == '@') { CTFGame game = getGame(); Player player = bpPlayer.getPlayer(); event.setCancelled(true); String playerName = player.getName(); game.sendTeamMessage(playerName, message, team); Breakpoint.info("Team chat: " + playerName + ": " + message); return false; } } return true; }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void AnniPlayersInit(AsyncPlayerChatEvent event) { if(event.isAsynchronous()) { AnniPlayer p = AnniPlayer.getPlayer(event.getPlayer().getUniqueId()); if(p.getTeam() == null) event.setFormat(g+"(All) ["+ChatColor.DARK_PURPLE+"Lobby"+g+"] %s"+ChatColor.WHITE+": %s"); else if(event.getMessage().startsWith("!")) { event.setMessage(event.getMessage().substring(1)); event.setFormat(g+"(All) ["+p.getTeam().getColor()+p.getTeam().toString()+g+"] %s"+ChatColor.WHITE+": %s"); } else { event.setFormat(g+"(Team) ["+p.getTeam().getColor()+p.getTeam().toString()+g+"] %s"+ChatColor.WHITE+": %s"); event.getRecipients().clear(); for(AnniPlayer pl : p.getTeam().getPlayers()) if(pl.isOnline()) event.getRecipients().add(pl.getPlayer()); } } }
@EventHandler public void onChat(AsyncPlayerChatEvent e) { if (e.isCancelled()) { return; } if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getChatTitle()) { //if no, check worlds if (!QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getWorlds() .contains(e.getPlayer().getWorld().getName())) { return; } } QuestPlayer qp = QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(e.getPlayer()); if (qp.getTitle() == null || qp.getTitle().trim().isEmpty() || qp.getTitle().trim().equalsIgnoreCase("The Unknown")) { return; } String msg = "[" + qp.getTitle() + "] " + e.getMessage(); e.setMessage(msg); }
@EventHandler(priority = EventPriority.HIGHEST) public void chat(AsyncPlayerChatEvent e) { if (Vars.adminChat.contains(e.getPlayer()) || e.getMessage().startsWith(",") && e.getPlayer().hasPermission("izenith.adminchat") && (e.getMessage().length() != 1)) { e.setCancelled(true); Util.sendAdminMessage(e.getMessage().startsWith(",") ? e.getMessage().substring(1) : e.getMessage(), e.getPlayer()); return; } try { if (!e.isCancelled()) { e.setCancelled(true); IPlayerHandler.getPlayer(e.getPlayer()).sendChatMessage(e.getMessage()); } } catch (Exception ex) { ex.printStackTrace(); } }
@EventHandler(priority = EventPriority.LOWEST) public void onReply(AsyncPlayerChatEvent event) { if (event.isCancelled()) return; if (!event.getPlayer().equals(player)) return; String message = event.getMessage().trim(); for (int i : options.keySet()) { if (message.equals(Integer.toString(i))) { player.sendMessage(replace(answerFormat + options.get(i))); conv.passPlayerAnswer(i); event.setCancelled(true); return; } } new BukkitRunnable() { @Override public void run() { display(); } }.runTask(BetonQuest.getInstance()); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerInteractEntity(AsyncPlayerChatEvent event) { Set<Player> recipients = event.getRecipients(); Iterator<Player> iter = recipients.iterator(); while (iter.hasNext()) { Player player = iter.next(); if (player.equals(event.getPlayer())) continue; FawePlayer<Object> fp = FawePlayer.wrap(player); if (!fp.hasMeta()) continue; CFICommands.CFISettings settings = fp.getMeta("CFISettings"); if (settings == null || !settings.hasGenerator()) continue; String name = player.getName().toLowerCase(); if (!event.getMessage().toLowerCase().contains(name)) { ArrayDeque<String> buffered = fp.getMeta("CFIBufferedMessages"); if (buffered == null) fp.setMeta("CFIBufferedMessaged", buffered = new ArrayDeque<String>()); String full = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); buffered.add(full); iter.remove(); } } }
protected void handleEvent(AsyncPlayerChatEvent event) { // The global mute takes power over the player mute, so the order of these events matter. SilenceData data = ChatSilencer.this.globalMuteData; SilenceData playerData = null; if (data == null) { data = playerData = ChatSilencer.this.silenced.get(event.getPlayer()); } if (data != null) { if (check(data)) { event.setCancelled(true); if (data.muteMessage != null) { event.getPlayer().sendMessage(data.muteMessage); } } else if (playerData != null) { // The player is no longer muted. unsilence(event.getPlayer()); } } }
@EventHandler(priority = EventPriority.HIGHEST) public void onChat(final AsyncPlayerChatEvent event) { // Team chat if (getBeaconzWorld() == null || event.getPlayer() == null) { return; } if (Settings.teamChat && event.getPlayer().getWorld().equals(getBeaconzWorld())) { // Cancel the event event.setCancelled(true); // Queue the sync task because you cannot use HashMaps asynchronously. Delaying to the next tick // won't be a major issue for synch events either. Bukkit.getScheduler().runTask(plugin, new Runnable() { @Override public void run() { teamChat(event,event.getMessage()); }}); } }
public void chatProcess(AsyncPlayerChatEvent e) { Player player = e.getPlayer(); PlayerInfo pi = players.get(player.getName().toLowerCase()); if (pi != null) { long now = new Date().getTime(); if (pi.lastTimeChatCmd != 0) { int delay = plugin.config.getChatDelay(player); int timeToWait = (int) ((pi.lastTimeChatCmd + delay) - now) / 1000; if (timeToWait > 0) { e.setCancelled(true); player.sendMessage(plugin.getPrefix() + ChatColor.RED + "Debido a tu rango debes esperar " + timeToWait + " segundos para hablar."); } else { pi.lastTimeChatCmd = now; } } else { pi.lastTimeChatCmd = now; } } if (!e.isCancelled()) { plugin.chat.processChat(e); } }
public void onPlayerChat(AsyncPlayerChatEvent event){ /*Player pl = event.getPlayer(); try{ String prefix = ""; if((Basic.getgPlayer(pl.getUniqueId().toString()).getValue("gFactionsTier").equals("autorifle")) && !event.getPlayer().getDisplayName().contains(ChatColor.BOLD + "[" + ChatColor.DARK_AQUA + "Auto-Rifler" + ChatColor.RESET + "" + ChatColor.BOLD + "]")){ prefix = ChatColor.BOLD + "[" + ChatColor.DARK_AQUA + "Auto-Rifler" + ChatColor.RESET + "" + ChatColor.BOLD + "]"; } else if((Basic.getgPlayer(pl.getUniqueId().toString()).getValue("gFactionsTier").equals("shotgun")) && !event.getPlayer().getDisplayName().contains(ChatColor.BOLD + "[" + ChatColor.GRAY + "Shotgunner" + ChatColor.RESET + "" + ChatColor.BOLD + "]")){ prefix = ChatColor.BOLD + "[" + ChatColor.GRAY + "Shotgunner" + ChatColor.RESET + "" + ChatColor.BOLD + "]"; } else if((Basic.getgPlayer(pl.getUniqueId().toString()).getValue("gFactionsTier").equals("sniper"))&& !event.getPlayer().getDisplayName().contains(ChatColor.BOLD + "[" + ChatColor.RED + "Sniper" + ChatColor.RESET + "" + ChatColor.BOLD + "]")){ prefix = ChatColor.BOLD + "[" + ChatColor.RED + "Sniper" + ChatColor.RESET + "" + ChatColor.BOLD + "]"; } else if(!event.getPlayer().getDisplayName().contains(ChatColor.BOLD + "[" + ChatColor.GOLD + "Melee" + ChatColor.RESET + "" + ChatColor.BOLD + "]")){ prefix = ChatColor.BOLD + "[" + ChatColor.GOLD + "Melee" + ChatColor.RESET + "" + ChatColor.BOLD + "]"; } event.getPlayer().setDisplayName(prefix + event.getPlayer().getDisplayName()); } catch(Exception e){ e.printStackTrace(); }*/ }
@Override public void eventTrigger(Event event) { if(event.getEventName().equalsIgnoreCase("playerjoinevent")){ } else if(event.getEventName().equalsIgnoreCase("playerentityinteractevent")){ eh.onPlayerInteract((PlayerInteractEntityEvent)event); } else if(event.getEventName().equalsIgnoreCase("worldloadevent")){ eh.onWorldLoad((WorldLoadEvent)event); } else if(event.getEventName().equalsIgnoreCase("EntityDamageEvent")){ eh.onEntityDamage((EntityDamageEvent)event); } else if(event.getEventName().equalsIgnoreCase("EntityDamageByEntityEvent")){ eh.onEntityDamage((EntityDamageByEntityEvent)event); } else if(event.getEventName().equalsIgnoreCase("entityexplodeevent")){ eh.onEntityExplode((EntityExplodeEvent)event); } else if(event.getEventName().equalsIgnoreCase("asyncplayerchatevent")){ eh.onPlayerChat((AsyncPlayerChatEvent)event); } }