Skip to content

Damage Source #7876

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 17 commits into
base: dev/feature
Choose a base branch
from

Conversation

Absolutionism
Copy link
Contributor

Problem

No current support for Damage Sources, including reading and checking data of damage sources, no previous event values for damage sources, and unable to create custom damage sources

Solution

New module for damage sources. Adds expressions and conditions to get/set/check the data of damage sources
Updates EffHealth to allow use of custom damage sources
DamageSourceWrapper for a continuous data setting of a custom damage source.

Testing Completed

The newly created test file

Supporting Information

Had to add an ignore list in ClassLoaderTest because when loading the DamageSourceWrapper on 1.19.4, was throwing an exception.


Completes: none
Related: none

@Absolutionism Absolutionism requested review from a team as code owners May 18, 2025 17:19
@Absolutionism Absolutionism requested review from UnderscoreTud and erenkarakal and removed request for a team May 18, 2025 17:19
@skriptlang-automation skriptlang-automation bot added the needs reviews A PR that needs additional reviews label May 18, 2025
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

I'm still not a huge fan of having some sources be editable and some not
I'd like some others' opinions on the topic, whether it should be allowed as is or if sources should be only editable upon creation (say, within the exprsec). It would mean the wrapper class wouldn't be needed.

@sovdeeth sovdeeth added the up for debate When the decision is yet to be debated on the issue in question label May 19, 2025
@Fusezion
Copy link
Contributor

I'm in agreeance with sovde here, a damage source should only be modifiable via the exprsec as a means to limit ambiguity, unsure how it would allow removal of the wrapper, it's still needed I would assume unless we store custom information onto the event.

@sovdeeth
Copy link
Member

I'm in agreeance with sovde here, a damage source should only be modifiable via the exprsec as a means to limit ambiguity, unsure how it would allow removal of the wrapper, it's still needed I would assume unless we store custom information onto the event.

You can just store a builder on the exprsection, yes

@Absolutionism
Copy link
Contributor Author

You can just store a builder on the exprsection, yes

We would still need the wrapper for a couple of reasons.
To even initiate the builder, would need a DamageType, granted that could be mitigated by simply requiring it in the pattern of the ExprSec
The Builder doesnt extend DamageSource so it wouldn't be viable for an event-value and the default expression.
Another is that with the Builder, there are no getters. So if something is set then there's no way to ensure the finalization is valid. Which the only check needed to be done is to ensure that if causing entity is set, then the direct entity needs to be set, or else get an IllegalArgumentException

I feel the wrapper should be kept, since DamageSource is still experimental, if the API was updated to allow control over more aspects, then the wrapper would be nice to have.

@sovdeeth
Copy link
Member

You can just store a builder on the exprsection, yes

We would still need the wrapper for a couple of reasons. To even initiate the builder, would need a DamageType, granted that could be mitigated by simply requiring it in the pattern of the ExprSec The Builder doesnt extend DamageSource so it wouldn't be viable for an event-value and the default expression. Another is that with the Builder, there are no getters. So if something is set then there's no way to ensure the finalization is valid. Which the only check needed to be done is to ensure that if causing entity is set, then the direct entity needs to be set, or else get an IllegalArgumentException

I feel the wrapper should be kept, since DamageSource is still experimental, if the API was updated to allow control over more aspects, then the wrapper would be nice to have.

The event-value thing could be easily done via just building the builder when necessary, but I see your point about future proofing given this api still seems very unfinished.

@Absolutionism Absolutionism requested a review from sovdeeth May 19, 2025 18:19
@Absolutionism Absolutionism requested a review from sovdeeth May 20, 2025 16:02
@Absolutionism
Copy link
Contributor Author

btw, can you remove the up for debate now?

@sovdeeth sovdeeth removed the up for debate When the decision is yet to be debated on the issue in question label May 22, 2025
@sovdeeth sovdeeth added the feature Pull request adding a new feature. label May 22, 2025
@Absolutionism Absolutionism requested a review from sovdeeth May 26, 2025 21:56
@Absolutionism Absolutionism requested a review from sovdeeth May 29, 2025 02:08
Copy link
Member

@sovdeeth sovdeeth left a comment

Choose a reason for hiding this comment

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

seems good

@sovdeeth sovdeeth added the breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) label May 30, 2025
@sovdeeth sovdeeth moved this to Needs Reviews in 2.12 Release Jun 3, 2025
public class ExprDirectEntity extends SimplePropertyExpression<DamageSource, Entity> implements DamageSourceExperiment {

static {
registerDefault(ExprDirectEntity.class, Entity.class, "direct entity", "damagesources");
Copy link
Member

Choose a reason for hiding this comment

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

i was thinking about the direct/indirect syntaxes and had a possible suggestion
Since direct entity of ... doesn't really mean much on its own, what do you think about:

[in]direct (source|cause) of %damagesource%

I'm not sure about source of source or whatever, and maybe it'd be better to include the work 'entity'.
You can also combine this class and the indirect class

idk it might be better it might be worse, let me know what you think

Copy link
Member

Choose a reason for hiding this comment

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

i think that could be good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer to keep the 3 elements separated since DamageSource is still experimental. Even if there was a high likelihood that the behavior wouldn't change.

Copy link
Member

Choose a reason for hiding this comment

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

What do you think about the syntax change, though?

Copy link
Member

@APickledWalrus APickledWalrus left a comment

Choose a reason for hiding this comment

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

I think this is looking really good so far. Here's what I found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) feature Pull request adding a new feature. needs reviews A PR that needs additional reviews
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

4 participants