diff --git a/gradle.properties b/gradle.properties index 9b96041..4612b6c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=online.bingiz.bilibili.video -version=1.4.5 +version=1.4.6 diff --git a/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/ApiHandler.kt b/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/ApiHandler.kt index b1d5af1..35b6e8c 100644 --- a/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/ApiHandler.kt +++ b/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/ApiHandler.kt @@ -1,8 +1,8 @@ package online.bingiz.bilibili.video.internal.handler +import online.bingiz.bilibili.video.internal.helper.debug import online.bingiz.bilibili.video.internal.helper.debugStatus import taboolib.common.platform.ProxyPlayer -import taboolib.common.platform.function.info abstract class ApiHandler { private var nextHandler: ApiHandler? = null @@ -17,7 +17,7 @@ abstract class ApiHandler { protected fun callNextHandler(player: ProxyPlayer, bvid: String, sessData: String): Boolean { return nextHandler?.handle(player, bvid, sessData) ?: let { if (debugStatus) { - info("最终处理器 > 玩家: ${player.name} | 视频: $bvid | 通过") + debug("最终处理器 > 玩家: ${player.name} | 视频: $bvid | 通过") } true } diff --git a/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/CoinsHandler.kt b/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/CoinsHandler.kt index 1bacbc9..b6e7042 100644 --- a/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/CoinsHandler.kt +++ b/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/CoinsHandler.kt @@ -1,11 +1,9 @@ package online.bingiz.bilibili.video.internal.handler import online.bingiz.bilibili.video.internal.engine.NetworkEngine -import online.bingiz.bilibili.video.internal.helper.debugStatus +import online.bingiz.bilibili.video.internal.helper.debug import online.bingiz.bilibili.video.internal.helper.infoAsLang import taboolib.common.platform.ProxyPlayer -import taboolib.common.platform.function.info -import taboolib.common.platform.function.warning /** * Coins handler @@ -15,17 +13,13 @@ import taboolib.common.platform.function.warning */ class CoinsHandler : ApiHandler() { override fun handle(player: ProxyPlayer, bvid: String, sessData: String): Boolean { - if (debugStatus) { - info("硬币处理器 > 玩家: ${player.name} | 视频: $bvid | 接受处理") - } + debug("硬币处理器 > 玩家: ${player.name} | 视频: $bvid | 接受处理") NetworkEngine.bilibiliAPI.hasCoins(bvid, sessData).execute().let { if (it.isSuccessful) { it.body()?.data?.multiply?.let { count -> if (count < 1) { player.infoAsLang("GetTripleStatusFailureNotCoins") - if (debugStatus) { - warning("硬币处理器 > 玩家: ${player.name} | 视频: $bvid | 硬币不足") - } + debug("硬币处理器 > 玩家: ${player.name} | 视频: $bvid | 硬币不足") return false } } @@ -33,9 +27,7 @@ class CoinsHandler : ApiHandler() { player.infoAsLang("NetworkRequestFailureCode", it.code()) } } - if (debugStatus) { - info("硬币处理器 > 玩家: ${player.name} | 视频: $bvid | 移交处理") - } + debug("硬币处理器 > 玩家: ${player.name} | 视频: $bvid | 移交处理") return callNextHandler(player, bvid, sessData) } } diff --git a/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/FavouredHandler.kt b/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/FavouredHandler.kt index ca579f7..9feb7c6 100644 --- a/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/FavouredHandler.kt +++ b/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/FavouredHandler.kt @@ -1,11 +1,9 @@ package online.bingiz.bilibili.video.internal.handler import online.bingiz.bilibili.video.internal.engine.NetworkEngine -import online.bingiz.bilibili.video.internal.helper.debugStatus +import online.bingiz.bilibili.video.internal.helper.debug import online.bingiz.bilibili.video.internal.helper.infoAsLang import taboolib.common.platform.ProxyPlayer -import taboolib.common.platform.function.info -import taboolib.common.platform.function.warning /** * Favoured handler @@ -15,17 +13,13 @@ import taboolib.common.platform.function.warning */ class FavouredHandler : ApiHandler() { override fun handle(player: ProxyPlayer, bvid: String, sessData: String): Boolean { - if (debugStatus) { - info("收藏处理器 > 玩家: ${player.name} | 视频: $bvid | 接受处理") - } + debug("收藏处理器 > 玩家: ${player.name} | 视频: $bvid | 接受处理") NetworkEngine.bilibiliAPI.hasFavoured(bvid, sessData).execute().let { resultResponse -> if (resultResponse.isSuccessful) { resultResponse.body()?.data?.let { if (it.favoured.not()) { player.infoAsLang("GetTripleStatusFailureNotFavoured") - if (debugStatus) { - warning("收藏处理器 > 玩家: ${player.name} | 视频: $bvid | 未收藏") - } + debug("收藏处理器 > 玩家: ${player.name} | 视频: $bvid | 未收藏") return false } } @@ -33,9 +27,7 @@ class FavouredHandler : ApiHandler() { player.infoAsLang("NetworkRequestFailureCode", resultResponse.code()) } } - if (debugStatus) { - info("收藏处理器 > 玩家: ${player.name} | 视频: $bvid | 移交处理") - } + debug("收藏处理器 > 玩家: ${player.name} | 视频: $bvid | 移交处理") return callNextHandler(player, bvid, sessData) } } diff --git a/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/FollowingHandler.kt b/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/FollowingHandler.kt index 58ed10a..e957943 100644 --- a/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/FollowingHandler.kt +++ b/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/FollowingHandler.kt @@ -2,11 +2,9 @@ package online.bingiz.bilibili.video.internal.handler import online.bingiz.bilibili.video.internal.config.SettingConfig import online.bingiz.bilibili.video.internal.engine.NetworkEngine -import online.bingiz.bilibili.video.internal.helper.debugStatus +import online.bingiz.bilibili.video.internal.helper.debug import online.bingiz.bilibili.video.internal.helper.infoAsLang import taboolib.common.platform.ProxyPlayer -import taboolib.common.platform.function.info -import taboolib.common.platform.function.warning /** * Following handler @@ -16,18 +14,14 @@ import taboolib.common.platform.function.warning */ class FollowingHandler : ApiHandler() { override fun handle(player: ProxyPlayer, bvid: String, sessData: String): Boolean { - if (debugStatus) { - info("关注处理器 > 玩家: ${player.name} | 视频: $bvid | 接受处理") - } + debug("关注处理器 > 玩家: ${player.name} | 视频: $bvid | 接受处理") if (SettingConfig.needFollow) { NetworkEngine.bilibiliAPI.hasFollowing(bvid, sessData).execute().let { resultResponse -> if (resultResponse.isSuccessful) { resultResponse.body()?.data?.let { if (it.card.following.not()) { player.infoAsLang("GetTripleStatusFailureNotFollowing") - if (debugStatus) { - warning("关注处理器 > 玩家: ${player.name} | 视频: $bvid | 未关注") - } + debug("关注处理器 > 玩家: ${player.name} | 视频: $bvid | 未关注") return false } } @@ -36,9 +30,7 @@ class FollowingHandler : ApiHandler() { } } } - if (debugStatus) { - info("关注处理器 > 玩家: ${player.name} | 视频: $bvid | 移交处理") - } + debug("关注处理器 > 玩家: ${player.name} | 视频: $bvid | 移交处理") return callNextHandler(player, bvid, sessData) } } diff --git a/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/LikeHandler.kt b/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/LikeHandler.kt index 77986f5..b2e780e 100644 --- a/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/LikeHandler.kt +++ b/src/main/kotlin/online/bingiz/bilibili/video/internal/handler/LikeHandler.kt @@ -1,11 +1,9 @@ package online.bingiz.bilibili.video.internal.handler import online.bingiz.bilibili.video.internal.engine.NetworkEngine -import online.bingiz.bilibili.video.internal.helper.debugStatus +import online.bingiz.bilibili.video.internal.helper.debug import online.bingiz.bilibili.video.internal.helper.infoAsLang import taboolib.common.platform.ProxyPlayer -import taboolib.common.platform.function.info -import taboolib.common.platform.function.warning /** * Like handler @@ -15,17 +13,13 @@ import taboolib.common.platform.function.warning */ class LikeHandler : ApiHandler() { override fun handle(player: ProxyPlayer, bvid: String, sessData: String): Boolean { - if (debugStatus) { - info("点赞处理器 > 玩家: ${player.name} | 视频: $bvid | 接受处理") - } + debug("点赞处理器 > 玩家: ${player.name} | 视频: $bvid | 接受处理") NetworkEngine.bilibiliAPI.hasLike(bvid, sessData).execute().let { if (it.isSuccessful) { it.body()?.data?.let { count -> if (count < 1) { player.infoAsLang("GetTripleStatusFailureNotLike") - if (debugStatus) { - warning("点赞处理器 > 玩家: ${player.name} | 视频: $bvid | 未点赞") - } + debug("点赞处理器 > 玩家: ${player.name} | 视频: $bvid | 未点赞") return false } } @@ -33,9 +27,7 @@ class LikeHandler : ApiHandler() { player.infoAsLang("NetworkRequestFailureCode", it.code()) } } - if (debugStatus) { - info("点赞处理器 > 玩家: ${player.name} | 视频: $bvid | 移交处理") - } + debug("点赞处理器 > 玩家: ${player.name} | 视频: $bvid | 移交处理") return callNextHandler(player, bvid, sessData) } } diff --git a/src/main/kotlin/online/bingiz/bilibili/video/internal/helper/DebugHelper.kt b/src/main/kotlin/online/bingiz/bilibili/video/internal/helper/DebugHelper.kt new file mode 100644 index 0000000..c24a5d3 --- /dev/null +++ b/src/main/kotlin/online/bingiz/bilibili/video/internal/helper/DebugHelper.kt @@ -0,0 +1,14 @@ +package online.bingiz.bilibili.video.internal.helper + +import taboolib.common.platform.function.info +import taboolib.module.chat.colored + +/** + * Debug + * Debug Helper + * + * @param message Message + */ +internal fun debug(message: String) { + info("&7&l[&a&ldebug&7&l] > &f&l$message".colored()) +}