mirror of
https://github.com/YouHaveTrouble/BlockEdit.git
synced 2026-06-29 21:46:19 +00:00
some commands
This commit is contained in:
@@ -17,6 +17,10 @@ public class BEPlayer {
|
|||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetSelection() {
|
||||||
|
this.selection = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateSelection() {
|
private void updateSelection() {
|
||||||
if (selectionPoint1 == null || selectionPoint2 == null) {
|
if (selectionPoint1 == null || selectionPoint2 == null) {
|
||||||
selection = null;
|
selection = null;
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
package me.youhavetrouble.blockedit;
|
package me.youhavetrouble.blockedit;
|
||||||
|
|
||||||
import me.youhavetrouble.blockedit.api.BlockEditWands;
|
import me.youhavetrouble.blockedit.api.BlockEditWands;
|
||||||
import me.youhavetrouble.blockedit.commands.ReplaceCommand;
|
import me.youhavetrouble.blockedit.commands.*;
|
||||||
import me.youhavetrouble.blockedit.commands.SetCommand;
|
|
||||||
import me.youhavetrouble.blockedit.commands.WandCommand;
|
|
||||||
import me.youhavetrouble.blockedit.wands.SelectionWand;
|
import me.youhavetrouble.blockedit.wands.SelectionWand;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public final class BlockEdit extends JavaPlugin {
|
public final class BlockEdit extends JavaPlugin {
|
||||||
@@ -22,26 +21,12 @@ public final class BlockEdit extends JavaPlugin {
|
|||||||
BlockEditWands.registerWand(selectionWand);
|
BlockEditWands.registerWand(selectionWand);
|
||||||
getServer().getPluginManager().registerEvents(selectionWand, this);
|
getServer().getPluginManager().registerEvents(selectionWand, this);
|
||||||
|
|
||||||
//getCommand("test").setExecutor(new TestCommand());
|
registerCommand("/wand", new WandCommand());
|
||||||
|
registerCommand("/set", new SetCommand());
|
||||||
WandCommand wandCommand = new WandCommand();
|
registerCommand("/replace", new ReplaceCommand());
|
||||||
PluginCommand bukkitWandCommand = getCommand("/wand");
|
registerCommand("/pos1", new Pos1Command());
|
||||||
if (bukkitWandCommand != null) {
|
registerCommand("/pos2", new Pos2Command());
|
||||||
bukkitWandCommand.setExecutor(wandCommand);
|
registerCommand("/desel", new DeselCommand());
|
||||||
bukkitWandCommand.setTabCompleter(wandCommand);
|
|
||||||
}
|
|
||||||
SetCommand setCommand = new SetCommand();
|
|
||||||
PluginCommand bukkitSetCommand = getCommand("/set");
|
|
||||||
if (bukkitSetCommand != null) {
|
|
||||||
bukkitSetCommand.setExecutor(setCommand);
|
|
||||||
bukkitSetCommand.setTabCompleter(setCommand);
|
|
||||||
}
|
|
||||||
ReplaceCommand replaceCommand = new ReplaceCommand();
|
|
||||||
PluginCommand bukkitReplaceCommand = getCommand("/replace");
|
|
||||||
if (bukkitReplaceCommand != null) {
|
|
||||||
bukkitReplaceCommand.setExecutor(replaceCommand);
|
|
||||||
bukkitReplaceCommand.setTabCompleter(replaceCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,4 +34,12 @@ public final class BlockEdit extends JavaPlugin {
|
|||||||
public static BlockEdit getPlugin() {
|
public static BlockEdit getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerCommand(String command, TabExecutor executor) {
|
||||||
|
PluginCommand bukkitReplaceCommand = getCommand(command);
|
||||||
|
if (bukkitReplaceCommand != null) {
|
||||||
|
bukkitReplaceCommand.setExecutor(executor);
|
||||||
|
bukkitReplaceCommand.setTabCompleter(executor);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
package me.youhavetrouble.blockedit;
|
|
||||||
|
|
||||||
import me.youhavetrouble.blockedit.util.ChunkWork;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Particle;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
import org.bukkit.util.BoundingBox;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class TestCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
BukkitTask task;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
|
||||||
if (sender instanceof Player player) {
|
|
||||||
|
|
||||||
Location location = player.getLocation();
|
|
||||||
if (task != null) {
|
|
||||||
task.cancel();
|
|
||||||
}
|
|
||||||
// That's how manually checking if selection is valid looks like.
|
|
||||||
task = Bukkit.getScheduler().runTaskTimerAsynchronously(BlockEdit.getPlugin(),() -> {
|
|
||||||
BoundingBox box = BEPlayer.getByPlayer(player).getSelection();
|
|
||||||
if (box == null) return;
|
|
||||||
for (int y = 0; y< 255; y++) {
|
|
||||||
location.getWorld().spawnParticle(Particle.END_ROD, box.getMaxX(), y, box.getMaxZ(), 0, 0.01, 0.01, 0.01);
|
|
||||||
location.getWorld().spawnParticle(Particle.END_ROD, box.getMinX(), y, box.getMinZ(), 0, 0.01, 0.01, 0.01);
|
|
||||||
}
|
|
||||||
}, 0, 4);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
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.command.TabExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DeselCommand implements TabExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (!(sender instanceof Player player)) return true;
|
||||||
|
BEPlayer bePlayer = BEPlayer.getByPlayer(player);
|
||||||
|
bePlayer.resetSelection();
|
||||||
|
player.sendMessage(Component.text("You have reset your selection"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
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.command.TabExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Pos1Command implements TabExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (!(sender instanceof Player player)) return true;
|
||||||
|
BEPlayer bePlayer = BEPlayer.getByPlayer(player);
|
||||||
|
bePlayer.setSelectionPoint1(player.getLocation().toBlockLocation());
|
||||||
|
player.sendMessage(Component.text("First point set at your location"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
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.command.TabExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Pos2Command implements TabExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (!(sender instanceof Player player)) return true;
|
||||||
|
BEPlayer bePlayer = BEPlayer.getByPlayer(player);
|
||||||
|
bePlayer.setSelectionPoint2(player.getLocation().toBlockLocation());
|
||||||
|
player.sendMessage(Component.text("Second point set at your location"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package me.youhavetrouble.blockedit.commands;
|
package me.youhavetrouble.blockedit.commands;
|
||||||
|
|
||||||
import me.youhavetrouble.blockedit.BEPlayer;
|
import me.youhavetrouble.blockedit.BEPlayer;
|
||||||
import me.youhavetrouble.blockedit.WorkSplitter;
|
|
||||||
import me.youhavetrouble.blockedit.api.BlockEditAPI;
|
import me.youhavetrouble.blockedit.api.BlockEditAPI;
|
||||||
import me.youhavetrouble.blockedit.operations.ReplaceOperation;
|
import me.youhavetrouble.blockedit.operations.ReplaceOperation;
|
||||||
import me.youhavetrouble.blockedit.util.Selection;
|
import me.youhavetrouble.blockedit.util.Selection;
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package me.youhavetrouble.blockedit.operations;
|
package me.youhavetrouble.blockedit.operations;
|
||||||
|
|
||||||
|
|
||||||
import me.youhavetrouble.blockedit.api.BlockEditOperation;
|
import me.youhavetrouble.blockedit.api.BlockEditOperation;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
|
||||||
public record SetOperation(BlockData blockData) implements BlockEditOperation {
|
public record SetOperation(BlockData blockData) implements BlockEditOperation {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,14 +6,18 @@ authors: [ YouHaveTrouble ]
|
|||||||
description: Modern WorldEdit alternative
|
description: Modern WorldEdit alternative
|
||||||
website: youhavetrouble.me
|
website: youhavetrouble.me
|
||||||
commands:
|
commands:
|
||||||
test:
|
|
||||||
description: test
|
|
||||||
/wand:
|
/wand:
|
||||||
permission: blockedit.wand
|
permission: blockedit.wand
|
||||||
description: Gives you a blockedit wand
|
description: Gives you a blockedit wand
|
||||||
/set:
|
/set:
|
||||||
permission: blockedit.set
|
permission: blockedit.command.set
|
||||||
description: Set selection area to chosen block
|
description: Set selection area to chosen block
|
||||||
/replace:
|
/replace:
|
||||||
permission: blockedit.replace
|
permission: blockedit.command.replace
|
||||||
description: Replace selected blocks in selection area
|
description: Replace selected blocks in selection area
|
||||||
|
/pos1:
|
||||||
|
permission: blockedit.command.pos
|
||||||
|
/pos2:
|
||||||
|
permission: blockedit.command.pos
|
||||||
|
/desel:
|
||||||
|
permission: blockedit.command.desel
|
||||||
|
|||||||
Reference in New Issue
Block a user