Add attributes
Add custom attributes to the item editor where each item can set them to different values
// PowerScrolls example
provider.addAddon(
new PluginAddon("PowerScrolls", XMaterial.WRITABLE_BOOK.get())
.attribute(
new AddonAttribute<>(
"Is a scroll", // Attribute name
XMaterial.WRITTEN_BOOK.get(), // GUI material
false, // Default value
(player, gui, editor, callback) -> {
Boolean current = (Boolean) editor
.getAttributeSerializableByName("PowerScrolls_Is a scroll") // Name format is "%AddonName%_%AttributeName%"
.getValue();
callback.result(!current); // Callback the new value
editor.createAddonGui(provider.getAddonByName("PowerScrolls"))
.openInventory(player); // Create a new gui for the addon and open it to the player
},
"&7If true, the item will be used to upgrade",
"&7other items and add abilities to them.",
"",
"&aClick to toggle" // Some lore to explain what this attribute does.
)
)
);Last updated