Confirm a command

Discussion in 'Plugin Development' started by maino, Aug 6, 2012.

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

    maino

    Hello,
    does anyone know how to run a command only when the user confirms it with another command, which is available for 10secs after the user runs the command?

    For example:
    User xy types command "/deleteeverything now". Then User xy has 10 seconds to type "/deleteeverything confirm" to really do it.

    Thanks,
    maino
     
  2. Offline

    Bavestry

    Yes, I had this exact question on a different plugin. What you need to do, is when the player types the essential command "/deleteeverything now" you need to put his name, and a boolean into a new HashMap. Also, when he types "/deleteeverything now" you need to set that boolean to true, before you put it into the HashMap. When the player types "/deleteeverything confirm" it gets the information from the HashMap, it then checks if the boolean is true, and if the playername in from the HashMap = the sender's username. If you need any other help, or you just don't get this, just ask. ;)
     
  3. Offline

    maino

    Thanks for your reply! I'll try that and will let you know if i have any issues :).
     
  4. Offline

    pzxc

    Instead of using a boolean, store a long that contains that time the command was executed. Then you can check to make sure no more than 10 seconds have passed, and also write a cleanup task that erases old entries where the 10 second timeout period expired
     
Thread Status:
Not open for further replies.

Share This Page