mirror of
https://github.com/jie65535/gc-openchat-plugin.git
synced 2025-06-01 17:29:11 +08:00
Fix ban issue
Add ban and limit feedback
This commit is contained in:
parent
4f8fc1f86d
commit
de01151d12
@ -47,7 +47,14 @@ Server command (requires `server.chat.others` permissions) :
|
||||
|
||||
// The content of the message sent when the player joins
|
||||
// Can be used to prompt the player how to switch the chat function
|
||||
joinMessage: "本服已启用聊天,/chat on 开启(默认),/chat off 屏蔽"
|
||||
joinMessage: "本服已启用聊天,/chat on 开启(默认),/chat off 屏蔽",
|
||||
|
||||
// Banned Feedback Message
|
||||
bannedFeedback: "你已经被禁言!",
|
||||
|
||||
// Message too frequent feedback message
|
||||
// {limit} messageFreLimitPerMinute
|
||||
msgTooFrequentFeedback: "服务器设置每分钟仅允许发言{limit}次"
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -53,7 +53,14 @@
|
||||
sendJoinMessage: true,
|
||||
|
||||
// 玩家加入时发送消息
|
||||
joinMessage: "本服已启用聊天,/chat on 开启(默认),/chat off 屏蔽"
|
||||
joinMessage: "本服已启用聊天,/chat on 开启(默认),/chat off 屏蔽",
|
||||
|
||||
// 被禁言反馈消息
|
||||
bannedFeedback: "你已经被禁言!",
|
||||
|
||||
// 消息太频繁反馈消息
|
||||
// {limit} 服务器设置的限制次数
|
||||
msgTooFrequentFeedback: "服务器设置每分钟仅允许发言{limit}次"
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -46,4 +46,15 @@ public class OpenChatConfig {
|
||||
* 玩家加入消息
|
||||
*/
|
||||
public String joinMessage = "本服已启用聊天,/chat on 开启(默认),/chat off 屏蔽";
|
||||
|
||||
/**
|
||||
* 被禁言反馈消息
|
||||
*/
|
||||
public String bannedFeedback = "你已经被禁言!";
|
||||
|
||||
/**
|
||||
* 消息太频繁反馈消息
|
||||
* {limit} 服务器设置的限制次数
|
||||
*/
|
||||
public String msgTooFrequentFeedback = "服务器设置每分钟仅允许发言{limit}次";
|
||||
}
|
||||
|
@ -47,9 +47,11 @@ public class OpenChatSystem extends ChatSystem {
|
||||
|
||||
// 检测是否正在禁言中
|
||||
if (checkIsBanning(player)) {
|
||||
// 可提示也可忽略,忽略可让玩家以为自己发送成功,其实别人看不到
|
||||
plugin.getLogger().warn(String.format("Message blocked (banning): player=%s(%d): \"%s\"",
|
||||
player.getNickname(), player.getUid(), message));
|
||||
if (!plugin.getConfig().bannedFeedback.isEmpty()) {
|
||||
player.dropMessage(plugin.getConfig().bannedFeedback);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -58,6 +60,11 @@ public class OpenChatSystem extends ChatSystem {
|
||||
// 可提示也可忽略,忽略可让玩家以为自己发送成功,其实别人看不到
|
||||
plugin.getLogger().warn(String.format("Message blocked (too often): player=%s(%d): \"%s\"",
|
||||
player.getNickname(), player.getUid(), message));
|
||||
if (!plugin.getConfig().msgTooFrequentFeedback.isEmpty()) {
|
||||
player.dropMessage(
|
||||
plugin.getConfig().msgTooFrequentFeedback
|
||||
.replace("{limit}", String.valueOf(plugin.getConfig().messageFreLimitPerMinute)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -40,15 +40,19 @@ public class ChatServerCommands implements CommandHandler {
|
||||
var time = new Date(2051190000);
|
||||
if (args.size() == 2) {
|
||||
try {
|
||||
time = new Date(System.currentTimeMillis() / 1000 + Integer.parseInt(args.get(1)) * 60L);
|
||||
time = new Date(System.currentTimeMillis() + Integer.parseInt(args.get(1)) * 60_000L);
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.ban.invalid_time");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (targetPlayer == null) {
|
||||
sendUsageMessage(sender);
|
||||
} else {
|
||||
plugin.getData().banList.put(targetPlayer.getUid(), time);
|
||||
CommandHandler.sendMessage(sender, "OK");
|
||||
}
|
||||
}
|
||||
case "limit" -> {
|
||||
var times = 20;
|
||||
if (args.size() == 2) {
|
||||
|
Loading…
Reference in New Issue
Block a user