Forge Message (Fake Chat Message)

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

  1. Offline


    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?
    GeekPlaya likes this.
  3. Offline


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


    Ok, let me try.
  6. Offline


    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


    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"HERRO WORLD");
    public void onPlayerChat(PlayerChatEvent event) {
    if (event.getMessage().equals(messageYouWant) && event.getSender().equals(thePlayerWhoSentIt)) {
    // Might be event.getPlayer(), don't remember
    //Do stuff here

Share This Page