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

Add elytra boost event, firework type and firework syntaxes #5956

Closed
wants to merge 11 commits into from

Conversation

TheLimeGlass
Copy link
Collaborator

Description

  • Adds Paper's elytra boost event.
  • Makes Firework a ClassInfo.
  • Adds Firework syntaxes.

Target Minecraft Versions: 1.18 for some 1.19 for some
Requirements: Paper for some syntaxes
Related Issues: #5826

@TheLimeGlass TheLimeGlass added enhancement Feature request, an issue about something that could be improved, or a PR improving something. feature Pull request adding a new feature. labels Aug 31, 2023
Copy link
Contributor

@Fusezion Fusezion left a comment

Choose a reason for hiding this comment

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

Only gone through this class too distracted rn to do more

Copy link
Contributor

@Fusezion Fusezion left a comment

Choose a reason for hiding this comment

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

Some other changes found, and concerns.

Copy link
Contributor

@Fusezion Fusezion left a comment

Choose a reason for hiding this comment

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

Couldn't find anything else to criticize so looks good to me.

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.

Meant to RC but commented instead

@TheLimeGlass TheLimeGlass changed the base branch from master to dev/feature October 7, 2023 05:15
@Examples({
"on player elytra boost:",
"\twill consume firework",
"\tset to consume the firework"
Copy link
Member

Choose a reason for hiding this comment

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

invalid example


static {
if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerElytraBoostEvent"))
Skript.registerCondition(CondElytraBoostConsume.class, "[event] (will [:not]|not:won't) consume [the] firework");
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 should be forced to include what is consuming the firework:

"[the] (event|player) (will [:not]|not:won't) consume [the] firework"

Comment on lines +65 to +67
if (!(event instanceof PlayerElytraBoostEvent))
return false;
return isNegated() && !((PlayerElytraBoostEvent) event).shouldConsume();
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
if (!(event instanceof PlayerElytraBoostEvent))
return false;
return isNegated() && !((PlayerElytraBoostEvent) event).shouldConsume();
if (event instanceof PlayerElytraBoostEvent)
return ((PlayerElytraBoostEvent) event).shouldConsume() ^ isNegated();
return false;

@Examples({
"on player elytra boost:",
"\twill consume firework",
"\tset to consume the firework"
Copy link
Member

Choose a reason for hiding this comment

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

invalid example


static {
if (Skript.classExists("com.destroystokyo.paper.event.player.PlayerElytraBoostEvent"))
Skript.registerEffect(EffElytraBoostConsume.class, "[not:do not] consume firework", "set consum(e|ption of) firework to %boolean%");
Copy link
Member

Choose a reason for hiding this comment

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

set consume of firework shouldn't be allowed.
also, what do you think about [un]cancel consumption of [the] firework or something similar?

Comment on lines +41 to +42
"How much time that the fireworks have been boosting the player in an <a href='events.html#elytra_boost'>elytra boost event</a>.",
"Maximum is the same as time until detonation. Paper names them differently than Spigot."
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
"How much time that the fireworks have been boosting the player in an <a href='events.html#elytra_boost'>elytra boost event</a>.",
"Maximum is the same as time until detonation. Paper names them differently than Spigot."
"How long a fireworks has been boosting the player in an <a href='events.html#elytra_boost'>elytra boost event</a>.",
"Maximum is the same as time until detonation."

Also, having maximum life time be the same as time until detonation is a poor naming scheme we shouldn't pass on. The maximum life time should be from the launch until detonation, and the time until detonation should be from the current moment until detonation.

Comment on lines +76 to +77
return Timespan.fromTicks_i(detonate ? firework.getTicksToDetonate() : firework.getTicksFlown());
return Timespan.fromTicks_i(detonate ? firework.getMaxLife() : firework.getLife());
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 Timespan.fromTicks_i(detonate ? firework.getTicksToDetonate() : firework.getTicksFlown());
return Timespan.fromTicks_i(detonate ? firework.getMaxLife() : firework.getLife());
return Timespan.fromTicks(detonate ? firework.getTicksToDetonate() : firework.getTicksFlown());
return Timespan.fromTicks(detonate ? firework.getMaxLife() : firework.getLife());


@Override
public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
long ticks = (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) ? 0 : ((Timespan) delta[0]).getTicks_i();
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
long ticks = (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) ? 0 : ((Timespan) delta[0]).getTicks_i();
long ticks = (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) ? 0 : ((Timespan) delta[0]).getTicks();

ticks = -ticks;
case ADD:
for (Firework firework : getExpr().getArray(event)) {
long existing = convert(firework).getTicks_i();
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
long existing = convert(firework).getTicks_i();
long existing = convert(firework).getTicks();

Comment on lines +137 to +154
case DELETE:
case RESET:
for (Firework firework : getExpr().getArray(event)) {
if (detonate) {
if (PAPER) {
firework.setTicksToDetonate((int) 20 * firework.getFireworkMeta().getPower());
} else {
firework.setMaxLife((int) 20 * firework.getFireworkMeta().getPower());
}
} else {
if (PAPER) {
firework.setTicksFlown((int) 20 * firework.getFireworkMeta().getPower());
} else {
firework.setLife((int) 20 * firework.getFireworkMeta().getPower());
}
}
}
break;
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 this is unintuitive.
Delete should not be a valid changer, in my opinion, or if it is, it should set the value to 0.
Reset can't reliably figure out what the lifespan should be, since it doesn't know how long it's flown already.
For that reason, Reset probably also shouldn't be valid, or if it is, it should set remaining time to the original amount and the ticks flown to 0.

@sovdeeth
Copy link
Member

closing due to inactivity

@sovdeeth sovdeeth closed this Sep 15, 2024
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. feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants