LunarClient / Apollo

Next-generation Lunar Client server API
https://lunarclient.dev
MIT License
65 stars 15 forks source link

Feature - Notification Icons & NanoSVG support #147

Closed ItsNature closed 2 months ago

ItsNature commented 2 months ago

Overview

Description: Adds Icon support to Notifications with client-side changes that support SVG format.

Code Example (If applicable):

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

    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        this.notificationModule.displayNotification(apolloPlayer, Notification.builder()
            .titleComponent(Component.text("UHC Announcement", NamedTextColor.GREEN))
            .descriptionComponent(Component.text("UHC starts in 5 minutes...", NamedTextColor.RED)
                .appendNewline()
                .append(Component.text("Get ready!", NamedTextColor.WHITE))
                .appendNewline()
                .append(Component.text("Good luck!", NamedTextColor.GOLD))
            )
            .displayTime(Duration.ofSeconds(5))
            .icon(ItemStackIcon.builder()
                .itemName("GOLDEN_APPLE")
                .build()
            )
            .build()
        );
    });
}

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

    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        this.notificationModule.displayNotification(apolloPlayer, Notification.builder()
            .titleComponent(Component.text("UHC Announcement", NamedTextColor.GREEN))
            .descriptionComponent(Component.text("UHC starts in 5 minutes...", NamedTextColor.RED)
                .appendNewline()
                .append(Component.text("Get ready!", NamedTextColor.WHITE))
                .appendNewline()
                .append(Component.text("Good luck!", NamedTextColor.GOLD))
            )
            .displayTime(Duration.ofSeconds(5))
            .icon(SimpleResourceLocationIcon.builder()
                .resourceLocation("lunar:logo/logo-200x182.svg")
                .size(12)
                .build()
            )
            .build()
        );
    });
}

Screenshots and/or Videos (If applicable): Using ItemStackIcon image

Using SimpleResourceLocationIcon with an SVG image image


Review Request Checklist