Skip to content
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

Change creeper max fuse and no damage ticks to timespan #5225

Open
wants to merge 20 commits into
base: dev/feature
Choose a base branch
from

Conversation

kiip1
Copy link
Contributor

@kiip1 kiip1 commented Nov 27, 2022

Description

Change creeper max fuse and no damage ticks from amount of ticks to timespan, although the former was logical due to it being the property in Bukkit, it doesn't align with the rest of Skript's syntax, therefore it should be timespan instead.


Related Issues:

@Moderocky
Copy link
Member

This will be a breaking change for users without sufficient justification. You could support the original format as an additional pattern.

@TheLimeGlass
Copy link
Collaborator

This syntax can also support a primed tnt in the future, so it's a scuffed addition but we have to deal with it now.

I like this syntax change.

@TheLimeGlass TheLimeGlass added enhancement Feature request, an issue about something that could be improved, or a PR improving something. breaking changes Pull or feature requests that contain breaking changes (API, syntax, etc.) labels Nov 28, 2022
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.

Looks pretty good. Might be worth discussing Kenzie's proposal.

@kiip1 kiip1 requested review from APickledWalrus and removed request for Moderocky December 12, 2022 21:05
Copy link
Member

@AyhamAl-Ali AyhamAl-Ali left a comment

Choose a reason for hiding this comment

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

Nice PR ⚡

@kiip1 kiip1 requested review from AyhamAl-Ali and removed request for APickledWalrus December 13, 2022 16:06
@sovdeeth sovdeeth added the 2.9 Targeting a 2.9.X version release label Mar 19, 2024
@sovdeeth sovdeeth changed the base branch from master to dev/feature March 19, 2024 19:14
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'd be happy to take this over if you are no longer interested in working on it.


@Override
public Timespan convert(LivingEntity entity) {
return Timespan.fromTicks_i(entity instanceof Creeper ? ((Creeper) entity).getMaxFuseTicks() : 0);
Copy link
Member

Choose a reason for hiding this comment

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

It's different from the old expression behavior, but I'm wondering if it would be better to return null here if it is not a creeper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no "old expression behaviour" here (refer to other comment) so it would be good to return null.

@Override
@Nullable
public Class<?>[] acceptChange(ChangeMode mode) {
return (mode != ChangeMode.REMOVE_ALL) ? CollectionUtils.array(Timespan.class) : null;
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 it would be better to use a switch here and check for the accepted modes rather than against.

break;
case DELETE:
case SET:
creeper.setMaxFuseTicks(Math.max(amount, 0));
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
creeper.setMaxFuseTicks(Math.max(amount, 0));
creeper.setMaxFuseTicks(amount);

amount should always be greater than 0 here

Copy link
Member

Choose a reason for hiding this comment

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

Might be worth keeping this for backwards compatibility like ExprNoDamageTicks


@Override
protected String getPropertyName() {
return "creeper max fuse time";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return "creeper max fuse time";
return "creeper maximum fuse time";

assert {_m}'s invulnerability time is 1 tick with "no damage time add ##2 failed"
delete {_m}'s invulnerability time
assert {_m}'s invulnerability time is 0 seconds with "no damage time delete failed"
delete {_m}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
delete {_m}
delete the entity within {_m}

public class ExprNoDamageDuration extends SimplePropertyExpression<LivingEntity, Timespan> {

static {
register(ExprNoDamageDuration.class, Timespan.class, "(invulnerability|no damage) (time|duration)", "livingentities");
Copy link
Member

Choose a reason for hiding this comment

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

any reason invincibility was removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My change was due to it not being refered to as "invincibility" in Bukkit, but for consistency it can be re-added.

if (!super.init(exprs, matchedPattern, isDelayed, parseResult))
return false;

Skript.warning("Switch from deprecated 'no damage ticks' to 'no damage duration', as the deprecated expression will be removed in 2.8.");
Copy link
Member

Choose a reason for hiding this comment

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

Could be good to use the deprecation warning: #6549


@Override
protected String getPropertyName() {
return "no damage time";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return "no damage time";
return "no damage duration";

since we refer to it as duration in the docs

@Description("How much time an entity is invulnerable for.")
@Examples({"on damage:",
"\tset victim's invulnerability time to 1 second # victim will not take damage for the next second"})
@Since("2.5, INSERT VERSION (Use Timespan)")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@Since("2.5, INSERT VERSION (Use Timespan)")
@Since("INSERT VERSION")

I'm tempted to say this since it's essentially a different syntax (though it returns the same property). I'd like thoughts though.

Copy link
Contributor Author

@kiip1 kiip1 left a comment

Choose a reason for hiding this comment

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

@APickledWalrus feel free to take this PR over :)

public class ExprCreeperMaxFuseTicks extends SimplePropertyExpression<LivingEntity, Long> {

static {
if(Skript.methodExists(LivingEntity.class, "getMaxFuseTicks"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This syntax has never actually worked since LivingEntity doesn't have getMaxFuseTicks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Member

Choose a reason for hiding this comment

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

lol


@Override
public Timespan convert(LivingEntity entity) {
return Timespan.fromTicks_i(entity instanceof Creeper ? ((Creeper) entity).getMaxFuseTicks() : 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no "old expression behaviour" here (refer to other comment) so it would be good to return null.

public class ExprNoDamageDuration extends SimplePropertyExpression<LivingEntity, Timespan> {

static {
register(ExprNoDamageDuration.class, Timespan.class, "(invulnerability|no damage) (time|duration)", "livingentities");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My change was due to it not being refered to as "invincibility" in Bukkit, but for consistency it can be re-added.

Comment on lines +21 to +22
delete {_m}
delete {_n}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR was before this syntax was released :)

@APickledWalrus APickledWalrus self-assigned this Jun 20, 2024
@sovdeeth sovdeeth removed the 2.9 Targeting a 2.9.X version release label Jun 28, 2024
Copy link
Member

@Moderocky Moderocky left a comment

Choose a reason for hiding this comment

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

Branch conflicts need resolving.

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.) enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants