Skip to content

Fix has item checks with uppercase hex colours and malformed head textures - #316

Open
entity wants to merge 1 commit into
HelpChat:mainfrom
entity:fix/has-item-hex-and-texture-parsing
Open

entity wants to merge 1 commit into
HelpChat:mainfrom
entity:fix/has-item-hex-and-texture-parsing

Conversation

@entity

@entity entity commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Two bugs in the has item requirement. I found both while reviewing the Paper migration (#228).

1. Uppercase hex colours never match

StringUtils#legacyColor kept the case of hex digits (&#AABBCC → §x§A§A§B§B§C§C). Names and lore read back from an item are always serialized in lowercase (§x§a§a§b§b§c§c). A strict name/lore check therefore failed whenever the menu used uppercase hex, even against the exact item DeluxeMenus had created from that config. The hex digits are now lowercased. This doesn't change the rendered colour.

Comparing legacyColor(configured) against legacy(colorItemText(configured)):

Configured name Before After
&#aabbcc&lHello match match
&#AABBCC&lHello no match match
&a&lHello match match

2. Malformed head textures crash the check

SkullUtils#decodeSkinUrl threw IllegalArgumentException (invalid base64) or JsonSyntaxException (not a JSON object). texture- and basehead- has item checks decode every head they inspect, and nothing caught these errors. One head from another plugin with a non-standard texture value in a player's inventory was enough to make the requirement throw. Before the migration, texture- checks read the skin through the Bukkit profile API and didn't hit this. Malformed values are now treated as having no skin URL.

I tested getTextureIdFromBase64 with: a valid texture (returns the id), invalid base64, non-object JSON ("hello", [1,2]), empty input, and wrong-typed textures/SKIN/url fields. Every malformed input now returns null; before, they threw.

I also checked that the plugin still boots, loads its menus and reloads on Paper 26.2 build 112.

… textures

- StringUtils#legacyColor kept the case of '&#RRGGBB' hex digits, while names and
  lore read back from items are always serialized lowercase, so strict has item
  name/lore checks failed whenever a menu used uppercase hex.
- SkullUtils#decodeSkinUrl threw IllegalArgumentException / JsonSyntaxException
  on texture values that are not valid base64 or not the expected JSON shape.
  Since texture- and basehead- has item checks decode every head in the
  inventory, a single malformed head from another plugin broke the requirement.
  Malformed values are now treated as having no skin url.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant