Solved Chat Check

Discussion in 'Plugin Development' started by CONTREKEE, Mar 6, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    CONTREKEE

    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.
     
  2. 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.
     
  3. Offline

    CONTREKEE

    @driver-e How would I be able to get the argument that has the players name in it?
     
  4. 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.
     
  5. Offline

    CONTREKEE

    deleted_90940145 likes this.
  6. Offline

    ChipDev

    You.. just..spoon-fe-
    :mad:[tnt][flintnsteel]
     
  7. Yes, no one else was helping him, and now he'll know how to do it for the future and might help someone else :)
     
    ProMCKingz likes this.
  8. Offline

    ChipDev

    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.
     
  9. Offline

    KryptonicMC

    @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..
     
  10. How about we go back in time and you help him?
     
Thread Status:
Not open for further replies.

Share This Page