-
-
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.
public class SpiritElementSupport implements ElementSupport {
@Override
public Element getElement() {
return SpiritsSupport.SPIRIT; //The actual element object
}
@Override
public int getOrderIndex() {
return ElementOrder.SPIRIT; //An integer that specifies where in the order this element should be
}
@Override
public Material getSlotMaterial() {
return Material.CYAN_STAINED_GLASS_PANE; //The slot glass pane to use when one of these abilities occupies a slot
}
@Override
public Material getAbilityMaterial() {
return Material.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
public class DarkElementSupport implements ElementSupport, ChooseSupport {
@Override
public int getChooseMenuIndex() {
return 16; //The index to place the menu item on the choose menu. 0 is the very top left, 26 is the max (bottom right)
}
@Override
public Element getElement() {
return SpiritsSupport.DARK_SPIRIT; //The element object
}
@Override
public String getLangChooseTitle() {
return "&9Choose &3&lDark Spirit"; //The default title for choosing this element. Is added to the config as a default
}
@Override
public String getLangChooseLore() { //The default lore for choosing this element. Is added to the config as a default
return "&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";
}
@Override
public int getOrderIndex() {
return ElementOrder.SPIRIT_DARK; //An integer that specifies where in the order this element should be
}
@Override
public Material getSlotMaterial() {
return Material.CYAN_STAINED_GLASS_PANE; //The slot glass pane to use when one of these abilities occupies a slot
}
@Override
public String getLangOverviewName() {
return getColor().toString().replace('\u00A7', '&') + "Dark Spirit"; //The name to use in the overview menu icon
}
@Override
public Material getAbilityMaterial() {
return Material.BLACK_GLAZED_TERRACOTTA; //The default material for abilities of this element
}
@Override
public Material getChooseMaterial() {
return Material.PURPLE_DYE; //The default material for the menu item to choose this element
}
@Override
public String getFancyName() {
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(new DarkElementSupport());
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...
public class RandomizerSupport {
public static MenuItem randomizeItem(MenuBendingOptions menu) {
if (!(menu.thePlayer instanceof Player) || ((Player) menu.thePlayer).hasPermission("bending.command.randomize")) return null;
final Player player = (Player) menu.thePlayer; //The player this menu is for. menu.openPlayer is the player viewing the menu
MenuItem item = new MenuItem(ChatColor.YELLOW + "Randomize Bending", Material.BEDROCK) {
@Override
public void onClick(Player clicker) {
BendingPlayer bendingPlayer = BendingPlayer.getBendingPlayer(player);
Random random = new Random();
//Select a random main element
Element randomElement = Element.getMainElements()[random.nextInt(Element.getMainElements().length)];
bendingPlayer.setElement(randomElement); //Set the element
GeneralMethods.saveElements(bendingPlayer); //Save to the database
List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(randomElement);
HashMap<Integer, String> abilitiesMap = new HashMap<>();
for (int slot = 1; slot <= 9; slot++) {
CoreAbility abil = abilities.get(random.nextInt(abilities.size()));
while (abil instanceof ComboAbility || abil.isHiddenAbility() || abil instanceof PassiveAbility) {
abil = abilities.get(random.nextInt(abilities.size()));
}
abilitiesMap.put(slot, abil.getName());
}
bendingPlayer.setAbilities(abilitiesMap); //Set the binds
BendingBoard.updateBoard(player); //Update the bending board
player.sendMessage(ChatColor.RED + "Chaos has been unleashed and your bending has been scrambled!");
}
};
item.addDescription(ChatColor.GRAY + "Randomize your bending");
return item;
}
}
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, etc -
MenuSelectElement.class
- The menu for selecting an element. Either from having no element or from changing your element -
MenuEditElements.class
- The menu for editing what elements a player has -
MenuPlayers.class
- The menu for viewing the bending of all players on the server -
MenuSelectPresets.class
- The menu for viewing a player's presets