Wait for...

Discussion in 'Plugin Development' started by splint, Jun 15, 2014.

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

    splint

    Hi, I'm a beguiner at Java, and I make a little music plugin.
    Basicly, all the plugins action was created because the player enter a specific command.
    But at this point, I make a listener, and when the player enter in a specific area, a variable called "entered" change from 0 to became 1.

    I just want to execute an action when the variable became 1, without any commands, and outside off the listener class.

    So the plugin will "wait" for the variable to became 1, and when the variable became 1, he do some stuff.

    How can I do this ?
    Thank.
     
  2. Offline

    LordVakar

    splint
    I see how you are a beginner at java.
    By variable, you mean int right?

    Have an int:
    int start = 0;

    To increase the int by 1:
    start++;

    To check if the int is 1:
    if (start == 1) {
    //Execute Code
    }
     
  3. Offline

    splint

    I know this code, but I need a loop, or something else to start it every time the variable change ?
    Because with the onCommand fonction, bukkit "wait" for the command, but if I put a simple if else on the main class, it will work ?
     
  4. Offline

    travja

    When you increase the number, run the code.
     
Thread Status:
Not open for further replies.

Share This Page