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

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: 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;
          }

            Assignee:
            Unassigned
            Reporter:
            Parker Hawke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: