Forge Message (Fake Chat Message)

Discussion in 'Plugin Development' started by GeekPlaya, Oct 11, 2011.

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

    GeekPlaya

    My 3rd topic of the day for my 3rd main question of the day...

    How do you forge a chat message so that the server believes a player SENT it and TREATS it like a chat message?
     
  2. player.chat("MyMessage");
     
    GeekPlaya likes this.
  3. Offline

    GeekPlaya

    But how would I append things such as recipients, etc.?
     
  4. Catch it in onPlayerChat and do stuff to it.
     
  5. Offline

    GeekPlaya

    Ok, let me try.

    Well, I tried:
    Code:
    PlayerChatEvent ch = new PlayerChatEvent(p.getServer().getPlayer("GeekPlaya"), m);
    			ch.setCancelled(false);
    That didn't work... seems like it should though :p Any ideas?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
  6. No, you don't create a player chat event. I mean create a listener and catch the event, then do what you want.
     
  7. Offline

    GeekPlaya

    Darn! I really wish I knew what you were talking about so I wouldn't be pestering you any more..

    I'm not sure if I am experienced enough to understand how to set such a thing up..

    I put that line within:
    Code:
    public void onPlayerChat(PlayerChatEvent chat) {
     
  8. first
    player.chat("HERRO WORLD");
    then
    public void onPlayerChat(PlayerChatEvent event) {
    if (event.getMessage().equals(messageYouWant) && event.getSender().equals(thePlayerWhoSentIt)) {
    // Might be event.getPlayer(), don't remember
    //Do stuff here
    }
    }
     
Thread Status:
Not open for further replies.

Share This Page