@@ -7,12 +7,16 @@ import org.bukkit.Bukkit
7
7
import org.bukkit.Material
8
8
import org.bukkit.Statistic
9
9
import org.bukkit.ban.ProfileBanList
10
+ import taboolib.common5.util.replace
10
11
import top.alazeprt.aonebot.action.SendGroupMessage
11
12
import top.alazeprt.aonebot.event.message.GroupMessageEvent
12
13
import top.alazeprt.aqqbot.AQQBot
13
14
import top.alazeprt.aqqbot.AQQBot.config
14
15
import top.alazeprt.aqqbot.DependencyImpl.Companion.playerStats
15
16
import top.alazeprt.aqqbot.DependencyImpl.Companion.withPAPI
17
+ import top.alazeprt.aqqbot.util.AI18n.get
18
+ import top.alazeprt.aqqbot.util.AI18n.getList
19
+ import top.alazeprt.aqqbot.util.AI18n.getOriginList
16
20
import java.text.SimpleDateFormat
17
21
18
22
class StatsHandler {
@@ -41,25 +45,30 @@ class StatsHandler {
41
45
private fun getStats (groupId : Long , userId : Long ) {
42
46
if (playerStats == null ) {
43
47
AQQBot .oneBotClient.action(SendGroupMessage (groupId,
44
- " 服务器尚未安装PlayerStats插件, 无法获取玩家统计信息! 请联系服务器管理员! " , true ))
48
+ get( " qq.stats.not_installed_dependency " ) , true ))
45
49
return
46
50
}
47
51
if (! AQQBot .dataMap.containsKey(userId.toString())) {
48
- AQQBot .oneBotClient.action(SendGroupMessage (groupId, " 你尚未绑定账号! 无法获取玩家统计信息! " , true ))
52
+ AQQBot .oneBotClient.action(SendGroupMessage (groupId, get( " qq.stats.not_bind " ) , true ))
49
53
return
50
54
}
51
55
val name = AQQBot .dataMap[userId.toString()]!!
52
56
val banEntry = Bukkit .getBanList<ProfileBanList >(BanList .Type .PROFILE ).getBanEntry(name)
57
+ val uuid = Bukkit .getOfflinePlayer(name).uniqueId
58
+ val lastLogin = Bukkit .getOfflinePlayer(uuid).lastPlayed
53
59
if (banEntry != null ) {
54
60
val banTime = banEntry.created
55
61
val expireTime = banEntry.expiration
56
62
val reason = banEntry.reason
57
- AQQBot .oneBotClient.action(SendGroupMessage (groupId, " QQ号: ${userId} \n " +
58
- " 游戏名: ${name} \n " +
59
- " 在线状态: 封禁\n " +
60
- " 封禁原因: ${reason} \n " +
61
- " 封禁时间: ${format.format(banTime)} \n " +
62
- " 解封时间: ${if (expireTime == null ) " 永久封禁" else format.format(expireTime)} " ))
63
+ AQQBot .oneBotClient.action(SendGroupMessage (groupId, getList(" qq.stats.result.ban" , mutableMapOf (
64
+ Pair (" userId" , userId.toString()),
65
+ Pair (" name" , name),
66
+ Pair (" reason" , reason ? : get(" qq.stats.result.dont_have_reason" )),
67
+ Pair (" ban_time" , format.format(banTime)),
68
+ Pair (" unban_time" , if (expireTime == null ) " 永久封禁" else format.format(expireTime)),
69
+ Pair (" last_login_time" , if (lastLogin == 0L ) get(" qq.stats.result.did_not_login" ) else format.format(lastLogin)),
70
+ Pair (" uuid" , uuid.toString())
71
+ ))))
63
72
return
64
73
}
65
74
val mob_killed = playerStats!! .statManager.executePlayerStatRequest(PlayerStatRequest (name)
@@ -72,29 +81,39 @@ class StatsHandler {
72
81
.untyped(Statistic .SPRINT_ONE_CM )).value
73
82
val mine_ancient_debris = playerStats!! .statManager.executePlayerStatRequest(PlayerStatRequest (name)
74
83
.blockOrItemType(Statistic .MINE_BLOCK , Material .ANCIENT_DEBRIS )).value
75
- val uuid = Bukkit .getOfflinePlayer(name).uniqueId
76
- val lastLogin = Bukkit .getOfflinePlayer(uuid).lastPlayed
77
- var message = " QQ号: ${userId} \n " +
78
- " 游戏名: ${name} \n " +
79
- " 在线状态: ${ if (Bukkit .getOfflinePlayer(name).isOnline) " 在线 " else " 离线 " } \n " +
80
- " 上次登录时间: ${ if (lastLogin == 0L ) " 你还没有有玩过捏 " else format.format(lastLogin)} \n " +
81
- " UUID: ${uuid} \n " +
82
- " 击杀怪物数: ${mob_killed ? : 0 } \n " +
83
- " 在线时长: ${ if (online_time == null ) 0 else formatDuration(online_time / 20 )} \n " +
84
- " 行走距离: ${ if (walk_distance == null && run_distance == null ) 0 else if ( walk_distance == null ) run_distance / 100.0
85
- else if (run_distance == null ) walk_distance / 100.0 else (run_distance + walk_distance) / 100 } m \n " +
86
- " 挖掘残骸数: ${mine_ancient_debris ? : 0 } "
84
+ var messageList = getOriginList( " qq.stats.result.normal " , mutableMapOf (
85
+ Pair ( " userId " , userId.toString()),
86
+ Pair ( " name " , name),
87
+ Pair ( " online " , if ( Bukkit .getOfflinePlayer(name).isOnline) " 在线 " else " 离线 " ),
88
+ Pair ( " last_login_time " , if (lastLogin == 0L ) " 你还没有有玩过捏 " else format.format(lastLogin)),
89
+ Pair ( " uuid " , uuid.toString()),
90
+ Pair ( " kill_mobs_count " , mob_killed?.toString() ? : " 0 " ),
91
+ Pair ( " online_time " , if (online_time == null ) " 0 " else formatDuration(online_time / 20 )),
92
+ Pair ( " walk_distance " , if (walk_distance == null && run_distance == null ) " 0 " else if (walk_distance == null ) (run_distance / 100.0 ).toString()
93
+ else if (run_distance == null ) (walk_distance / 100.0 ).toString() else ((run_distance + walk_distance) / 100 ).toString()),
94
+ Pair ( " break_ancient_debris_count " , mine_ancient_debris?.toString() ? : " 0 " )
95
+ ))
87
96
if (config.getBoolean(" stats.party.enable" ) && withPAPI && Bukkit .getOfflinePlayer(name).isOnline) {
88
97
var party = PlaceholderAPI .setPlaceholders(Bukkit .getOfflinePlayer(name), config.getString(" stats.party.placeholder" )!! )
89
98
if (config.getBoolean(" stats.party.format" )) party = formatString(party)
90
- message + = " \n 组织: ${party.ifEmpty { " 你还没有加入组织捏" }} "
99
+ messageList = messageList.replace(Pair (" \$ {organization}" , party.ifEmpty { get(" qq.stats.result.dont_have_organization" ) }))
100
+ .toMutableList()
101
+ } else {
102
+ messageList.removeIf {
103
+ it.contains(" \$ {organization}" )
104
+ }
91
105
}
92
106
if (config.getBoolean(" stats.prefix.enable" ) && withPAPI && Bukkit .getOfflinePlayer(name).isOnline) {
93
107
var prefix = PlaceholderAPI .setPlaceholders(Bukkit .getOfflinePlayer(name), config.getString(" stats.prefix.placeholder" )!! )
94
108
if (config.getBoolean(" stats.prefix.format" )) prefix = formatString(prefix)
95
- message + = " \n 称号: ${prefix.ifEmpty { " 你还没有称号捏" }} "
109
+ messageList =
110
+ messageList.replace(Pair (" \$ {prefix}" , prefix.ifEmpty { get(" qq.stats.result.dont_have_prefix" ) })).toMutableList()
111
+ } else {
112
+ messageList.removeIf {
113
+ it.contains(" \$ {prefix}" )
114
+ }
96
115
}
97
- AQQBot .oneBotClient.action(SendGroupMessage (groupId, message , true ))
116
+ AQQBot .oneBotClient.action(SendGroupMessage (groupId, messageList.joinToString( " \n " ) , true ))
98
117
}
99
118
100
119
0 commit comments