ChatNotifier: remove recipient instead of cancelling the event

This commit is contained in:
Erik Bročko 2018-09-08 02:29:02 +02:00
parent d64f9729a5
commit bd343888bb

View File

@ -19,10 +19,10 @@ public class ChatNotifier extends Feature {
@EventHandler @EventHandler
public void onPlayerChat(AsyncPlayerChatEvent e) { public void onPlayerChat(AsyncPlayerChatEvent e) {
e.setCancelled(true);
for (Player p : plugin.getServer().getOnlinePlayers()) { for (Player p : plugin.getServer().getOnlinePlayers()) {
String msg = e.getMessage(); String msg = e.getMessage();
if (e.getMessage().toLowerCase().contains(p.getName().toLowerCase()) && p.getPlayer() != e.getPlayer()) { if (e.getMessage().toLowerCase().contains(p.getName().toLowerCase()) && p.getPlayer() != e.getPlayer()) {
e.getRecipients().remove(p);
msg = ChatColor.RED + msg; msg = ChatColor.RED + msg;
BountifulAPI.sendActionBar(p, ChatColor.RED + "Byl jsi zminen v chatu!"); BountifulAPI.sendActionBar(p, ChatColor.RED + "Byl jsi zminen v chatu!");
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 3.0F); p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 3.0F);