From bafc57c247bdd9da09bfae0891ee30bfa88a46e5 Mon Sep 17 00:00:00 2001 From: Tomachi <8929706+book000@users.noreply.github.com> Date: Thu, 11 Aug 2022 12:31:58 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=9F=E8=A1=8C=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E3=82=92=E5=85=A8=E6=A8=A9?= =?UTF-8?q?=E9=99=90=E3=81=A7=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=20(#921)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mymaid4/event/Event_CommandFeedback.java | 48 ++++++++++++ .../mymaid4/event/Event_CommandSender.java | 77 ++++++++----------- 2 files changed, 79 insertions(+), 46 deletions(-) create mode 100644 src/main/java/com/jaoafa/mymaid4/event/Event_CommandFeedback.java diff --git a/src/main/java/com/jaoafa/mymaid4/event/Event_CommandFeedback.java b/src/main/java/com/jaoafa/mymaid4/event/Event_CommandFeedback.java new file mode 100644 index 000000000..fcd9ed9e5 --- /dev/null +++ b/src/main/java/com/jaoafa/mymaid4/event/Event_CommandFeedback.java @@ -0,0 +1,48 @@ +/* + * jaoLicense + * + * Copyright (c) 2022 jao Minecraft Server + * + * The following license applies to this project: jaoLicense + * + * Japanese: https://github.com/jaoafa/jao-Minecraft-Server/blob/master/jaoLICENSE.md + * English: https://github.com/jaoafa/jao-Minecraft-Server/blob/master/jaoLICENSE-en.md + */ + +package com.jaoafa.mymaid4.event; + +import com.jaoafa.mymaid4.lib.EventPremise; +import com.jaoafa.mymaid4.lib.MyMaidLibrary; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.JoinConfiguration; +import net.kyori.adventure.text.event.ClickEvent; +import net.kyori.adventure.text.event.HoverEvent; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.Style; +import net.kyori.adventure.text.format.TextDecoration; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; + +public class Event_CommandFeedback extends MyMaidLibrary implements Listener, EventPremise { + @Override + public String description() { + return "実行したコマンドを実行者に対して表示します。"; + } + + @EventHandler(priority = EventPriority.MONITOR) + public void onCommand(PlayerCommandPreprocessEvent event) { + Player executor = event.getPlayer(); + String command = event.getMessage(); + + executor.sendMessage(Component.join(JoinConfiguration.noSeparators(), + Component.text("["), + Component.text("Cmd", Style.style(TextDecoration.UNDERLINED)) + .hoverEvent(HoverEvent.showText(Component.text("クリックすると実行したコマンドをコピーします。"))) + .clickEvent(ClickEvent.copyToClipboard(command)), + Component.text("] " + command)) + .colorIfAbsent(NamedTextColor.DARK_GRAY)); + } +} diff --git a/src/main/java/com/jaoafa/mymaid4/event/Event_CommandSender.java b/src/main/java/com/jaoafa/mymaid4/event/Event_CommandSender.java index 0ee12cc16..d86cb6925 100644 --- a/src/main/java/com/jaoafa/mymaid4/event/Event_CommandSender.java +++ b/src/main/java/com/jaoafa/mymaid4/event/Event_CommandSender.java @@ -28,38 +28,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; public class Event_CommandSender extends MyMaidLibrary implements Listener, EventPremise { - private static void sendCmd(Player player, Player executer, String group, String command, PlayerCommandPreprocessEvent event) { - player.sendMessage( - Component.text() - .color(NamedTextColor.DARK_GRAY) - .append( - // [Group/PlayerName] command test test (取り消し済み) - Component.text( - String.format("[%s|", group), - NamedTextColor.GRAY - ), - Component.text( - executer.getName(), - Style.style() - .color(NamedTextColor.GRAY) - .decorate(TextDecoration.UNDERLINED) - .clickEvent(ClickEvent.runCommand("/secrettp " + executer.getName())) - .hoverEvent(HoverEvent.showText( - Component.text(String.format("スペクテイターで%sにテレポート", executer.getName())) - )) - .build() - ), - Component.text( - "] ", - NamedTextColor.GRAY - ), - Component.text(command, NamedTextColor.YELLOW), - Component.text((event.isCancelled() ? " (拒否)" : ""), NamedTextColor.RED) - ) - ); - - } - @Override public String description() { return "実行されたコマンドを特定権限に通知します。"; @@ -71,20 +39,6 @@ public void onCommand(PlayerCommandPreprocessEvent event) { String command = event.getMessage(); String group = getPermissionMainGroup(executor); - //feedback - if (isAMRV(executor)) { - // Verified以上は実行試行したコマンドを返す - executor.sendMessage( - Component.text() - .color(NamedTextColor.DARK_GRAY) - .append( - Component.text("["), - Component.text("Cmd", Style.style(TextDecoration.UNDERLINED, ClickEvent.copyToClipboard(command)).toBuilder().build()), - Component.text("] " + command) - ) - ); - } - //sender for (Player player : Bukkit.getServer().getOnlinePlayers()) { //TempMute or 実行者本人 @@ -108,4 +62,35 @@ public void onCommand(PlayerCommandPreprocessEvent event) { } } } + + private static void sendCmd(Player player, Player executer, String group, String command, PlayerCommandPreprocessEvent event) { + player.sendMessage( + Component.text() + .color(NamedTextColor.DARK_GRAY) + .append( + // [Group/PlayerName] command test test (取り消し済み) + Component.text( + String.format("[%s|", group), + NamedTextColor.GRAY + ), + Component.text( + executer.getName(), + Style.style() + .color(NamedTextColor.GRAY) + .decorate(TextDecoration.UNDERLINED) + .clickEvent(ClickEvent.runCommand("/secrettp " + executer.getName())) + .hoverEvent(HoverEvent.showText( + Component.text(String.format("スペクテイターで%sにテレポート", executer.getName())) + )) + .build() + ), + Component.text( + "] ", + NamedTextColor.GRAY + ), + Component.text(command, NamedTextColor.YELLOW), + Component.text((event.isCancelled() ? " (拒否)" : ""), NamedTextColor.RED) + ) + ); + } }