Make a command timeout

Discussion in 'Plugin Development' started by 1SmallVille1, Mar 23, 2013.

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

    1SmallVille1

    Hi so I was just wondering how you can make a command timeout after a specified amount of time. An example of what I mean is for most teleport plugins where after the request is sent, you have x amount of time to accept. This is what I've tried but it just doesn't work....
    Code:
        private void startTime() {
     
            int i = 0;
     
            while (play) {
     
                try {
                    Thread.sleep(1000);
                    i++;
                   
                    if (i == this.getConfig().getInt("commandTimeOut")) {
     
                        chosen = null;
                        challenger = null;
                        play = false;
                    }
                } catch (InterruptedException e) {
     
                }
            }
     
        }
     
  2. Offline

    ZeusAllMighty11

    When would it EVER be a good idea to sleep the thread on a per-player cooldown?
     
  3. Offline

    1SmallVille1

    So then how do you suggest I do it?
     
  4. Offline

    ZeusAllMighty11

  5. Offline

    1SmallVille1

Thread Status:
Not open for further replies.

Share This Page