Listen for Server Side Messages

Discussion in 'Plugin Development' started by sonica123, Jun 23, 2016.

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

    sonica123

    My problem: When a player types /f home, it sends them a message "You are teleportation in 10 seconds", or whatever. How can I simply make an event where I can listen for that exact string of text so I can apply a new line to the players scoreboard when the receive that message?

    I have already looked into ProtocolLib help posts and I go a couple errors I wasnt sure how to fix. Please help, whether protocollib is involved or just raw bukkit!
     
  2. Offline

    MadMaxCookie

    simply use MassiveCore or Factions as API by this, this is not an error.
     
  3. Offline

    mine-care

    @sonica123 you want to hijack the message comming from the other plugin.
    First step, check if they provide an API that allows you to do it.
    If it doesnt then we will move to more proactive ways.
    One is to overwrite the method sendMessage of CraftPlayer somehow and use it to filter out messages. I am not sure how you can safely and efficienty implement this... Never had to mess with it.
    The other way is to capture the outgoing PacketPlayOutChat and check if the byte value in there is 0 or 1. If it is, turn the IChatBaseComponent back to String (ChatSerializer) and check if it contains the message you are trying to capture.

    Again! The api solution is the most efficient and possibly most secure...
     
    I Al Istannen likes this.
  4. Offline

    Zombie_Striker

    @sonica123
    As @mine-care said, look if the API has a method for that or check if the plugin stores the message in a config. If not, then you should decompile the Factions plugin. (*)Once you do that, look inside the classes until you find the bit of code that deals with sending the message. Either remove that line or simply change the message, re-compile the class, and put it back inside the plugin.

    Although you can do as @mine-care said, overwriting the sendMessage method or dealing with packets is overkill and can cause problems if done incorrectly.

    (*) You can use the following site to decompile a .class file. Open up the plugin's .jar file, loop through the files until you find a .class file, extract it out of the jar file, and then upload the file.
    http://www.showmycode.com/
     
Thread Status:
Not open for further replies.

Share This Page