Skip to content

Conversation

@MrScopes
Copy link
Contributor

@MrScopes MrScopes commented Dec 23, 2025

Problem

This event could be useful in some situations.
https://jd.papermc.io/paper/1.21.11/io/papermc/paper/event/player/PrePlayerAttackEntityEvent.html

Solution

Added on attempt attack and on attempt[ing] to attack %entitydatas%
Added [the] (entity|victim) (:will|will not|won't) be attack(ed|ing) decided not to include since it's effectively useless. the event is fired as canceled if the entity won't be attacked

Testing Completed

Tested my examples given. Everything works as expected

                    on attack attempt:
                        if event is cancelled:
                            broadcast "%attacker% failed to attack %victim%!"
                        else:
                            broadcast "%attacker% damaged %victim%!"

                    on attempt to attack an animal:
                        cancel event        

                    on attempting to attack an entity:
                        if victim is a creeper:
                            cancel event     

                    on attempt to attack a zombie or creeper:
                        attacker isn't holding a diamond sword
                        cancel event

Supporting Information

ExprAttacked and ExprAttacker also updated to support this event, and I also updated the code in both classes to follow new conventions


Completes: 8266
Related: none
AI assistance: none

@MrScopes MrScopes requested a review from a team as a code owner December 23, 2025 08:26
@MrScopes MrScopes requested review from Pesekjak and TheMug06 and removed request for a team December 23, 2025 08:26
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label Dec 23, 2025
@sovdeeth
Copy link
Member

Note that listening to cancelled events does not require the config, you can simply do on cancelled X or on any X

@MrScopes
Copy link
Contributor Author

Note that listening to cancelled events does not require the config, you can simply do on cancelled X or on any X

Good to know. I can update the examples and description with that + whatever else is decided

@sovdeeth sovdeeth added the feature Pull request adding a new feature. label Dec 24, 2025
Copy link
Member

@Efnilite Efnilite left a comment

Choose a reason for hiding this comment

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

looks good after sovde's changes

@skriptlang-automation skriptlang-automation bot added needs reviews A PR that needs additional reviews and removed needs reviews A PR that needs additional reviews labels Dec 25, 2025
@MrScopes
Copy link
Contributor Author

MrScopes commented Jan 2, 2026

Decided on

on attempt[ing] to attack %entitydatas%
on attack attempt

@Efnilite
Copy link
Member

Efnilite commented Jan 3, 2026

additionally you should change the target branch to dev/feature

@MrScopes MrScopes changed the base branch from master to dev/feature January 3, 2026 16:39
@MrScopes
Copy link
Contributor Author

MrScopes commented Jan 3, 2026

unsure how if at all, build failure is related to my code

Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
@Efnilite
Copy link
Member

Efnilite commented Jan 3, 2026

unsure how if at all, build failure is related to my code

the test run crashed, happens sometimes 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Pull request adding a new feature. needs reviews A PR that needs additional reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants