Skip to content

Inappropriate use of short for slot positions #8

@Touchie771

Description

@Touchie771

Issue Description

The SlotItem record uses short for the itemSlot parameter, which is unusual and error-prone for inventory slot positions. Slots are naturally integers (0-53), and using short provides no benefit while potentially causing confusion.

Location

  • SlotItem.java line 29
  • Menu.java lines 86, 159, 339, 388

Issues with using short:

  1. Unnecessary casting when working with array indices
  2. Confusing API - users expect int for positions
  3. No performance benefit for modern JVMs
  4. Can cause signed/unsigned confusion

Suggested Fix

Change itemSlot type from short to int:

public record SlotItem(
    @Nullable Component itemName,
    int itemSlot,  // Changed from short
    @Nullable Material material,
    int quantity,
    // ... rest of parameters

Impact

Better API design and less confusion for users. The change would be breaking but worth it for API clarity.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions