Forge Message (Fake Chat Message)

Discussion in 'Plugin Development' started by GeekPlaya, Oct 12, 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.
     
  6. Offline

    GeekPlaya

    Well, I tried:
    Code (Text):
    1. PlayerChatEvent ch = new PlayerChatEvent(p.getServer().getPlayer("GeekPlaya"), m);
    2.             ch.setCancelled(false);
    That didn't work... seems like it should though :p Any ideas?
     
  7. No, you don't create a player chat event. I mean create a listener and catch the event, then do what you want.
     
  8. 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 (Text):
    1. public void onPlayerChat(PlayerChatEvent chat) {
     
  9. 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