1.16.5 EssentialsX Teleport Listener

Discussion in 'Spigot Plugin Development' started by specomputers, Jun 14, 2021.

  1. Hey all!

    I'm currently working on my plugin that outputs to staff what commands they are using. For example, if I was to vanish then it would say in chat "[smmacca: vanished]"

    Right now I'm working on the Essentials listeners and this is a lot harder because of the fact that there's no documentation or easy way to see what's part of the API. What event would I use to listen for /tp and /tphere commands and how do I pull info from them that lets me see who they have teleported to?

    Help is appreciated!
    Cheers
     
    • Informative Informative x 1
  2. Hi! You can listen to the PlayerCommandPreprocessEvent like FigT said
    After that you can simply see what the arguments are to determine who is teleporting to who.
    You might also want to use a permission check to make sure they have the correct permissions to do it. If essentials fails to teleport, your code would still output the same as you're not running the same checks as essentials, so the easiest way around this problem is to use the same checks as essentials.
     
    • Informative Informative x 1
  3. Thank you! How would I pull the arguments from the command using this event?
     
  4. Code (Java):
    //returns the whole command
    event.getMessage();
    //use split by space to get the arguments
    event.getMessage().split(“ “);
    //1 would be the first index for arguments.
     
    • Useful Useful x 1
  5. Thank you !!