Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7448

How To Achieve Target Selector

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Invalid
    • Icon: Minor Minor
    • None
    • None
    • 1.20.1
    • Yes

      If I have created a plugin that allows players to send message privatly, here are a part of codes:

      // in onCommand method:
      // strings[0] == A Player's Name
      // strings[1] == A Text want to tell to others privatly
      Bukkit.getPlayer(strings[0]).sendMessage(strings[1]);

      Then I have to execute the in-game commands:

      /privatespeak Steve Hello
      

      But, as a player, I want to change my target to a nearest player, and tell him to come to my home to get his prize, I will exactly write this:

      /privatespeak @p Come-to-my-home

      However, the Target Selector @p is not a player's name. Then the plugin will throw an error because nobody in the server named "@p".

      So how can I achieve this just like the original in-game commands /msg ?

      Or is it possible to reprint the command /msg using plugins?

            Unassigned Unassigned
            X_huihui X_huihui
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: