On a AsyncPlayerChatEvent, how would I be able to check to see if they used someone's name that is currently online, and if that player is online, it changes their name in the chat message to a certain color.
Code: public void onChat(AsyncPlayerChatEvent event){ String message = event.getMessage(); for(Player players : Bukkit.getOnlinePlayers()){ if(message.contains(players.getName()){ //Figure this out yourself ;) } } } Untested code. EDIT: If you really can't figure this out, just tahg me and I'll assist you.
Code: @EventHandler public void onChat(AsyncPlayerChatEvent event){ String message = event.getMessage(); for(Player players : Bukkit.getOnlinePlayers()){ if(message.contains(players.getName())){ String editedmsg = message.replace(players.getName(), ChatColor.YELLOW + players.getName() + ChatColor.RESET); event.setMessage(editedmsg); } } } Tested code.
Yes, no one else was helping him, and now he'll know how to do it for the future and might help someone else
I get your point, But maybe let him do the programming and give him a base to use, I bet 9/10 he would c/p that code.
@ChipDev He was spoonfeeding, we know but... nobody was helping him. @driver-e You could of told him how to do it, not do it for him..