105 lines
4.3 KiB
Kotlin
105 lines
4.3 KiB
Kotlin
package io.github.beradq.adybubbles
|
|
|
|
import org.bukkit.command.CommandSender
|
|
import org.bukkit.entity.Player
|
|
import taboolib.common.platform.command.*
|
|
import taboolib.platform.util.*
|
|
|
|
@CommandHeader("bubbles")
|
|
@Suppress("unused")
|
|
object BubblesCommand {
|
|
@CommandBody
|
|
@Suppress("unused")
|
|
val popup = subCommand {
|
|
dynamic("NPC_ID") {
|
|
suggestion<CommandSender>(uncheck = true) { _, _ ->
|
|
AdyBubbles.adyApi.getEntityFinder().getEntities().map { it.id }
|
|
}
|
|
dynamic("TEXT") {
|
|
execute<CommandSender> { sender, context, _ ->
|
|
val npcId = context["NPC_ID"]
|
|
val npcList = AdyBubbles.adyApi.getEntityFinder().getEntitiesFromId(npcId)
|
|
if (npcList.size == 1) {
|
|
BubblesBundle.popup(npcList.first().uniqueId, context["TEXT"])
|
|
} else {
|
|
sender.sendMessage("找到了${npcList.size}个NPC:")
|
|
npcList.withIndex().forEach {
|
|
sender.sendMessage("${it.index + 1}: ${it.value.uniqueId}")
|
|
}
|
|
sender.sendMessage("请通过聊天输入序号指定NPC")
|
|
(sender as Player).nextChatInTick(20 * 10, {
|
|
val npcUniqueId = npcList[it.toInt() - 1].uniqueId
|
|
BubblesBundle.popup(npcUniqueId, context["TEXT"])
|
|
}, {
|
|
sender.sendMessage("超时")
|
|
})
|
|
}
|
|
}
|
|
int("LIFE") {
|
|
execute<CommandSender> { sender, context, _ ->
|
|
val npcId = context["NPC_ID"]
|
|
val npcList = AdyBubbles.adyApi.getEntityFinder().getEntitiesFromId(npcId)
|
|
val text = context["TEXT"]
|
|
val lifetime = context.int("LIFE")
|
|
if (npcList.size == 1) {
|
|
BubblesBundle.popupTick(npcList.first().uniqueId, text, lifetime.toLong())
|
|
} else {
|
|
sender.sendMessage("找到了${npcList.size}个NPC:")
|
|
npcList.withIndex().forEach {
|
|
sender.sendMessage("${it.index + 1}: ${it.value.uniqueId}")
|
|
}
|
|
sender.sendMessage("请通过聊天输入序号指定NPC")
|
|
(sender as Player).nextChatInTick(20 * 10, {
|
|
val npcUniqueId = npcList[it.toInt() - 1].uniqueId
|
|
BubblesBundle.popupTick(npcUniqueId, text, lifetime.toLong())
|
|
}, {
|
|
sender.sendMessage("超时")
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@CommandBody
|
|
@Suppress("unused")
|
|
val clear = subCommand {
|
|
dynamic("NPC_ID") {
|
|
suggestion<CommandSender>(uncheck = true) { _, _ ->
|
|
AdyBubbles.adyApi.getEntityFinder().getEntities().map { it.id }
|
|
}
|
|
execute<CommandSender> { sender, context, _ ->
|
|
val npcId = context["NPC_ID"]
|
|
val npcList = AdyBubbles.adyApi.getEntityFinder().getEntitiesFromId(npcId)
|
|
if (npcList.size == 1) {
|
|
BubblesBundle.clear(npcList.first().uniqueId)
|
|
} else {
|
|
sender.sendMessage("找到了${npcList.size}个NPC:")
|
|
npcList.withIndex().forEach {
|
|
sender.sendMessage("${it.index + 1}: ${it.value.uniqueId}")
|
|
}
|
|
sender.sendMessage("请通过聊天输入序号指定NPC")
|
|
(sender as Player).nextChatInTick(20 * 10, {
|
|
val npc = npcList[it.toInt() - 1]
|
|
BubblesBundle.clear(npc.uniqueId)
|
|
}, {
|
|
sender.sendMessage("超时")
|
|
})
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@CommandBody
|
|
@Suppress("unused")
|
|
val reload = subCommand {
|
|
execute<CommandSender> { sender, _, _ ->
|
|
Config.reload()
|
|
sender.sendMessage("重载完成")
|
|
}
|
|
}
|
|
} |