mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-01 04:51:29 +01:00
Add ability to mimic messages from a player with the echo command
This commit is contained in:
parent
2404f19fe2
commit
37f0f797fd
@ -1,24 +1,32 @@
|
||||
package demo.commands;
|
||||
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.minestom.server.command.builder.Command;
|
||||
import net.minestom.server.command.builder.arguments.ArgumentType;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.ArgumentComponent;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.ArgumentUUID;
|
||||
|
||||
public class EchoCommand extends Command {
|
||||
public EchoCommand() {
|
||||
super("echo");
|
||||
|
||||
this.setDefaultExecutor((sender, context) -> sender.sendMessage(
|
||||
Component.text("Usage: /echo <json>")
|
||||
Component.text("Usage: /echo <json> [uuid]")
|
||||
.hoverEvent(Component.text("Click to get this command.")
|
||||
.clickEvent(ClickEvent.suggestCommand("/echo ")))));
|
||||
|
||||
ArgumentComponent json = ArgumentType.Component("json");
|
||||
ArgumentUUID uuid = ArgumentType.UUID("uuid");
|
||||
|
||||
this.addSyntax((sender, context) -> {
|
||||
sender.sendMessage(context.get(json));
|
||||
}, json);
|
||||
|
||||
this.addSyntax((sender, context) -> {
|
||||
sender.sendMessage(Identity.identity(context.get(uuid)), context.get(json), MessageType.CHAT);
|
||||
}, uuid, json);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user