[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with setting displaynames of items #317

Open
Thorinwasher opened this issue Feb 24, 2024 · 1 comment
Open

Issue with setting displaynames of items #317

Thorinwasher opened this issue Feb 24, 2024 · 1 comment

Comments

@Thorinwasher
Copy link
Thorinwasher commented Feb 24, 2024

Issue

I'm having problems with setting the displayname of the items. I want one of the displaynames to be "Cancel" in red, and another be "Accept" in green.

Behavior

When triggering the GUI, these items appear to have the default names. (Barrier and Green wool)

Versions

Server:

This server is running Paper version git-Paper-426 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 7ccefdc)
You are 9 version(s) behind
Download the new version at: https://papermc.io/downloads/paper

AnvilGUI version 1.9.2-SNAPSHOT

Reproducible example

        AnvilGUI.Builder builder = new AnvilGUI.Builder();
        ItemStack itemLeft = new ItemStack(Material.BARRIER);
        ItemMeta itemMetaLeft = itemLeft.getItemMeta();
        itemMetaLeft.displayName(Component.text("Cancel").color(NamedTextColor.RED));
        itemLeft.setItemMeta(itemMetaLeft);
        ItemStack itemOutput = new ItemStack(Material.GREEN_WOOL);
        ItemMeta itemMetaOutput = itemOutput.getItemMeta();
        itemMetaOutput.displayName(Component.text("Accept").color(NamedTextColor.GREEN));
        itemOutput.setItemMeta(itemMetaOutput);
        builder.itemLeft(itemLeft).itemOutput(itemOutput).title("Type flag arguments").plugin(plugin).text("");
        builder.onClickAsync((slot, stateSnapshot) -> CompletableFuture.supplyAsync(() -> {
            if (slot == AnvilGUI.Slot.INPUT_RIGHT) {
                return Collections.emptyList();
            }
            if (slot == AnvilGUI.Slot.OUTPUT) {
                action.accept(stateSnapshot.getText()); // Do whatever action I want with the string I fetched from the anvil
            }
            return List.of(AnvilGUI.ResponseAction.close());
        }));
        builder.interactableSlots(AnvilGUI.Slot.INPUT_LEFT, AnvilGUI.Slot.INPUT_RIGHT, AnvilGUI.Slot.OUTPUT);
        builder.open(activator);
@BoBkiNN
Copy link
BoBkiNN commented Mar 19, 2024

Same issue on 1.19.4 1.9.2-SNAPSHOT

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

No branches or pull requests

2 participants