mirror of
https://github.com/YouHaveTrouble/BlockEdit.git
synced 2026-06-29 21:46:19 +00:00
migrate to paper plugin system
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package me.youhavetrouble.blockedit.commands;
|
||||
|
||||
import me.youhavetrouble.blockedit.BEPlayer;
|
||||
import me.youhavetrouble.blockedit.WorkSplitter;
|
||||
import me.youhavetrouble.blockedit.api.BlockEditAPI;
|
||||
import me.youhavetrouble.blockedit.operations.SetOperation;
|
||||
import me.youhavetrouble.blockedit.util.Selection;
|
||||
@@ -10,20 +9,38 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SetCommand implements TabExecutor {
|
||||
public class SetCommand extends Command {
|
||||
|
||||
public SetCommand() {
|
||||
super("set");
|
||||
setPermission("blockedit.command.set");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) return true;
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
|
||||
if (args.length == 1) {
|
||||
ArrayList<String> suggestions = new ArrayList<>();
|
||||
for (Material material : Material.values()) {
|
||||
if (material.isBlock())
|
||||
suggestions.add(material.name().toLowerCase());
|
||||
}
|
||||
return StringUtil.copyPartialMatches(args[0], suggestions, new ArrayList<>());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] args) {
|
||||
if (!(commandSender instanceof Player player)) return true;
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(Component.text("You need to provide block type"));
|
||||
return true;
|
||||
@@ -44,19 +61,4 @@ public class SetCommand implements TabExecutor {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
if (args.length == 1) {
|
||||
ArrayList<String> suggestions = new ArrayList<>();
|
||||
for (Material material : Material.values()) {
|
||||
if (material.isBlock())
|
||||
suggestions.add(material.name().toLowerCase());
|
||||
}
|
||||
return StringUtil.copyPartialMatches(args[0], suggestions, new ArrayList<>());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user