I'm writing a minecraft plugin that will notify someone when you mention his name in chat. He will receive a customized message where in the message his name is underlined and recoulerd. It will also play a music note.
I have this, but it will sent the message to everyone in the server:
@Override
public void onEnable()
{
Bukkit.getServer().getPluginManager().registerEvents(this, this);
}
@Override
public void onDisable()
{
}
@EventHandler
public void onChat(AsyncPlayerChatEvent e)
{
for(Player on:Bukkit.getServer().getOnlinePlayers())
{
if(on.equals(e.getPlayer()))continue;
if(e.getMessage().contains(on.getName()))
{
e.setMessage(e.getMessage().replaceAll(on.getName(), ChatColor.GREEN + "@" + ChatColor.UNDERLINE + on.getName()));
on.playNote(on.getLocation(), Instrument.PIANO, Note.natural(1, Tone.A));
}
}
}