mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-07-01 12:57:24 +00:00
feat(extension): 支持从 Maven 仓库下载并安装扩展包.
支持该功能后, 可以使用户更容易安装扩展包, 尤其是无需配置的扩展包.
This commit is contained in:
@ -7,6 +7,7 @@ import org.eclipse.aether.artifact.Artifact
|
||||
import java.io.File
|
||||
import java.io.FileFilter
|
||||
import java.io.FilenameFilter
|
||||
import java.net.URL
|
||||
|
||||
internal fun ByteArray.toHaxString(): String = ByteUtils.bytesToHexString(this)
|
||||
|
||||
@ -93,4 +94,18 @@ private object UtilsInternal {
|
||||
log.debug { "All registered hook resources have been closed." }
|
||||
}, "Shutdown-AutoCloseable"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun URL.resolveToFile(canonical: Boolean = true): File {
|
||||
if ("file" != protocol) {
|
||||
throw ClassCastException("Only the URL of the `file` protocol can be converted into a File object.")
|
||||
}
|
||||
|
||||
val urlString = toString().substringAfter(':')
|
||||
val file = File(urlString)
|
||||
return if (canonical) {
|
||||
file.canonicalFile
|
||||
} else {
|
||||
file
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user