Player.sendMessage | Player Recieves message from any plugin event.

Discussion in 'Plugin Development' started by vasil7112, Mar 21, 2014.

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

    vasil7112

    Hello there,

    Is there any Event that would track if someone uses the player.sendMessage("Message here"), and then possibly get the string and then cancel the task?

    Thanks alot!
     
  2. Offline

    willeb96

    I think your best bet is to use ProtocolLib to catch all outgoing chat messages.
     
  3. Offline

    vasil7112

    Hmm, i prefer to do it with a normal packet if that is your idea. But how would i be able to see what is a player message and what is not?
    I mean, sure, a player message will contain his name right? But what if the message says something like "Playername" has just voted? Then it will create some confusion to the determination of if the message is from a player, or from a plugin. That is why i am looking exactly for an event for it:)
     
  4. Offline

    skyrimfan1

     
  5. Offline

    willeb96

    Wait, you want to catch only player chat?
    AsyncPlayerChatEvent is called even if it was a plugin that issued Player.chat(String) I'm pretty sure.
     
  6. Offline

    vasil7112


    No, i want to catch all the chat events except the PlayerChatEvent.
    I only need to catch the messages that are sent by plugins, and not the ones that are send by players.
    Also skyrimfan, inorder to not use a depency plugin, i prefer writing the code myself. As result the downloaders won't need an external plugin to use mine.

    Kind regards to you:)
     
  7. Offline

    willeb96

    I'm pretty sure there is no event for sent messages, so you'll either have to depend on ProtocolLib, steal their code or write your own packet listener.
     
  8. Offline

    Garris0n

    ಠ_ಠ
     
  9. Offline

    willeb96

    I figured I'd list all his options, I wouldn't recommend that one in particular though.
     
  10. Offline

    vasil7112

    There is no reason to steal the code for something as simple as that. It is just some more research.
    The only thing i need to find is the Packet Name for the chat messages. ProtocolLib has quite a "Complicated" Code because it allows you to intergrade it with many Versions of minecraft.

    So, i guess that my only option is to make my own chat event right?
    But i will keep the thread open for future suggestions.
    Thanks alot everyone for your time! Have a good day or night!:)
     
  11. Offline

    RawCode

    i will suggest to build special debug version of cbukkit if you want to monitor activity of plugins on server.
    sources are posted, also you can compile only classes you need, soo there is no need to use maven or rebuild entire server in order to add debugtrace to specific method.

    ever if you add packetlib (or write down your own packet handler), it wont tell you source of method invocation, you must build specially for this case.
     
    Garris0n likes this.
  12. Offline

    willeb96

    If you're that confident you can pull it off then go for it!
    I've personally never looked into it.
     
  13. Offline

    vasil7112

    Well, forcing the players to use a custom craftbukkit is not that good, not that efficient, and probably against the rules, so i think i will pass on that idea :/

    Just a bump simple bump
    Reason: People in different time zone might have another idea :) If not, well, still no problem.

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

    RawCode

    vasil7112
    Random players not going to debug cbukkit and plugins.

    Personally i can't see any reason for such feature expect debugging.
    If you dont like some specific plugin that sent messages - path that plugin and add custom event
     
  15. Offline

    MRPS

    You'd have to use java reflection in order to prevent another plugin from using sendMessage().
     
  16. Offline

    vasil7112

    Well the main thing i am looking to make is the following:
    A custom Messaging system e.x
    ================
    Server News e.t.c
    ================
    + Player Message 1
    + Player Message 2
    ......
    +Playe Message 5
    ================
    Server commands response (Example if someone typed / plugins the plugins would be shown on the last line e.t.c)
     
  17. Offline

    Cloaking_Ocean

    Sorry MRPS I know this is something I should know but how to you use reflection to stop other plugins codes? It'd be helpful to know because I've had this problem before. I had a plugin that would let you spectate a player but once you added a plugin like essentials when you teleported your inventory closed so you couldn't edit your inventory or even exit minecraft. If I could figure out how to use reflection I could find the code that closes the inventory and cancel it. If you take any consideration in teaching me thanks so much.
     
  18. Offline

    MRPS


    Reflection is one of the more difficult topics in Java - I don't even know the Reflection API itself, but I know what it does.
     
  19. Offline

    Cloaking_Ocean

    MRPS okay thanks! Sorry. I should just look it up myself. Thanks Anways :D.
     
  20. Offline

    Garris0n

    Meh, it isn't that complicated.
     
    MRPS likes this.
Thread Status:
Not open for further replies.

Share This Page