Toggling commands

Discussion in 'Spigot Plugin Development' started by X_M7md_UaE, May 5, 2017.

Thread Status:
Not open for further replies.
  1. Hey there,

    How to toggle command? For example if I would toggle the command "/fly"

    Thanks,
    ~ Mohammad
     
    #1 X_M7md_UaE, May 5, 2017
    Last edited: May 10, 2017
  2. Code (Text):
    Player#setAllowFlight(!(Player#getAllowFlight()));
    That should work just fine.
    Basically what I did there is grab a boolean that represents the current value (on/off) of the toggle and then set the value to its inverse thus making it "toggle".
     
    • Like Like x 1
  3. Yeah, use Yugikids method it should work just fine.
     
    • Like Like x 1
  4. Thanks for your lovely answer!
     
Thread Status:
Not open for further replies.