ChatNotifier: gave up on highlights

This commit is contained in:
Erik Bročko 2018-09-08 22:40:49 +02:00
parent 094f354086
commit 2774ac7ab1

View File

@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import com.connorlinfoot.bountifulapi.BountifulAPI;
@ -13,17 +14,18 @@ import net.md_5.bungee.api.ChatColor;
public class ChatNotifier extends Feature {
// TODO: Per-player highlighting
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent e) {
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
String msg = e.getMessage();
if (e.getMessage().toLowerCase().contains(p.getName().toLowerCase()) && p.getPlayer() != e.getPlayer()) {
e.getRecipients().remove(p);
msg = ChatColor.RED + msg;
if (msg.toLowerCase().contains(p.getName().toLowerCase()) && p.getPlayer() != e.getPlayer()) {
/*e.getRecipients().remove(p);
msg = ChatColor.RED + msg;*/
BountifulAPI.sendActionBar(p, ChatColor.RED + "Byl jsi zminen v chatu!");
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 3.0F);
}
p.sendMessage(String.format(e.getFormat(), e.getPlayer().getDisplayName(), msg));
//p.sendMessage(String.format(e.getFormat(), e.getPlayer().getDisplayName(), msg));
}
}