Package com.ultikits.ultitools.utils
Class PluginInstallUtils
java.lang.Object
com.ultikits.ultitools.utils.PluginInstallUtils
Utility class for plugin installation and management operations.
Provides methods to download, install, and uninstall UltiTools plugins
from the remote plugin repository.
插件安装和管理操作的实用工具类。 提供从远程插件仓库下载、安装和卸载UltiTools插件的方法。
插件安装和管理操作的实用工具类。 提供从远程插件仓库下载、安装和卸载UltiTools插件的方法。
- Since:
- 6.0.0
- Author:
- wisdomme
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringencodePathSegment(String value) private static StringencodeQueryValue(String value) static FilefindPluginJar(File pluginsFolder, String identifyString) Find the JAR file for a plugin by its identify-string.(package private) static StringGet the base URL for API calls.static PluginEntityGet plugin information by identify string.static StringgetPluginLatestDownloadLink(String idString) Get plugin latest version download link.static StringgetPluginLatestVersion(String idString) Get plugin latest version.static List<PluginEntity> getPluginList(int page, int pageSize) Get plugin list online.static StringgetPluginVersionDownloadLink(String idString, String version) Get plugin download link.getPluginVersions(String idString) Get plugin versions.(package private) static StringinstalledJarName(String idString, String version) static booleaninstallLatestPlugin(String idString) Install latest plugin.static booleaninstallPlugin(String idString, String version) Install plugin.private static StringnormalizeIdentifyString(String idString) (package private) static voidReset the base URL to force re-initialization.(package private) static voidSet a custom base URL for testing purposes.static booleanuninstallPlugin(String name) Uninstall plugin.private static <T> TunwrapData(String body, Class<T> clazz) Extract the "data" field from a backend API envelope response.private static <T> TunwrapData(String body, Type type) Extract the "data" field from a backend API envelope response (generic type version).private static StringunwrapStringData(String body) Extract a String value from the "data" field of a backend API envelope response.static booleanupdatePlugin(String identifyString) Update a plugin module: download latest version and delete old JAR.
-
Field Details
-
LOGGER
-
GSON
private static final com.google.gson.Gson GSON -
baseUrl
-
customBaseUrl
-
-
Constructor Details
-
PluginInstallUtils
public PluginInstallUtils()
-
-
Method Details
-
getBaseUrl
Get the base URL for API calls. Uses lazy initialization to avoid requiring UltiTools at class loading time.
获取API调用的基础URL。 使用延迟初始化以避免在类加载时需要UltiTools。- Returns:
- the base URL
-
setBaseUrlForTesting
Set a custom base URL for testing purposes. This should only be used in unit tests.
设置自定义的基础URL,仅用于测试目的。- Parameters:
url- the custom base URL, or null to reset to default
-
resetBaseUrl
static void resetBaseUrl()Reset the base URL to force re-initialization. This should only be used in unit tests.
重置基础URL以强制重新初始化,仅用于测试目的。 -
normalizeIdentifyString
-
encodeQueryValue
-
encodePathSegment
-
installedJarName
-
unwrapData
Extract the "data" field from a backend API envelope response. The backend wraps responses as {"code":"200","msg":"Success","data":...}.
从后端API信封响应中提取"data"字段。- Type Parameters:
T- the target type- Parameters:
body- the raw JSON response bodyclazz- the class to deserialize the data field into- Returns:
- the deserialized data, or null if absent or response indicates error
-
unwrapData
Extract the "data" field from a backend API envelope response (generic type version).
从后端API信封响应中提取"data"字段(泛型版本)。- Type Parameters:
T- the target type- Parameters:
body- the raw JSON response bodytype- the Type to deserialize the data field into- Returns:
- the deserialized data, or null if absent or response indicates error
-
unwrapStringData
Extract a String value from the "data" field of a backend API envelope response. Handles both quoted JSON strings and primitive values.
从后端API信封响应的"data"字段中提取字符串值。- Parameters:
body- the raw JSON response body- Returns:
- the data as a String, or null if absent or response indicates error
-
getPluginList
Get plugin list online.
在线获取插件列表。- Parameters:
page- 页数pageSize- 每页数量- Returns:
- 插件列表
-
getPluginVersionDownloadLink
Get plugin download link.
获取插件下载链接。- Parameters:
idString- 插件IDversion- 版本- Returns:
- 插件下载链接
-
getPluginVersions
Get plugin versions.
获取插件版本列表。- Parameters:
idString- 插件ID- Returns:
- 插件版本列表
-
getPluginLatestVersion
Get plugin latest version.
获取插件最新版本。- Parameters:
idString- 插件ID- Returns:
- 插件最新版本
-
getPluginLatestDownloadLink
Get plugin latest version download link.
获取插件最新版本下载链接。- Parameters:
idString- Plugin identify string
插件ID- Returns:
- Download link for latest version
插件最新版本下载链接
-
getPlugin
Get plugin information by identify string.
通过标识字符串获取插件信息。- Parameters:
idString- Plugin identify string
插件ID- Returns:
- Plugin entity or null if not found
插件信息,未找到返回null
-
installLatestPlugin
Install latest plugin.
安装最新插件。- Parameters:
idString- 插件ID- Returns:
- 是否安装成功
-
installPlugin
Install plugin.
安装插件。- Parameters:
idString- 插件IDversion- 版本- Returns:
- 是否安装成功
-
findPluginJar
Find the JAR file for a plugin by its identify-string. Scans all JARs in the given directory, reads plugin.yml from each.
通过identify-string查找插件的JAR文件。- Parameters:
pluginsFolder- the folder to scanidentifyString- the identify-string to match- Returns:
- the matching JAR file, or null if not found
-
updatePlugin
Update a plugin module: download latest version and delete old JAR.
更新插件模块:下载最新版本并删除旧JAR。- Parameters:
identifyString- the plugin identify string- Returns:
- true if update succeeded
-
uninstallPlugin
Uninstall plugin.
卸载插件。- Parameters:
name- 插件名称- Returns:
- 是否卸载成功
- Throws:
IOException- if an I/O error occurs
-