Cooldown and sign reward

Discussion in 'Plugin Development' started by Tjerkh987, Nov 22, 2014.

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

    Tjerkh987

    I'm making 2 plugins at the moment a package plugin and a parkour plugin:

    Package: In my package plugin I'm making 5 packages as commands and donators can do 1 package every hour? I already have the commands I only need the stopwatch so that they can use 1 package every hour they can choose out of 5

    Parkour: Just a sign and if they click on the sign they get a reward my question is can someone help me? add me on skype: <Timtower says: conversation must be kept in the thread>
    I will send you some screenshot later I actually gtg please answer!

    EDIT by Timtower: removed skype and added title with a description.
     
  2. Offline

    mine-care

    About your plugin "package" you'll need to have a map where you store player's name or preferably UUID and a long next to it.
    When they use something and you want to add them in the cooldown, just put in the hashmap player's uuid and as a long you need to pass system's current time miliseconds + the ammount of time you need in cooldown. From a plugin of mine here is an example:
    Code:java
    1. System.currentTimeMillis()+ TimeUtil.secToMilisec(20*60);
    2. //Add curent time miliseconds plus 20 minutes converted to miliseconds.
    3.  

    After you done that, keep a repeating task that will loop through the cooldowns and check if the time in the map is less or equal to curent time miliseconds, if it is it will remove the entry
    an example of this (again from the same plugin as above):
    Code:java
    1. BukkitScheduler schedule = Bukkit.getServer().getScheduler();
    2. schedule.scheduleSyncRepeatingTask(this, new Runnable() {
    3. @Override
    4. public void run() {
    5. for(UUID u : cooldown.keySet()){
    6. long l = cooldown.get(u);
    7. if(l<=System.currentTimeMillis()){
    8. cooldown.remove(u);
    9. }
    10. }
    11. }
    12. }, 0L, 20L);

    About the sign reward, you'll need to listen to PlayerInteractEvent and when it is caled, check for null's and if the clicked item is sign, if it is cast it to sign and use some of the usefull Sign methods to check if it is the sign you're after. If it is, do your code there!
    A tutorial on that can be found here:

    Phew...
    Hope that helps!
     
Thread Status:
Not open for further replies.

Share This Page