채팅 비우기 메시지 수정
This commit is contained in:
parent
dc29e0e251
commit
727769a170
1 changed files with 39 additions and 34 deletions
|
|
@ -32,8 +32,9 @@ object ChatCommand {
|
||||||
private fun hasPermissionOrSend(player: ServerPlayer?, requiredLevel: Int = 2): Boolean {
|
private fun hasPermissionOrSend(player: ServerPlayer?, requiredLevel: Int = 2): Boolean {
|
||||||
if (player != null && !player.hasPermissions(requiredLevel)) {
|
if (player != null && !player.hasPermissions(requiredLevel)) {
|
||||||
player.sendSystemMessage(
|
player.sendSystemMessage(
|
||||||
Component.literal("해당 명령어를 실행할 권한이 없습니다.")
|
Component.literal("해당 명령어를 실행할 권한이 없습니다.").withStyle {
|
||||||
.withStyle { it.withColor(ChatFormatting.RED) }
|
it.withColor(ChatFormatting.RED)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
@ -42,20 +43,22 @@ object ChatCommand {
|
||||||
|
|
||||||
private fun registerReloadCommand(root: String, sub: String, event: RegisterCommandsEvent) {
|
private fun registerReloadCommand(root: String, sub: String, event: RegisterCommandsEvent) {
|
||||||
event.dispatcher.register(
|
event.dispatcher.register(
|
||||||
Commands.literal(root).then(
|
Commands.literal(root)
|
||||||
|
.then(
|
||||||
Commands.literal(sub).executes { context ->
|
Commands.literal(sub).executes { context ->
|
||||||
val player = getPlayerOrNull(context.source)
|
val player = getPlayerOrNull(context.source)
|
||||||
if (!hasPermissionOrSend(player)) return@executes 0
|
if (!hasPermissionOrSend(player)) return@executes 0
|
||||||
|
|
||||||
ChatConfig.loadConfig()
|
ChatConfig.loadConfig()
|
||||||
|
|
||||||
val success = Component.literal("채팅 형식을 새로고침했습니다.")
|
val success =
|
||||||
.withStyle { it.withColor(ChatFormatting.GOLD) }
|
Component.literal("채팅 형식을 새로고침했습니다.").withStyle {
|
||||||
|
it.withColor(ChatFormatting.GOLD)
|
||||||
|
}
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
context.source.sendSuccess({ success }, false)
|
context.source.sendSuccess({ success }, false)
|
||||||
else
|
else player.sendSystemMessage(success)
|
||||||
player.sendSystemMessage(success)
|
|
||||||
|
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
@ -65,20 +68,22 @@ object ChatCommand {
|
||||||
|
|
||||||
private fun registerClearCommand(root: String, sub: String, event: RegisterCommandsEvent) {
|
private fun registerClearCommand(root: String, sub: String, event: RegisterCommandsEvent) {
|
||||||
event.dispatcher.register(
|
event.dispatcher.register(
|
||||||
Commands.literal(root).then(
|
Commands.literal(root)
|
||||||
|
.then(
|
||||||
Commands.literal(sub).executes { context ->
|
Commands.literal(sub).executes { context ->
|
||||||
val player = getPlayerOrNull(context.source)
|
val player = getPlayerOrNull(context.source)
|
||||||
if (!hasPermissionOrSend(player)) return@executes 0
|
if (!hasPermissionOrSend(player)) return@executes 0
|
||||||
|
|
||||||
val server = context.source.server
|
val server = context.source.server
|
||||||
val allPlayers = server.playerList.players.filterIsInstance<ServerPlayer>()
|
val allPlayers =
|
||||||
|
server.playerList.players.filterIsInstance<
|
||||||
|
ServerPlayer>()
|
||||||
ChatUtils.clearChatForAll(allPlayers)
|
ChatUtils.clearChatForAll(allPlayers)
|
||||||
|
|
||||||
server.playerList.broadcastSystemMessage(
|
server.playerList.broadcastSystemMessage(
|
||||||
Component.literal("📢")
|
Component.literal("\u00A0\u00A0채팅창을 비웠습니다.").withStyle {
|
||||||
.append(Component.literal("\u00A0\u00A0채팅창을 비웠습니다.")
|
it.withColor(ChatFormatting.AQUA)
|
||||||
.withStyle { it.withColor(ChatFormatting.AQUA) }
|
},
|
||||||
),
|
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue