Bukkit Plugins: Auto Ranking System
Bukkit Plugins: Auto Ranking System
Content Deleted
Last edited by Samuel98 on Sun Mar 22, 2015 9:37 pm, edited 1 time in total.
Samuel Carr
Server Developer
W: http://epiccrafts.co.uk
E: [url]mailto://samuel.carr@epiccrafts.co.uk[/url]
Re: Bukkit Plugins: Auto Ranking System
I'm not familiar with Java or Bukkit at all, but the principle of this seems really easy.
Set a timestamp when the user first joins the server, and then create a variable with the value of the first timestamp + 30 minutes.
Then check to see if current timestamp > original timestamp+30 minutes every minute or so. Whenever current timestamp is greater than timestamp+30 minutes, upgrade user rank.
And for the /timeremaining command, just check to see if current timestamp > timestamp+30 minutes. If not, show timestamp+30 minutes minus current timestamp.
Just brainstorming here, but in my mind, this would work
Set a timestamp when the user first joins the server, and then create a variable with the value of the first timestamp + 30 minutes.
Then check to see if current timestamp > original timestamp+30 minutes every minute or so. Whenever current timestamp is greater than timestamp+30 minutes, upgrade user rank.
And for the /timeremaining command, just check to see if current timestamp > timestamp+30 minutes. If not, show timestamp+30 minutes minus current timestamp.
Just brainstorming here, but in my mind, this would work
Re: Bukkit Plugins: Auto Ranking System
Content Deleted
Last edited by Samuel98 on Sun Mar 22, 2015 9:37 pm, edited 1 time in total.
Samuel Carr
Server Developer
W: http://epiccrafts.co.uk
E: [url]mailto://samuel.carr@epiccrafts.co.uk[/url]
Re: Bukkit Plugins: Auto Ranking System
Content Deleted
Last edited by Samuel98 on Sun Mar 22, 2015 9:38 pm, edited 1 time in total.
Samuel Carr
Server Developer
W: http://epiccrafts.co.uk
E: [url]mailto://samuel.carr@epiccrafts.co.uk[/url]
Re: Bukkit Plugins: Auto Ranking System
I'm not entirely sure how java or bukkit works but I guess there's some way to run code every game tick. Figure out how long one of those ticks are and then figure out how many ticks there are in a minute and create a loop.
I'll try to write an example. Keep in mind I have no idea what the proper Java syntax is so don't copy paste my code as it will not work
I'll try to write an example. Keep in mind I have no idea what the proper Java syntax is so don't copy paste my code as it will not work
i = 1 //Run loop while i is less than or equal to the number of ticks in one minute. while i<=xTicks { //Add one each time the loop runs i.e each game tick. i++ // if i is greater than the or equal to the number of game ticks in one minute, reset i back to 0 and check the timestamp again. if i>=xTicks { i = 0 //if current time is greater than the original timestamp + 30 minutes, upgrade user. if currentTimestamp >= timestamp+30minutes{ upgrade user } // end if } //end if }// end while loopI hope you got the idea Sorry if I confused you. I really know nothing about java.
Re: Bukkit Plugins: Auto Ranking System
Depends how precise you wan tot be. If it doesn’t have to be exactly every 60 seconds then you can use the BukkitScheduler.SamzRulez wrote:Question how can I make it check every minute?
so in your main plugin class you can set up a repeating task that is called every 60 seconds like this
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new YourTask(this), 0L, 1200L);The 1200 here comes from 60 * 20 because there are 20 ticks in each second.
The class YourTask() is one which implements Runnable and has a run() method, that method will be called roughly every 60 seconds. I say roughly because the tick rate is not a steady 20 ticks/second as we assume here.
If you want it to be exactly on the 60 second mark you will have to do somethign a bit more like Temor said above, using the system time.