MapPalette Valid Range for getColor(byte) Needs Updating for 1.12

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None
    • Environment:

      MacOS

    • Magic

      I have a plugin that setsĀ blocks in-game from map items (e.g. pixel art using wool blocks). It works using MapPalette.imageToBytes, and then passing each of those bytes to MapPalette.getColor(byte).

      This worked prior to 1.12, but now in 1.12 I will sometimes get an IndexOutOfBoundsException.

      I believe this is due to the commit that added more colors:

      https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/5ad2ecf658276b8aae336b0e5bfb894a5151b578#src/main/java/org/bukkit/map/MapPalette.java

      But the valid ranges for bytes was not updated to include the new colors:

      https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/map/MapPalette.java#249

      I am not certain I know how to fix this correctly myself, so I would appreciate some feedback. If no one has a fix ready I will give it a shot when I get a chance.

      It may also be that matchColor needs updating as well, though I am not sure.

            Assignee:
            Unassigned
            Reporter:
            Nathan Wolf
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: