How to get player who activated command block

Discussion in 'Plugin Development' started by Zhro, Dec 26, 2013.

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

    Zhro

    Player presses a button which activates a command block that sends a command; command is found by plugin by onCommand override. The CommandSender is an instance of BlockCommandSender.

    Is it possible to deduce who pushed the button?
     
  2. Offline

    mrkirby153

    Zhro

    Uh you could have the command be /yourcommand @p. That should pass in the command and the nearest player. Haven't tested that. May not work
     
  3. Offline

    Zhro

    The nearest player is not always the one who activated the block.
     
  4. Offline

    Garris0n

    It's not worth your time to try. But, should you want to, you'll have to keep track of all button presses, lever presses, pressure plate presses, tripwire presses (what if I throw an item on a tripwire?, so item drops...), and tons of other stuff. You'll also have to trace the redstone from the command block to whatever got pressed and try to decude, which is pretty much impossible when you take lag into account, who pressed whatever it is that was triggered.
     
  5. Offline

    Jonasrems

    You can make a scoreboard objective that tracks buttonpress on players and make the commandblock use "/command @p[score_buttonpress_min=1]".
    Remember to make another commandblock set the score back to 0 after the command was runned.
     
Thread Status:
Not open for further replies.

Share This Page