Search in sources :

Example 1 with InventoryProvider

use of fr.minuskube.inv.content.InventoryProvider in project Nexus by ProjectEdenGG.

the class MinigamesMenus method openCustomSettingsMenu.

@SneakyThrows
public void openCustomSettingsMenu(Player player, Arena arena) {
    Class<? extends InventoryProvider> provider = null;
    customMenus: for (Class<? extends InventoryProvider> menu : new Reflections("gg.projecteden.nexus.features.minigames.menus.custom").getSubTypesOf(InventoryProvider.class)) {
        for (Class<? extends Mechanic> superclass : arena.getMechanic().getSuperclasses()) {
            if (menu.getAnnotation(CustomMechanicSettings.class) != null) {
                List<Class<? extends Mechanic>> classes = Arrays.asList(menu.getAnnotation(CustomMechanicSettings.class).value());
                if (classes.contains(superclass)) {
                    provider = menu;
                    break customMenus;
                }
            }
        }
    }
    if (provider == null) {
        player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
        return;
    }
    SmartInventory INV = SmartInventory.builder().id("customSettingsMenu").provider(provider.getDeclaredConstructor(Arena.class).newInstance(arena)).title("Custom Settings Menu").size(3, 9).build();
    INV.open(player);
}
Also used : SmartInventory(fr.minuskube.inv.SmartInventory) Mechanic(gg.projecteden.nexus.features.minigames.models.mechanics.Mechanic) CustomMechanicSettings(gg.projecteden.nexus.features.minigames.menus.annotations.CustomMechanicSettings) List(java.util.List) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) Arena(gg.projecteden.nexus.features.minigames.models.Arena) Reflections(org.reflections.Reflections) SneakyThrows(lombok.SneakyThrows)

Aggregations

SmartInventory (fr.minuskube.inv.SmartInventory)1 InventoryProvider (fr.minuskube.inv.content.InventoryProvider)1 CustomMechanicSettings (gg.projecteden.nexus.features.minigames.menus.annotations.CustomMechanicSettings)1 Arena (gg.projecteden.nexus.features.minigames.models.Arena)1 Mechanic (gg.projecteden.nexus.features.minigames.models.mechanics.Mechanic)1 List (java.util.List)1 SneakyThrows (lombok.SneakyThrows)1 Reflections (org.reflections.Reflections)1