Skip to content

Commit

Permalink
fix cooldowns
Browse files Browse the repository at this point in the history
  • Loading branch information
Faithcaio committed Aug 28, 2024
1 parent d174770 commit 587166f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
*/
package org.spongepowered.api.entity.living.player;

import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.util.Ticks;

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

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

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

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

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package org.spongepowered.api.event.entity.living.player;

import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.entity.living.player.CooldownTracker;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
import org.spongepowered.api.event.Cancellable;
Expand All @@ -47,11 +48,11 @@ public interface CooldownEvent extends Event {
ServerPlayer player();

/**
* Gets the associated item type whose cooldown is being set or removed.
* Gets the associated item group whose cooldown is being set or removed.
*
* @return The associated item type
*/
ItemType itemType();
ResourceKey group();

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

0 comments on commit 587166f

Please sign in to comment.