class ItemManager(private val dataFolder: File, private val plugin: LemonMines) { private val itemParser: ItemParser = ItemParser(plugin, this) val itemUtils: ItemUtils = ItemUtils(plugin) val loaded: MutableSet = mutableSetOf() fun loadItems() { val itemsPath = "$dataFolder/items" val file = File(itemsPath); if(!file.exists()) { plugin.logger.info("$itemsPath does not exist, creating directory") file.parentFile.mkdirs(); file.mkdirs(); return; } val itemFiles = file.walkBottomUp().toList() .stream() .filter { it.name.endsWith(".json") } .collect(Collectors.toList()) if(itemFiles.isEmpty()) plugin.logger.warning("Directory $itemsPath is empty, ignoring it") itemFiles.forEach { val lemonItem = itemParser.parseItemFile(it.absolutePath) ?: return; plugin.logger.info("Custom item with id ${lemonItem.id} loaded successfully") loaded.add(lemonItem) } plugin.logger.info("All items have been loaded successfully") } }