Timer event ;_:

Discussion in 'Plugin Development' started by Diimensions, Feb 10, 2014.

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

    Diimensions

    Hello I would like to collapse is more like a (timer)
    Example player type / hi
    Ai executes an event such as a message
    Code:java
    1. player.sendMessage("§cHellou);

    Ai dps a few seconds run anything (1 second)
    Code:java
    1. player.sendMessage("§cHellou2);

    Ai dps finishes the event (without repetitions)
     
  2. Offline

    msnijder30

    Diimensions
    I would do it like this:
    Code:java
    1. @Override
    2. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    3. if(label.equalsIgnoreCase("hi")){ //checks if the command is /hi
    4. if(sender instanceof Player){ //checks if the sender is a player
    5. final Player player = (Player) sender; //casts the sender to a player
    6. player.sendMessage("§cHellou"); //send message 1
    7.  
    8. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){ // bukkit delay
    9. public void run(){
    10. player.sendMessage("§cHellou2"); //send message 2
    11. }
    12. }, 20L); // 20 ticks is 1 second, so this is a 1 second delay
    13.  
    14. }
    15. }
    16. return false;
    17. }


    and in your plugin.yml
    Code:
    commands:
      hi:
          description: Hello!
    
     
  3. Offline

    GaaTavares

    "Ai dps a few seconds run anything (1 second) "
    Você precisava pelo menos falar sua língua local para tentar traduzir.
    You must at least speak your native language well, for "attempt" to translate it.
    Note: He said dps (which is a "cool-way" to say depois, that means, before >.>)
     
  4. Offline

    msnijder30

    GaaTavares
    Cool, I am guessing "Hellou" means Hello then :p
     
  5. Offline

    GaaTavares

    Hahah, trying to figure out how you understood what he wanted ;P
     
  6. Offline

    msnijder30

    GaaTavares
    I just did what I thought, not sure if I read it correctly.
    What I got:
    on command /hi send the player a message, after 1 second send another message :p
     
Thread Status:
Not open for further replies.

Share This Page