Skip to content

Feature - Inventory & Chat Buttons - #304

Draft
ItsNature wants to merge 3 commits into
version/1.2.9from
feature/inventory-and-chat-buttons
Draft

Feature - Inventory & Chat Buttons#304
ItsNature wants to merge 3 commits into
version/1.2.9from
feature/inventory-and-chat-buttons

Conversation

@ItsNature

@ItsNature ItsNature commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Overview

Description:
Add Inventory Buttons and Chat Buttons, letting servers display clickable buttons on the player inventory and on the chat screen. Buttons are built on a new shared button system: they mix adventure components and icons inside a single button, support tooltips, custom shape/size/position, custom and hover colors, click actions, and live content and tooltips that re-resolve per viewer and resend automatically.

Full Docs:

Changes:

  • New shared button system ApolloButton:
    • ApolloButtonContent builder: text, icon and live content parts, content scale
    • ApolloButtonTooltip: static lines or a live resolver
    • ApolloButtonAction: runCommand, openUrl, clientAction (OPEN_MINIMAP_VIEW, OPEN_WAYPOINTS_MENU)
    • ApolloButtonShape: (ROUNDED_SQUARE, CIRCLE)
    • ApolloButtonSize
  • New InventoryModule API:
    • displayInventoryButtons(Recipients, Collection<InventoryButton>) & displayInventoryButton(Recipients, InventoryButton)
    • removeInventoryButton(Recipients, String) & removeInventoryButton(Recipients, InventoryButton)
    • resetInventoryButtons(Recipients)
    • updateInventoryButton(Recipients, String, ApolloButtonContent, ApolloButtonTooltip), updateInventoryButtonContent(...) & updateInventoryButtonTooltip(...)
    • New InventoryButton builder: box (LEFT/RIGHT), inventoryType, size presets & default colors
  • New ChatModule API:
    • displayChatButtons(Recipients, Collection<ChatButton>) & displayChatButton(Recipients, ChatButton)
    • removeChatButton(Recipients, String) & removeChatButton(Recipients, ChatButton)
    • resetChatButtons(Recipients)
    • updateChatButton(Recipients, String, ApolloButtonContent, ApolloButtonTooltip), updateChatButtonContent(...) & updateChatButtonTooltip(...)
    • New ChatButton builder with chat size presets
  • New options on both modules:
    • buttons.live-broadcast (default false): automatically re-resolves and re-sends live button content on each piece's own update interval; combined with the packet enrichment module, updates are only sent to players who currently have their inventory/chat open
    • buttons.send-defaults (default false) & buttons.defaults: define static buttons directly in config.yml, displayed automatically when a player joins
  • Packet Enrichment Module: new player-inventory-open / player-inventory-close packets and ApolloPlayerInventoryOpenEvent / ApolloPlayerInventoryCloseEvent

Code Example:

public void displayChatButtonsExample(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());

    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        ChatButton teamChat = ChatButton.builder()
            .id("team-chat")
            .position(HudPosition.of(0, 2))
            .size(ApolloButtonSize.of(70, 16))
            .shape(ApolloButtonShape.ROUNDED_SQUARE)
            .backgroundColor(ChatButton.DEFAULT_BACKGROUND_COLOR)
            .borderColor(ChatButton.DEFAULT_BORDER_COLOR)
            .content(ApolloButtonContent.builder()
                .append(ItemStackIcon.builder()
                    .itemName("SHIELD")
                    .build())
                .append(Component.text("Team Chat", NamedTextColor.GREEN))
                .scale(1.0F)
                .build())
            .tooltip(ApolloButtonTooltip.of(
                Component.text("Click to switch!", NamedTextColor.YELLOW)))
            .onClick(ApolloButtonAction.runCommand("/channel team"))
            .build();

        this.chatModule.displayChatButtons(apolloPlayer, Arrays.asList(teamChat));
    });
}

Review Request Checklist

  • Your code follows the style guidelines of this project.
  • I have performed a self-review of my code.
  • I have tested this change myself. (If applicable)
  • I have made corresponding changes to the documentation. (If applicable)
  • The branch name follows the projects naming conventions. (e.g. feature/add-module & bugfix/fix-issue)

@ItsNature ItsNature added type: Documentation Documentation improvement or issue type: Enhancement Feature improvement or addition labels Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: Documentation Documentation improvement or issue type: Enhancement Feature improvement or addition

Development

Successfully merging this pull request may close these issues.

2 participants