mirror of
https://github.com/YouHaveTrouble/BlockEdit.git
synced 2026-06-29 21:46:19 +00:00
copy command
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user