Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7225

FireworkMeta#getPower() can throw a NullPointerException for items with no power set

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • CraftBukkit versions following 0a1c89e4b1c
    • Yes

      As of this commit allowing for negative power, the `power` field has become type `Integer` allowing it to be null (by default). The `getPower()` method does not, however, check for its nullability and does an unboxing operation to return a primitive `int`. This can be quickly fixed with a ternary.

          @Override
          public int getPower() {
      -        return this.power;
      +        return hasPower() ? this.power : 0;
          }

            Unassigned Unassigned
            2008Choco Parker Hawke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: