Slimefun4 icon indicating copy to clipboard operation
Slimefun4 copied to clipboard

Add feature: Cooldowns

Open Sefiraat opened this issue 2 years ago • 2 comments

Description

Adds the ability to set cooldowns that will automatically apply based on ItemHandlers allowing cooldowns on placing, breaking, attacking, killing w/e the implementing class requires of it's cooldown(s).

This PR is still WIP - it requires docs at the very least so it's in draft just to get some initial views on the current state.

Proposed changes

Adds a new object called ItemCooldown which has a default duration. This object can be provided ItemHandler classes that would cause the cooldown to fire. Adds a new overload for callItemHandler() that additionally accepts a player and will both check and set the cooldown if the conditions match/don't match Changes those listeners that are player-led to call this new overload passing the player through. Adds the relevant test units to cover the new addition

Things I know I already dislike: I don't like MockItemHandler2 but something is required to ensure unwanted handlers don't trigger it - suggestions? Dislike the CoundownLatch, but we need time to pass and it's the only way to trick it into checking expiry I can work out.

Tested lightly, what i've tested all works well - but likely more to look at.

Related Issues (if applicable)

Checklist

  • [ ] I have fully tested the proposed changes and promise that they will not break everything into chaos.
  • [ ] I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them.
  • [ ] I have made sure that the proposed changes do not break compatibility across the supported Minecraft versions (1.16.* - 1.20.*).
  • [ ] I followed the existing code standards and didn't mess up the formatting.
  • [ ] I did my best to add documentation to any public classes or methods I added.
  • [ ] I have added Nonnull and Nullable annotations to my methods to indicate their behaviour for null values
  • [ ] I added sufficient Unit Tests to cover my code.

Sefiraat avatar Jul 12 '23 13:07 Sefiraat

Your Pull Request was automatically labelled as: "🎈 Feature" Thank you for contributing to this project! ❤️

github-actions[bot] avatar Jul 12 '23 13:07 github-actions[bot]

Slimefun preview build

A Slimefun preview build is available for testing! Commit: 75543068

https://preview-builds.walshy.dev/download/Slimefun/3909/75543068

Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!

github-actions[bot] avatar Jul 12 '23 13:07 github-actions[bot]