Skip to content

Add event for player toggling entity age lock#8555

Open
CrebsTheCoder wants to merge 17 commits into
SkriptLang:dev/featurefrom
CrebsTheCoder:feature/age-lock
Open

Add event for player toggling entity age lock#8555
CrebsTheCoder wants to merge 17 commits into
SkriptLang:dev/featurefrom
CrebsTheCoder:feature/age-lock

Conversation

@CrebsTheCoder

@CrebsTheCoder CrebsTheCoder commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Problem

Would be usefull to check if a player locks an entity age

Solution

Registered an event to be called wen a player locks an entity age

Testing Completed

on player toggle entity age lock:
    broadcast "%player% has toggled the age lock for %event-entity% using %event-item%"
image

Supporting Information


Completes: none
Related: none
AI assistance: none

@CrebsTheCoder CrebsTheCoder requested a review from a team as a code owner April 17, 2026 12:12
@CrebsTheCoder CrebsTheCoder requested review from Efnilite and Pesekjak and removed request for a team April 17, 2026 12:12
@skriptlang-automation skriptlang-automation Bot added the needs reviews A PR that needs additional reviews label Apr 17, 2026
@TheMug06

Copy link
Copy Markdown
Contributor

Please target dev/feature or dev/patch instead of master. (feature in this case)

Mb dawg i just copied it off the EvtBread
@CrebsTheCoder CrebsTheCoder changed the base branch from master to dev/feature April 17, 2026 12:18
@CrebsTheCoder

Copy link
Copy Markdown
Contributor Author

Please target dev/feature or dev/patch instead of master. (feature in this case)

Oops sorry

@Absolutionism Absolutionism left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unsure if there is a delay when applying the new age lock to the entity.
Should check this to see if a EventValueExpression is needed, or if users can simply check the age lock on the event-entity to determine the behavior they wish to proceed with.

@Absolutionism

Copy link
Copy Markdown
Contributor

btw, no big concern, but the code snippet you provided does not match the output shown in the screenshot.

@Absolutionism Absolutionism left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A JUnit test would be nice

CrebsTheCoder and others added 3 commits April 18, 2026 12:57
Comment thread src/test/skript/junit/EvtPlayerToggleEntityTest.sk
Comment thread src/test/skript/junit/EvtPlayerToggleEntityTest.sk Outdated
@skriptlang-automation skriptlang-automation Bot removed the needs reviews A PR that needs additional reviews label Apr 19, 2026
CrebsTheCoder and others added 4 commits April 19, 2026 21:27
…nts/events/EvtPlayerToggleEntityAge.java

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
…nts/events/EvtPlayerToggleEntityAge.java

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
…t changes syntax because "test "EvtPlayerToggleEntityAge" if running minecraft "26.1" doesn't exist
@CrebsTheCoder CrebsTheCoder requested a review from Efnilite April 19, 2026 15:35

@Efnilite Efnilite left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

almost there 🙏

Comment thread src/test/skript/junit/EvtPlayerToggleEntityTest.sk Outdated
@sovdeeth sovdeeth added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Apr 20, 2026
@CrebsTheCoder CrebsTheCoder requested a review from sovdeeth April 21, 2026 14:44

@sovdeeth sovdeeth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks great

@APickledWalrus APickledWalrus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few thoughts!

Comment thread src/test/skript/junit/EvtPlayerToggleEntityTest.sk

@APickledWalrus APickledWalrus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nearly ready, good work so far

Comment on lines +46 to +47
EventValues.registerEventValue(PlayerToggleEntityAgeLockEvent.class, LivingEntity.class, PlayerToggleEntityAgeLockEvent::getEntity);
EventValues.registerEventValue(PlayerToggleEntityAgeLockEvent.class, ItemStack.class, PlayerToggleEntityAgeLockEvent::getItem);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can use updated event value registration. See BukkitEventValues for many examples

.addEvent(PlayerToggleEntityAgeLockEvent.class)
.addPatterns("[player] entity age ([:un]lock|toggle:toggle) [of %-entitytypes%]")
.addDescription("Called when a player toggles the age lock of an entity using a golden dandelion.")
.addExample("""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would split this into 3 separate examples (one per event)

…nts/events/EvtPlayerToggleEntityAge.java

Co-authored-by: SirSmurfy2 <82696841+Absolutionism@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature request, an issue about something that could be improved, or a PR improving something.

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

6 participants