Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
feat: ChatBanされている場合はw(1v1 tell)とか使えないように (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
book000 authored Jun 7, 2022
1 parent 26a6da5 commit 4a2a0f2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
8 changes: 5 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion src/main/java/com/jaoafa/mymaid4/event/Event_ChatBan.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,19 @@
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.List;

public class Event_ChatBan implements Listener, EventPremise {
private final List<String> tell1v1 = List.of(
"tell",
"msg",
"message",
"m",
"t",
"r",
"w"
);

@Override
public String description() {
return "ChatBanに関する各種処理を行います。";
Expand Down Expand Up @@ -88,7 +100,8 @@ public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent event) {
// ChatBanされてる
if (!chatBan.isStatus()) return;
String command = event.getMessage();
if (!command.toLowerCase().startsWith("/chatban")) return;
if (!command.toLowerCase().startsWith("/chatban") && tell1v1.stream().map(c -> "/" + c).noneMatch(command::startsWith))
return;
event.setCancelled(true);
player.sendMessage("[ChatBan] " + ChatColor.GREEN + "あなたはコマンドを実行できません。");
Bukkit.getLogger().info("[ChatBan] " + player.getName() + "==>あなたはコマンドを実行できません。");
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/com/jaoafa/mymaid4/lib/ChatBan.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@ public Result addBan(String banned_by, String reason) {
));

TextChannel sendTo = getDiscordSendTo();
sendTo.sendMessage(
String.format("__**ChatBan[追加]**__: プレイヤー「%s」が「%s」によって「%s」という理由でChatBanされました。",
MyMaidLibrary.DiscordEscape(player.getName()),
MyMaidLibrary.DiscordEscape(banned_by),
MyMaidLibrary.DiscordEscape(reason))).queue();
if (sendTo != null) {
sendTo.sendMessage(
String.format("__**ChatBan[追加]**__: プレイヤー「%s」が「%s」によって「%s」という理由でChatBanされました。",
MyMaidLibrary.DiscordEscape(player.getName()),
MyMaidLibrary.DiscordEscape(banned_by),
MyMaidLibrary.DiscordEscape(reason))).queue();
}
if (MyMaidData.getServerChatChannel() != null) {
MyMaidData.getServerChatChannel().sendMessage(
String.format("__**ChatBan[追加]**__: プレイヤー「%s」が「%s」によって「%s」という理由でChatBanされました。",
Expand Down

0 comments on commit 4a2a0f2

Please sign in to comment.