Skip to content

Commit d492539

Browse files
authored
Implement ACTION defining by ACTION TYPE (#1938)
This change implements a new way how to define actions via a custom panel template. Previously there were 2 options how to define an action: - by click-type - as an array list This adds the third type: by action type. It means that now developers could code that action is the main key for defining what happens when button is clicked: ``` actions: visit: click-type: LEFT tooltip: Tooltip text for left click action ```
1 parent fa68f8f commit d492539

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/java/world/bentobox/bentobox/api/panels/reader/TemplateReader.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,24 @@ else if (section.isString(FALLBACK) && reusableItemMap != null)
360360
itemRecord.addAction(actionData);
361361
}
362362
}
363+
else
364+
{
365+
ConfigurationSection actionDataSection = actionSection.getConfigurationSection(actionKey);
366+
367+
if (actionDataSection != null && actionDataSection.contains("click-type"))
368+
{
369+
clickType = Enums.getIfPresent(ClickType.class,
370+
actionDataSection.getString("click-type", "UNKNOWN").toUpperCase()).
371+
or(ClickType.UNKNOWN);
372+
373+
ItemTemplateRecord.ActionRecords actionData =
374+
new ItemTemplateRecord.ActionRecords(clickType,
375+
actionKey,
376+
actionDataSection.getString("content"),
377+
actionDataSection.getString("tooltip"));
378+
itemRecord.addAction(actionData);
379+
}
380+
}
363381
});
364382
}
365383
}

0 commit comments

Comments
 (0)