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);
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:
AnvilGUI version 1.9.2-SNAPSHOT
Reproducible example