Disable And Enable Command

Discussion in 'Plugin Development' started by morha13, Jul 1, 2013.

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

    morha13

    Hello,
    I Want To Make A Command That Can Disable And Enable...
    like i have the command /ts the print the ts server ip..
    so i want command like /cts that cancel/enable the command..
    thanx to helpers
     
  2. Offline

    Shzylo

    I'm having a hard time understanding what your exact question is.
    here is a way, like say i have the command '/boolean' a boolean holds a true or false value.

    Code:java
    1. private boolean enabled = false; //my thing to check if it is enabled/disabled
    2.  
    3. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    4. if(cmd.getName().equalsIgnoreCase("boolean")) {
    5. if(enabled) { // checks if the boolean enabled is true
    6. sender.sendMessage("disabling"); //telling the sender that it is getting disabled
    7. enabled = false; //disables 'enabled'
    8. } else {
    9. sender.sendMessage("enabling"); //telling the seender that it is getting enabled
    10. enabled = true; //enables 'enabled'
    11. }
    12. }
    13. return false;
    14. }

    Hope this helped.
     
  3. Offline

    morha13

    thank you!!! i will try this later and i will tell you if its work!
     
  4. Offline

    SnipsRevival

Thread Status:
Not open for further replies.

Share This Page