copy command

This commit is contained in:
2023-04-14 00:10:57 +02:00
parent f6d2b86c4b
commit b24fefa290
@@ -0,0 +1,29 @@
package me.youhavetrouble.blockedit.commands;
import me.youhavetrouble.blockedit.BEPlayer;
import net.kyori.adventure.text.Component;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class CopyCommand extends Command {
public CopyCommand() {
super("copy");
setPermission("blockedit.command.copy");
}
@Override
public boolean execute(@NotNull CommandSender sender, @NotNull String s, @NotNull String[] args) {
if (!(sender instanceof Player player)) return true;
BEPlayer bePlayer = BEPlayer.getByPlayer(player);
try {
bePlayer.setClipboardFromSelection();
player.sendMessage(Component.text("Copied selection to clipboard"));
} catch (IllegalStateException e) {
player.sendMessage(Component.text("You need to select an area first"));
}
return true;
}
}