Skip to content

FireworkMeta#setPower Javadoc information incorrect #7409

@TehBrian

Description

@TehBrian

Expected behavior

Setting the FireworkMeta's power to 128 should succeed, as per the Javadoc:

/**
 * Sets the approximate power of the firework. Each level of power is half
 * a second of flight time.
 *
 * @param power the power of the firework, from 0-128
 * @throws IllegalArgumentException if {@literal height<0 or height>128}
 */
void setPower(int power) throws IllegalArgumentException;

Observed/Actual behavior

Calling fireworkMeta.setPower(128); resulted in an IllegalArgumentException:

[19:21:18 WARN]: java.lang.IllegalArgumentException: Power cannot be more than 127: 128
[19:21:18 WARN]: 	at org.apache.commons.lang.Validate.isTrue(Validate.java:93)
[19:21:18 WARN]: 	at org.bukkit.craftbukkit.v1_18_R1.inventory.CraftMetaFirework.setPower(CraftMetaFirework.java:404)
(irrelevant lines omitted)

Steps/models to reproduce

Run the following code in a plugin:

final ItemStack item = new ItemStack(Material.FIREWORK_ROCKET);
if (item.getItemMeta() instanceof FireworkMeta firework) {
    firework.setPower(128);
}

Plugin and Datapack List

Plugins (1): Iteminator
There are 2 data packs enabled: [vanilla (built-in)], [file/bukkit (world)]

Paper version

This server is running Paper version git-Paper-175 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) (Git: 9490475)
You are running the latest version

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.type: documentationDocumentation stuff

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions