Bukkit Plugins: Auto Ranking System

Any help topics that don't fit in the current categories can go here.
Post Reply
User avatar
Samuel98
Posts: 46
Joined: Wed Oct 05, 2011 1:20 am
Location: United Kingdom
Contact:

Bukkit Plugins: Auto Ranking System

Post by Samuel98 »

Content Deleted
Last edited by Samuel98 on Sun Mar 22, 2015 9:37 pm, edited 1 time in total.
Image

Samuel Carr
Server Developer
W: http://epiccrafts.co.uk
E: [url]mailto://samuel.carr@epiccrafts.co.uk[/url]
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: Bukkit Plugins: Auto Ranking System

Post by Temor »

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 :)
User avatar
Samuel98
Posts: 46
Joined: Wed Oct 05, 2011 1:20 am
Location: United Kingdom
Contact:

Re: Bukkit Plugins: Auto Ranking System

Post by Samuel98 »

Content Deleted
Last edited by Samuel98 on Sun Mar 22, 2015 9:37 pm, edited 1 time in total.
Image

Samuel Carr
Server Developer
W: http://epiccrafts.co.uk
E: [url]mailto://samuel.carr@epiccrafts.co.uk[/url]
User avatar
Samuel98
Posts: 46
Joined: Wed Oct 05, 2011 1:20 am
Location: United Kingdom
Contact:

Re: Bukkit Plugins: Auto Ranking System

Post by Samuel98 »

Content Deleted
Last edited by Samuel98 on Sun Mar 22, 2015 9:38 pm, edited 1 time in total.
Image

Samuel Carr
Server Developer
W: http://epiccrafts.co.uk
E: [url]mailto://samuel.carr@epiccrafts.co.uk[/url]
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: Bukkit Plugins: Auto Ranking System

Post by Temor »

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 :P
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 loop

I hope you got the idea :P Sorry if I confused you. I really know nothing about java.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Bukkit Plugins: Auto Ranking System

Post by jacek »

SamzRulez wrote:Question how can I make it check every minute?
Depends how precise you wan tot be. If it doesn’t have to be exactly every 60 seconds then you can use the BukkitScheduler.

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.
Image
Post Reply