-
-
Notifications
You must be signed in to change notification settings - Fork 368
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
base: dev/feature
Are you sure you want to change the base?
Conversation
This will be a breaking change for users without sufficient justification. You could support the original format as an additional pattern. |
src/test/skript/tests/syntaxes/expressions/ExprCreeperMaxFuseTicks.sk
Outdated
Show resolved
Hide resolved
src/test/skript/tests/syntaxes/expressions/ExprNoDamageTicks.sk
Outdated
Show resolved
Hide resolved
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. |
There was a problem hiding this 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.
src/main/java/ch/njol/skript/expressions/ExprCreeperMaxFuseTicks.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR ⚡
src/main/java/ch/njol/skript/expressions/ExprNoDamageTicks.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCreeperMaxFuseTicks.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprNoDamageTicks.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprNoDamageTicks.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprNoDamageTicks.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Ayham Al Ali <[email protected]>
src/main/java/ch/njol/skript/expressions/ExprCreeperMaxFuseTicks.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprNoDamageTicks.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/expressions/ExprCreeperMaxFuseDuration.java
Outdated
Show resolved
Hide resolved
bd134d0
to
3f08853
Compare
Co-authored-by: LimeGlass <[email protected]>
There was a problem hiding this 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creeper.setMaxFuseTicks(Math.max(amount, 0)); | |
creeper.setMaxFuseTicks(amount); |
amount should always be greater than 0 here
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
There was a problem hiding this 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")) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
delete {_m} | ||
delete {_n} |
There was a problem hiding this comment.
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 :)
There was a problem hiding this 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.
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: