mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Update /setblock command
This commit is contained in:
parent
782620466b
commit
5992d52429
@ -1,22 +1,23 @@
|
||||
package demo.commands;
|
||||
|
||||
import net.minestom.server.command.builder.Command;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.ArgumentBlockState;
|
||||
import net.minestom.server.command.builder.arguments.relative.ArgumentRelativeBlockPosition;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.utils.location.RelativeVec;
|
||||
|
||||
import static net.minestom.server.command.builder.arguments.ArgumentType.BlockState;
|
||||
import static net.minestom.server.command.builder.arguments.ArgumentType.RelativeVec3;
|
||||
import static net.minestom.server.command.builder.arguments.ArgumentType.RelativeBlockPosition;
|
||||
|
||||
public class SetBlockCommand extends Command {
|
||||
public SetBlockCommand() {
|
||||
super("setblock");
|
||||
|
||||
final ArgumentRelativeBlockPosition position = RelativeBlockPosition("position");
|
||||
final ArgumentBlockState block = BlockState("block");
|
||||
|
||||
addSyntax((sender, context) -> {
|
||||
RelativeVec relativeVec = context.get("position");
|
||||
Block block = context.get("block");
|
||||
final Player player = sender.asPlayer();
|
||||
player.getInstance().setBlock(relativeVec.from(player), block);
|
||||
}, RelativeVec3("position"), BlockState("block"));
|
||||
player.getInstance().setBlock(context.get(position).from(player), context.get(block));
|
||||
}, position, block);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user