Remove cool down after death.

Discussion in 'Plugin Development' started by DazzT, May 11, 2019.

Thread Status:
Not open for further replies.
  1. I'm making a kits plugin and i have made a cool down for the kits but i want the cool down to be gone after the player dies, the cool down is in a different class then the Listener class with the PlayerDeathEvent.
    how do i get the Hashmap cooldown into the listener class and use i at the PlayerDeathEvent?
     
  2. Online

    timtower Administrator Administrator Moderator

    @DazzT You make a getter for it.
    But the rest of the information depends on your code.
     
  3. Offline

    KarimAKL

    @DazzT You could make a getter and a setter for it, something like this:
    Code:Java
    1. // In this case the map is <UUID, Long>
    2. public long getCooldown(UUID uuid) {
    3. if (!map.containsKey(uuid)) return 0L;
    4. return map.get(uuid);
    5. }
    6.  
    7. public void setCooldown(UUID uuid, long cooldown) {
    8. map.put(uuid, cooldown);
    9. }

    Then just pass the instance of the class to the class in which you want to set the cooldown, then use the setCooldown method.
     
  4. Alright i've created a getter and setter but how do i exactly pass the instance of the class i wanna set or remove the cooldown? im getting back into programming so im kinda new so i don't really know alot yet.
     
Thread Status:
Not open for further replies.

Share This Page