From 74ceb81704efb97899a1198a9d7b307765885104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noel=20N=C3=A9meth?= Date: Sun, 12 Jun 2022 14:30:30 +0200 Subject: [PATCH] Add chat preview command --- .../demo/commands/ChatPreviewCommand.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 demo/src/main/java/net/minestom/demo/commands/ChatPreviewCommand.java diff --git a/demo/src/main/java/net/minestom/demo/commands/ChatPreviewCommand.java b/demo/src/main/java/net/minestom/demo/commands/ChatPreviewCommand.java new file mode 100644 index 000000000..1408bd5ec --- /dev/null +++ b/demo/src/main/java/net/minestom/demo/commands/ChatPreviewCommand.java @@ -0,0 +1,20 @@ +package net.minestom.demo.commands; + +import net.minestom.server.command.builder.Command; +import net.minestom.server.command.builder.arguments.ArgumentBoolean; +import net.minestom.server.command.builder.arguments.ArgumentType; +import net.minestom.server.entity.Player; + +public class ChatPreviewCommand extends Command { + private static final ArgumentBoolean on = ArgumentType.Boolean("on"); + + public ChatPreviewCommand() { + super("preview"); + + addSyntax(((sender, context) -> { + if (sender instanceof Player player) { + player.toggleChatPreview(context.get(on)); + } + }), on); + } +}