Forge Message (Fake Chat Message)

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

  1. Offline

    GeekPlaya

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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. Offline

    tips48

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    player.chat("MyMessage");
    GeekPlaya likes this.
  3. Offline

    GeekPlaya

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    But how would I append things such as recipients, etc.?
  4. Offline

    tips48

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Catch it in onPlayerChat and do stuff to it.
  5. Offline

    GeekPlaya

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Ok, let me try.
  6. Offline

    GeekPlaya

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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?
  7. Offline

    tips48

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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) {

    This post has been edited 2 times. It was last edited by GeekPlaya Oct 12, 2011.
  9. Offline

    tips48

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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
    }
    }

Share This Page