Skip to content

Add Bee#set/getTimeSinceSting() methods (#12719) #12792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Umbre11as
Copy link

Description

Adds API methods to get and set the time since a bee last stung, allowing better control over bee behavior after stinging.

Problem

Currently there's no way to access or modify the timeSinceSting field through the API. This prevents plugins from properly managing bee behavior when using setHasStung(false) to make bees attack repeatedly, as the timeSinceSting value keeps increasing and can eventually cause the bee to die.

Solution

Added two new methods to the Bee API:

  • getTimeSinceSting() - Returns the number of ticks since the bee last stung
  • setTimeSinceSting(int time) - Sets the number of ticks since the bee last stung

Closes #12719

@Umbre11as Umbre11as requested a review from a team as a code owner July 3, 2025 12:56
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Jul 3, 2025

@Override
public void setTimeSinceSting(final int time) {
this.getHandle().setTimeSinceSting(time);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't have source in front of me, are there any range restrictions on this number? Like should it never be negative? That sort of thing.

@github-project-automation github-project-automation bot moved this from Awaiting review to Changes required in Paper PR Queue Jul 3, 2025
@Umbre11as
Copy link
Author

@Machine-Maker Done. Made the timeSinceSting field public and added validation to prevent negative values. Thanks for the suggestions

@Toffikk
Copy link

Toffikk commented Jul 3, 2025

As it was said before, please use an AT (paper.at) for making things public
edit: it also seems the patch blobs got broken, should be +_,26 @@ not +146,26 @@

@Umbre11as
Copy link
Author

Now I used Access Transformer

@Override
public void setTimeSinceSting(int time) {
if (time < 0) {
throw new IllegalArgumentException("Time since sting cannot be negative");
Copy link
Contributor

@Lulu13022002 Lulu13022002 Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a precondition, can you also rebuild patches to sort the AT file if you don't mind.
Can also put the @ NonNegative annotation for the api.

@Umbre11as
Copy link
Author

@Lulu13022002 Done. Used Preconditions.checkArgument() for validation, added @NonNegative annotation, also rebuilt patches as you asked

@Umbre11as Umbre11as requested a review from Machine-Maker July 5, 2025 12:39
@github-project-automation github-project-automation bot moved this from Changes required to Awaiting final testing in Paper PR Queue Jul 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Awaiting final testing
Development

Successfully merging this pull request may close these issues.

Add Bee#set/getTimeSinceSting() method
4 participants