use of gg.projecteden.nexus.features.menus.api.content.InventoryProvider in project Nexus by ProjectEdenGG.
the class MechanicsMenu method openCustomSettingsMenu.
@SneakyThrows
public static void openCustomSettingsMenu(Player player, Arena arena) {
Class<? extends InventoryProvider> provider = null;
customMenus: for (Class<? extends InventoryProvider> menu : new Reflections(ICustomMechanicMenu.class.getPackageName()).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;
}
final InventoryProvider menu = provider.getDeclaredConstructor(Arena.class).newInstance(arena);
arena.write();
menu.open(player);
}
Aggregations