This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
79 additions
and
46 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/java/com/jaoafa/mymaid4/event/Event_CommandFeedback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters