How would I add a warmup to my commands

Discussion in 'Plugin Development' started by Kowaman, Aug 25, 2013.

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

    Kowaman

    So I am making a plugin and I want one of the commands, /fly to have a warmup, how would I do so. If possible I would like it to be another method in a separate class, so my CommandExecutor doesn't get too crowded.
     
  2. Offline

    JWhy

    You can use schedulers for that.
    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    2. if(cmd.getName().equalsIgnoreCase("tp")){
    3. new TeleportTask(this).runTaskLater(this.plugin, 100);
    4. sender.sendMessage("You will be teleported in 5 seconds");
    5. return true;
    6. }
    7. return false;
    8. }

    Code:java
    1. public class TeleportTask extends BukkitRunnable {
    2.  
    3. private final JavaPlugin plugin;
    4.  
    5. public TeleportTask(JavaPlugin plugin) {
    6. this.plugin = plugin;
    7. }
    8.  
    9. public void run() {
    10. // Perform some magic
    11. }
    12.  
    13. }
     
Thread Status:
Not open for further replies.

Share This Page