@@ -7,47 +7,29 @@ import mindustry.world.Block
77import mindustry.world.blocks.storage.CoreBlock
88import java.util.*
99
10- @Suppress(" MemberVisibilityCanBePrivate" )
11- sealed class Log (val uid : String? , private val desc : () -> String ) {
10+ @Suppress(" MemberVisibilityCanBePrivate" , " CanBeParameter " )
11+ sealed class Log (val uid : String? , val desc : PlaceHoldString ) {
1212 val time = Date ()
1313
14- class Place (uid : String? , val type : Block ) : Log(uid, {
15- " 放置了方块${type.name} "
16- })
14+ class Place (uid : String? , val type : Block ) : Log(uid, " 放置了方块{block}" .with("block" to type))
15+ class Break (uid : String? ) : Log(uid, " 拆除了方块" .with())
16+ class Config (uid : String? , val value : String ) : Log(uid, " 修改了属性: {config}" .with("config" to value))
17+ class Deposit (uid : String? , val item : Item , val amount : Int ) :
18+ Log (uid, " 往里面丢了{amount}个{item}" .with (" item" to item, " amount" to amount))
1719
18- class Break (uid : String? ) : Log(uid, {
19- " 拆除了方块"
20- })
21-
22- class Config (uid : String? , val value : String ) : Log(uid, {
23- " 修改了属性: $value "
24- })
25-
26- class Deposit (uid : String? , val item : Item , val amount : Int ) : Log(uid, {
27- " 往里面丢了${amount} 个${item.name} "
28- })
29-
30- class Destroy : Log (null , {
31- " 拆毁了方块"
32- })
33-
34- class PickUp (uid : String? ) : Log(uid, {
35- " 拾起了方块"
36- })
37-
38- // TODO no event
39- // class PickDown(uid: String?, val type: Block) : Log(uid, {
40- // "放下了方块: ${type.name}"
41- // })
20+ class Destroy : Log (null , " 拆毁了方块" .with())
21+ class PickUp (uid : String? ) : Log(uid, " 拾起了方块" .with())
22+ class PickDown (uid : String? , val type : Block ) : Log(uid, " 放下了方块: {block}" .with("block" to type))
4223
4324 fun descLog (descPrefix : String = ""): PlaceHoldString {
44- val desc = descPrefix + desc()
4525 return if (uid == null ) {
46- " [red]{time:HH:mm:ss}[]-[yellow]未知单位[white]{desc}" .with (" time" to time, " desc" to desc)
26+ " [red]{time:HH:mm:ss}[]-[yellow]未知单位[white]{descPrefix}{desc}" .with (
27+ " time" to time, " descPrefix" to descPrefix, " desc" to desc
28+ )
4729 } else {
4830 val info = netServer.admins.getInfo(uid)
49- " [red]{time:HH:mm:ss}[]-[yellow]{info.name}[yellow]({info.shortID})[white]{desc}"
50- .with (" time" to time, " desc" to desc, " info" to info)
31+ " [red]{time:HH:mm:ss}[]-[yellow]{info.name}[yellow]({info.shortID})[white]{descPrefix}{ desc}"
32+ .with (" time" to time, " descPrefix " to descPrefix, " desc" to desc, " info" to info)
5133 }
5234 }
5335}
@@ -101,8 +83,11 @@ listen<EventType.BlockDestroyEvent> {
10183listen<EventType .PickupEvent > {
10284 val build = it.build ? : return @listen
10385 // As the build has removed when pickup, use tileOn instead
104- val tile = build.tileOn()
105- log(tile.array(), Log .PickUp (it.carrier.player?.uuid()))
86+ log(build.tileOn().array(), Log .PickUp (it.carrier.player?.uuid()))
87+ }
88+ listen<EventType .PayloadDropEvent > {
89+ val build = it.build ? : return @listen
90+ log(build.tile.array(), Log .PickDown (it.carrier.player?.uuid(), build.block))
10691}
10792
10893fun Player.showLog (xf : Float , yf : Float ) {
@@ -131,7 +116,7 @@ fun Player.showLog(xf: Float, yf: Float) {
131116// 查询
132117val enabledPlayer = mutableSetOf<String >()
133118command(" history" , " 开关查询模式" ) {
134- permission = " wayzer.ext.history"
119+ requirePermission( " wayzer.ext.history" )
135120 usage = " [core(查询核心)]"
136121 aliases = listOf (" 历史" )
137122 body {
0 commit comments