diff --git a/backend/mirai-console/src/internal/util/PluginServiceHelper.kt b/backend/mirai-console/src/internal/util/PluginServiceHelper.kt index 86dc84dab..c65e16135 100644 --- a/backend/mirai-console/src/internal/util/PluginServiceHelper.kt +++ b/backend/mirai-console/src/internal/util/PluginServiceHelper.kt @@ -14,7 +14,6 @@ package net.mamoe.mirai.console.internal.util import net.mamoe.mirai.console.internal.data.cast import net.mamoe.mirai.console.internal.data.createInstanceOrNull import net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl -import java.io.InputStream import java.lang.reflect.Modifier import java.util.* import kotlin.reflect.KClass @@ -30,9 +29,13 @@ internal object PluginServiceHelper { fun ClassLoader.findServices(vararg serviceTypes: KClass): ServiceList = serviceTypes.flatMap { serviceType -> - getResourceAsStream("META-INF/services/" + serviceType.qualifiedName!!) - ?.use(InputStream::readBytes) - ?.let(::String)?.lines()?.filter(String::isNotBlank).orEmpty() + getResourceAsStream("META-INF/services/" + serviceType.qualifiedName!!)?.let { stream -> + stream.bufferedReader().useLines { lines -> + lines.filter(String::isNotBlank) + .filter { it[0] != '#' } + .toList() + } + }.orEmpty() }.let { ServiceList(this, it) } fun ServiceList.loadAllServices(): List {