Skip to content

Commit cce0977

Browse files
Fixed translation missing. Added status subcommand.
1 parent 6856ad1 commit cce0977

File tree

4 files changed

+41
-16
lines changed

4 files changed

+41
-16
lines changed

src/main/kotlin/NoMathExpectation/chatExchange/neoForged/ChatExchange.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ object ChatExchange {
3030
logger.log(Level.INFO, "Hello! This is working!")
3131
}
3232
}
33+
34+
internal fun String.replaceModId() = replace("modid", ChatExchange.ID)

src/main/kotlin/NoMathExpectation/chatExchange/neoForged/NeoForgeEvents.kt

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,35 @@ object NeoForgeEvents {
157157

158158
val command = Commands.literal("chatexchange")
159159
.then(
160+
Commands.literal("status").executes { context ->
161+
val player = context.source.player ?: return@executes 0
162+
163+
fun Boolean.toProperLiteral() =
164+
(if (this) "chatexchange.const.enabled" else "chatexchange.const.disabled").toTranslatableComponent()
165+
166+
player.sendSystemMessage(
167+
"chatexchange.command.chatexchange.status".toExchangeServerTranslatedLiteral(
168+
ChatExchangeConfig.chat.get().toProperLiteral(),
169+
ChatExchangeConfig.joinLeave.get().toProperLiteral(),
170+
ChatExchangeConfig.death.get().toProperLiteral(),
171+
ChatExchangeConfig.advancement.get().toProperLiteral()
172+
)
173+
)
174+
175+
1
176+
}
177+
).then(
160178
Commands.literal("broadcastme").then(
161179
Commands.argument("toggle", BoolArgumentType.bool()).executes { context ->
162180
val player = context.source.player ?: return@executes 0
163181
val data = player.server.chatExchangeData
164182
val toggle = BoolArgumentType.getBool(context, "toggle")
165183
if (toggle) {
166184
data.removeIgnoredPlayer(player.uuid)
167-
player.sendSystemMessage("modid.command.chatexchange.broadcastme.on".toExchangeServerTranslatedLiteral())
185+
player.sendSystemMessage("chatexchange.command.chatexchange.broadcastme.on".toExchangeServerTranslatedLiteral())
168186
} else {
169187
data.addIgnoredPlayer(player.uuid)
170-
player.sendSystemMessage("modid.command.chatexchange.broadcastme.off".toExchangeServerTranslatedLiteral())
188+
player.sendSystemMessage("chatexchange.command.chatexchange.broadcastme.off".toExchangeServerTranslatedLiteral())
171189
}
172190

173191
1
@@ -176,9 +194,9 @@ object NeoForgeEvents {
176194
val player = context.source.player ?: return@executes 0
177195
val data = player.server.chatExchangeData
178196
if (data.isIgnoredPlayer(player.uuid)) {
179-
player.sendSystemMessage("modid.command.chatexchange.broadcastme.isoff".toExchangeServerTranslatedLiteral())
197+
player.sendSystemMessage("chatexchange.command.chatexchange.broadcastme.isoff".toExchangeServerTranslatedLiteral())
180198
} else {
181-
player.sendSystemMessage("modid.command.chatexchange.broadcastme.ison".toExchangeServerTranslatedLiteral())
199+
player.sendSystemMessage("chatexchange.command.chatexchange.broadcastme.ison".toExchangeServerTranslatedLiteral())
182200
}
183201

184202
1
@@ -187,11 +205,10 @@ object NeoForgeEvents {
187205
val player = context.source.player ?: return@executes 0
188206

189207
player.sendSystemMessage(
190-
"modid.command.chatexchange.description".toExchangeServerTranslatedLiteral()
208+
"chatexchange.command.chatexchange.description".toExchangeServerTranslatedLiteral()
191209
)
192210
1
193211
}
194-
195212
dispatcher.register(command)
196213
}
197214
}
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"itemGroup.chatexchange": "Chat Exchange",
3+
"chatexchange.const.enabled": "§2Enabled§r",
4+
"chatexchange.const.disabled": "§cDisabled§r",
35
"modid.config.host": "Host",
46
"modid.config.port": "Port",
57
"modid.config.token": "Token",
@@ -9,9 +11,10 @@
911
"modid.config.joinLeave": "Enable Join/Leave",
1012
"modid.config.death": "Enable Death",
1113
"modid.config.advancement": "Enable Advancement",
12-
"modid.command.chatexchange.description": "§3§lChatExchange Help§r\nIf the server has enabled broadcasting chat messages, your chat messages will be broadcast to an external port by default.\nYou can use /chatexchange broadcastme to control whether your chat messages will be broadcast.\nAlso, you can broadcast your messages by prefixing @broadcast/@bc.",
13-
"modid.command.chatexchange.broadcastme.on": "Your chat messages will now be broadcast.",
14-
"modid.command.chatexchange.broadcastme.off": "Your chat messages will not be broadcast.",
15-
"modid.command.chatexchange.broadcastme.ison": "Your chat messages are currently being broadcast.",
16-
"modid.command.chatexchange.broadcastme.isoff": "Your chat messages are currently not being broadcast."
14+
"chatexchange.command.chatexchange.description": "§3§lChatExchange Help§r\nIf the server has enabled broadcasting chat messages, your chat messages will be broadcast to an external port by default.\nYou can use /chatexchange broadcastme to control whether your chat messages will be broadcast.\nAlso, you can broadcast your messages by prefixing @broadcast/@bc.",
15+
"chatexchange.command.chatexchange.status": "Chat: %s\nJoin/Leave: %s\nDeath: %s\nAdvancement: %s",
16+
"chatexchange.command.chatexchange.broadcastme.on": "Your chat messages will now be broadcast.",
17+
"chatexchange.command.chatexchange.broadcastme.off": "Your chat messages will not be broadcast.",
18+
"chatexchange.command.chatexchange.broadcastme.ison": "Your chat messages are currently being broadcast.",
19+
"chatexchange.command.chatexchange.broadcastme.isoff": "Your chat messages are currently not being broadcast."
1720
}
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"itemGroup.chatexchange": "Chat Exchange",
3+
"chatexchange.const.enabled": "§2已启用§r",
4+
"chatexchange.const.disabled": "§c已禁用§r",
35
"modid.config.host": "主机",
46
"modid.config.port": "端口",
57
"modid.config.token": "令牌",
@@ -9,9 +11,10 @@
911
"modid.config.joinLeave": "启用加入/离开消息",
1012
"modid.config.death": "启用死亡消息",
1113
"modid.config.advancement": "启用进度消息",
12-
"modid.command.chatexchange.description": "§3§lChatExchange 帮助§r\n若服务器开启了广播聊天消息,你的聊天消息默认会被自动广播到外部端口。\n你可以使用 /chatexchange broadcastme 来控制你的消息是否被广播。\n同时,在发送消息前加上@广播/@broadcast/@bc前缀也可以广播你的消息。",
13-
"modid.command.chatexchange.broadcastme.on": "你的聊天消息现在会被广播了。",
14-
"modid.command.chatexchange.broadcastme.off": "你的聊天消息现在不会被广播了。",
15-
"modid.command.chatexchange.broadcastme.ison": "你的聊天消息当前会被广播。",
16-
"modid.command.chatexchange.broadcastme.isoff": "你的聊天消息当前不会被广播。"
14+
"chatexchange.command.chatexchange.description": "§3§lChatExchange 帮助§r\n若服务器开启了广播聊天消息,你的聊天消息默认会被自动广播到外部端口。\n你可以使用 /chatexchange broadcastme 来控制你的消息是否被广播。\n同时,在发送消息前加上@广播/@broadcast/@bc前缀也可以广播你的消息。",
15+
"chatexchange.command.chatexchange.status": "聊天消息: %s\n加入/离开消息: %s\n死亡消息: %s\n进度消息: %s",
16+
"chatexchange.command.chatexchange.broadcastme.on": "你的聊天消息现在会被广播了。",
17+
"chatexchange.command.chatexchange.broadcastme.off": "你的聊天消息现在不会被广播了。",
18+
"chatexchange.command.chatexchange.broadcastme.ison": "你的聊天消息当前会被广播。",
19+
"chatexchange.command.chatexchange.broadcastme.isoff": "你的聊天消息当前不会被广播。"
1720
}

0 commit comments

Comments
 (0)