How to call function every hour? Also, how can I loop this?

前端 未结 4 1110
鱼传尺愫
鱼传尺愫 2021-02-05 14:17

I need a simple way to call a function every 60 minutes. How can I do this? I\'m making a MineCraft bukkit plugin, and this is what I have:

package com.webs.play         


        
4条回答
  •  爱一瞬间的悲伤
    2021-02-05 14:20

    You must use Bukkit Scheduler:

    public void Method(){
        this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
            @Override
            public void run() {
                // Your code goes here
                Method();
            }
        }, time * 20L );
    }
    

    You must create a method with this and there you must call the same method.

提交回复
热议问题