interface DungeonPlaceholder : DungeonComponent {
/**
* 占位符头
*/
val head: String
/**
* 所属插件
*/
val plugin: String
/**
* 例子
*/
val example: String
/**
* 支持的脚本类型列表,空则全部类型支持
*/
fun getSupportType(): Array<ScriptType>? {
return null
}
/**
* [dungeon] 地牢对应地牢
* [params] 参数,即 'hand:params' 某个 [ *值] 都为一参数值
*/
fun onRequest(dungeon: Dungeon, params: Array<String>): String? {
return null
}
/**
* [dungeon] 地牢对应地牢
* [params] 参数,即 'hand:params' 某个 [ *值] 都为一参数值
* [trigger] 触发者
*/
fun onRequest(dungeon: Dungeon, params: Array<String>, trigger: Entity?): String? {
return this.onRequest(dungeon, params)
}
}
package org.serverct.ersha.dungeon.internal.dungeon.placeholder
import org.serverct.ersha.dungeon.common.api.annotation.AutoRegister
import org.serverct.ersha.dungeon.common.api.component.placeholder.DungeonPlaceholder
import org.serverct.ersha.dungeon.common.api.component.script.type.ScriptType
import org.serverct.ersha.dungeon.internal.dungeon.Dungeon
@AutoRegister(registerMessage = false)
class DungeonMobPlaceholder : DungeonPlaceholder {
override val head: String = "mob"
override val example: String = "<mob:kill-amount/kill-contain *怪物名>"
override val plugin: String = "DungeonPlus"
override fun getSupportType(): Array<ScriptType> {
return arrayOf(ScriptType.SYSTEM, ScriptType.DUNGEON, ScriptType.PLAYER, ScriptType.TRIGGER_SELF)
}
override fun onRequest(dungeon: Dungeon, params: Array<String>): String? {
val name = params[1]
val monsterAnnal = dungeon.dungeonMeta.getOrDefault("monster-annal") {
mutableMapOf<String, Int>()
}
return when (params[0]) {
"kill-amount" -> (monsterAnnal[name] ?: 0).toString()
"kill-contain" -> monsterAnnal.containsKey(name).toString()
else -> null
}
}
}