Spoofing player chat messages?

Discussion in 'Plugin Development' started by Guccify, Jun 5, 2014.

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

    Guccify

    I'm trying to figure out how to dispatch a fake chat event on a given player by username through a command. For example:
    Code:
    /spoof Notch test
    Would show up as if the player "Notch" said "test".

    Basically breaking it down:
    - How can I define a player object by IGN.
    - How can I dispatch a chat event from that player.
     
  2. Offline

    Phantom_64

    Guccify
    Getting player by their name (Null check recommended):
    Code:java
    1. Bukkit.getServer().getPlayer(playerName)

    Forcing a player to chat:
    Code:java
    1. player.chat(message)
     
  3. Offline

    RawCode

    you can just sent message in format you like...
     
  4. Offline

    Phantom_64

    Did you read the question properly? :/
     
  5. Offline

    RawCode

    Do you know how client recieve "chat" messages.
    Please explain what makes messages from player and messages from plugin different?
     
  6. Offline

    Dubehh

    Phantom_64

    Couldn't u just Broadcast the message? With (for example) Args[0] as the spoof-name thing, and then add a stringbuilder for the message.

    And RawCode is right,

    in chat --> Dubehh: Hi everyone!
    Is the same as: player.sendMessage("Dubehh: Hi everyone!");

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 30, 2016
  7. Offline

    metalhedd


    Not exactly. You'd have to match any custom formatting applied by any chat plugins. if the recieving player is ignoring the 'fake' sender, they will still receive that message. also, IIRC, since 1.7.9 server broadcasts and player chat actually use separate packets so that a client can disable chat while still recieving server messages.
     
  8. Offline

    RawCode

    you always can mimic any formatting your server have, you dont need any special skills for this.
     
  9. Offline

    lycano

    Guccify if the player is online you can call the PlayerChatEvent which will trigger the correct event so that other plugins that filter chat or modify chat formating for specific players will work.

    If the player is not online there is no player object and you can't just "create" one since this is not trivial. In this case you can only fake the message via broadcast.

    If you want to make it as "realistic" as possible then you need to check what plugin is used and read out the format strings and use it when broadcasting.

    And just to clarify sending a chat string via broadcast is not the same as sending a chat message through player object. It may looks the same if formatting is applied correctly but technically this is not the same.
     
  10. Offline

    Necrodoom

    How is copying a server chat format, taking in all the factors from several plugins, prefixes, suffixes, nick, tags, etc, not to mention bypassing plugins doing listening on playerchatevent, is any better than a simple player.chat(msg) call?

    You are arguing for the point of arguing here.
     
    Aengo and garbagemule like this.
  11. Offline

    Garris0n

    That's interesting.

    Edit: I don't seen any separate packets, do you mean a later version?
     
  12. Offline

    1Rogue


    Both of these are incorrect. For one, messages sent via plugin and via chat are bothed perceived completely differently by the minecraft client (try disabling "player chat", this would still go through). Secondly, player#chat(String) is already built into the API for faking a message and correctly handling all aspects around it, why would you try to circumvent that?
     
    Phantom_64 likes this.
  13. Offline

    metalhedd

    It may be a snapshot feature. I'm not entirely sure, and I'm at work right now so I can't verify it. You can disable player chat in the client without disabling server broadcast messages though, as confirmed by the previous poster here, so there is some difference in what's coming over the wire in order for the client to pull that off
     
  14. Offline

    Garris0n

    Maybe it's in the JSON.
     
  15. Offline

    RawCode

    you also can spoof json tags just like anything else, i dont see issue here.

    basically this looks like "evil bit" for me
     
  16. Offline

    Phantom_64

    1Rogue Exactly what I was trying to say.

     
Thread Status:
Not open for further replies.

Share This Page