Skip to content

Commit 587166f

Browse files
committed
fix cooldowns
1 parent d174770 commit 587166f

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/main/java/org/spongepowered/api/entity/living/player/CooldownTracker.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
*/
2525
package org.spongepowered.api.entity.living.player;
2626

27+
import org.spongepowered.api.ResourceKey;
2728
import org.spongepowered.api.item.ItemType;
29+
import org.spongepowered.api.item.inventory.ItemStack;
2830
import org.spongepowered.api.util.Ticks;
2931

3032
import java.util.Optional;
@@ -42,7 +44,8 @@ public interface CooldownTracker {
4244
* @param type The item type to check is on cooldown
4345
* @return Whether or not the specified item type is cooldown
4446
*/
45-
boolean hasCooldown(ItemType type);
47+
boolean hasCooldown(ItemStack stack);
48+
boolean hasCooldown(ResourceKey group);
4649

4750
/**
4851
* Gets the cooldown of the specified {@link ItemType} in ticks for the
@@ -52,7 +55,8 @@ public interface CooldownTracker {
5255
* @return The cooldown remaining for this item type in ticks, if not
5356
* on cooldown
5457
*/
55-
Optional<Ticks> cooldown(ItemType type);
58+
Optional<Ticks> cooldown(ItemStack stack);
59+
Optional<Ticks> cooldown(ResourceKey group);
5660

5761
/**
5862
* Sets the cooldown for the specified {@link ItemType} for the
@@ -63,7 +67,8 @@ public interface CooldownTracker {
6367
* @return False if setting the cooldown failed, possibly due to the event
6468
* being cancelled
6569
*/
66-
boolean setCooldown(ItemType type, Ticks ticks);
70+
boolean setCooldown(ItemStack stack, Ticks ticks);
71+
boolean setCooldown(ResourceKey group, Ticks ticks);
6772

6873
/**
6974
* Resets the cooldown of the specified {@link ItemType} for the
@@ -73,7 +78,8 @@ public interface CooldownTracker {
7378
* @return False if setting the cooldown failed, possibly due to the event
7479
* being cancelled
7580
*/
76-
boolean resetCooldown(ItemType type);
81+
boolean resetCooldown(ItemStack stack);
82+
boolean resetCooldown(ResourceKey group);
7783

7884
/**
7985
* Gets the fraction of the specified {@link ItemType}'s cooldown that
@@ -85,6 +91,7 @@ public interface CooldownTracker {
8591
* @param type The item type to get the cooldown fraction remaining
8692
* @return The fraction of cooldown remaining for the specified item type
8793
*/
88-
OptionalDouble fractionRemaining(ItemType type);
94+
OptionalDouble fractionRemaining(ItemStack stack);
95+
OptionalDouble fractionRemaining(ResourceKey group);
8996

9097
}

src/main/java/org/spongepowered/api/event/entity/living/player/CooldownEvent.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package org.spongepowered.api.event.entity.living.player;
2626

27+
import org.spongepowered.api.ResourceKey;
2728
import org.spongepowered.api.entity.living.player.CooldownTracker;
2829
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
2930
import org.spongepowered.api.event.Cancellable;
@@ -47,11 +48,11 @@ public interface CooldownEvent extends Event {
4748
ServerPlayer player();
4849

4950
/**
50-
* Gets the associated item type whose cooldown is being set or removed.
51+
* Gets the associated item group whose cooldown is being set or removed.
5152
*
5253
* @return The associated item type
5354
*/
54-
ItemType itemType();
55+
ResourceKey group();
5556

5657
/**
5758
* Handles an {@link ItemType} being given a cooldown for a {@link ServerPlayer player}.

0 commit comments

Comments
 (0)