diff --git a/.idea/misc.xml b/.idea/misc.xml index 34a2006c8..b41fa3fa8 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -13,9 +13,11 @@ - - - + + + + + \ No newline at end of file diff --git a/src/main/java/com/jaoafa/mymaid4/event/Event_ChatBan.java b/src/main/java/com/jaoafa/mymaid4/event/Event_ChatBan.java index ffb40df9f..1b3c32392 100644 --- a/src/main/java/com/jaoafa/mymaid4/event/Event_ChatBan.java +++ b/src/main/java/com/jaoafa/mymaid4/event/Event_ChatBan.java @@ -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 tell1v1 = List.of( + "tell", + "msg", + "message", + "m", + "t", + "r", + "w" + ); + @Override public String description() { return "ChatBanに関する各種処理を行います。"; @@ -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() + "==>あなたはコマンドを実行できません。"); diff --git a/src/main/java/com/jaoafa/mymaid4/lib/ChatBan.java b/src/main/java/com/jaoafa/mymaid4/lib/ChatBan.java index 3918b4787..f6b73f655 100644 --- a/src/main/java/com/jaoafa/mymaid4/lib/ChatBan.java +++ b/src/main/java/com/jaoafa/mymaid4/lib/ChatBan.java @@ -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されました。",