Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 7
By default, BendingGUI will add basic support for 3rd party elements just from having them installed. This will allow them to show up in the overview lore, as well as have a material set for its abilities in the config. SubElements of existing elements don't need to have support added at all.
If you want more support, you can create a class implementing the ElementSupport interface.
publicclassSpiritElementSupportimplementsElementSupport {
@OverridepublicElementgetElement() {
returnSpiritsSupport.SPIRIT; //The actual element object
}
@OverridepublicintgetOrderIndex() {
returnElementOrder.SPIRIT; //An integer that specifies where in the order this element should be
}
@OverridepublicMaterialgetSlotMaterial() {
returnMaterial.CYAN_STAINED_GLASS_PANE; //The slot glass pane to use when one of these abilities occupies a slot
}
@OverridepublicMaterialgetAbilityMaterial() {
returnMaterial.BLUE_GLAZED_TERRACOTTA; //The default material for abilities of this element
}
}The ElementOrder class contains methods and final variables for the different integer orders of all the elements. You can use this class to easily get a number if you so wish.
If you wish to make an element selectable on the Choose element menu, then make your class also implement the ChooseSupport interface
publicclassDarkElementSupportimplementsElementSupport, ChooseSupport {
@OverridepublicintgetChooseMenuIndex() {
return16; //The index to place the menu item on the choose menu. 0 is the very top left, 26 is the max (bottom right)
}
@OverridepublicElementgetElement() {
returnSpiritsSupport.DARK_SPIRIT; //The element object
}
@OverridepublicStringgetLangChooseTitle() {
return"&9Choose &3&lDark Spirit"; //The default title for choosing this element. Is added to the config as a default
}
@OverridepublicStringgetLangChooseLore() { //The default lore for choosing this element. Is added to the config as a defaultreturn"&7A Dark Spirit is a spirit corrupted by dark and chaotic energy. " +
"Because they are a being pure of energy, they are able to interact with the " +
"world differently to other beings";
}
@OverridepublicintgetOrderIndex() { returnElementOrder.SPIRIT_DARK; //An integer that specifies where in the order this element should be
}
@OverridepublicMaterialgetSlotMaterial() {
returnMaterial.CYAN_STAINED_GLASS_PANE; //The slot glass pane to use when one of these abilities occupies a slot
}
@OverridepublicStringgetLangOverviewName() {
returngetColor().toString().replace('\u00A7', '&') + "Dark Spirit"; //The name to use in the overview menu icon
}
@OverridepublicMaterialgetAbilityMaterial() {
returnMaterial.BLACK_GLAZED_TERRACOTTA; //The default material for abilities of this element
}
@OverridepublicMaterialgetChooseMaterial() {
returnMaterial.PURPLE_DYE; //The default material for the menu item to choose this element
}
@OverridepublicStringgetFancyName() {
return"Dark Spirit"; //A name to use instead of element.getName()
}
}After you have created a class implementing ElementSupport (and maybe ChooseSupport), you register it via the API class (com.strangeone101.bendinggui.API)
API.registerElementSupport(newDarkElementSupport());Note: The Spirit elements are just examples and are already provided by BendingGUI! You do not need to create these yourself to support the Spirits plugin
If you want to register a custom menu item on a menu, you can do so. The main thing you need is to make a method that returns a MenuItem and has the Menu you want to add to as the parameter of the method. For example...
publicclassRandomizerSupport {
publicstaticMenuItemrandomizeItem(MenuBendingOptionsmenu) {
if (!(menu.thePlayerinstanceofPlayer) || ((Player) menu.thePlayer).hasPermission("bending.command.randomize")) returnnull;
finalPlayerplayer = (Player) menu.thePlayer; //The player this menu is for. menu.openPlayer is the player viewing the menuMenuItemitem = newMenuItem(ChatColor.YELLOW + "Randomize Bending", Material.BEDROCK) {
@OverridepublicvoidonClick(Playerclicker) {
BendingPlayerbendingPlayer = BendingPlayer.getBendingPlayer(player);
Randomrandom = newRandom();
//Select a random main elementElementrandomElement = Element.getMainElements()[random.nextInt(Element.getMainElements().length)];
bendingPlayer.setElement(randomElement); //Set the elementGeneralMethods.saveElements(bendingPlayer); //Save to the databaseList<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(randomElement);
HashMap<Integer, String> abilitiesMap = newHashMap<>();
for (intslot = 1; slot <= 9; slot++) {
CoreAbilityabil = abilities.get(random.nextInt(abilities.size()));
while (abilinstanceofComboAbility || abil.isHiddenAbility() || abilinstanceofPassiveAbility) {
abil = abilities.get(random.nextInt(abilities.size()));
}
abilitiesMap.put(slot, abil.getName());
}
bendingPlayer.setAbilities(abilitiesMap); //Set the bindsBendingBoard.updateBoard(player); //Update the bending boardplayer.sendMessage(ChatColor.RED + "Chaos has been unleashed and your bending has been scrambled!");
}
};
item.addDescription(ChatColor.GRAY + "Randomize your bending");
returnitem;
}
}This class creates an item that sets the player's element to a random element, as well as sets random abilities to their binds.
Then you register it with
API.addCustomMenuIcon(MenuBendingOptions.class, RandomizerSupport::randomizeItem, 32);Index 32 is the 4th from the bottom right slot. Which is currently the only free slot in the main bending menu.
The following menus are supported:
MenuBendingOptions.class- The main bending menu that contains abilities, slots, toggles, etcMenuSelectElement.class- The menu for selecting an element. Either from having no element or from changing your elementMenuEditElements.class- The menu for editing what elements a player hasMenuPlayers.class- The menu for viewing the bending of all players on the serverMenuSelectPresets.class- The menu for viewing a player's presets