mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 12:07:42 +01:00
Added block command argument type
This commit is contained in:
parent
80d899a53a
commit
cac3c29e41
@ -7,10 +7,7 @@ import net.minestom.server.command.builder.CommandDispatcher;
|
||||
import net.minestom.server.command.builder.CommandSyntax;
|
||||
import net.minestom.server.command.builder.arguments.*;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.*;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.registry.ArgumentEnchantment;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.registry.ArgumentEntityType;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.registry.ArgumentParticle;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.registry.ArgumentPotionEffect;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.registry.*;
|
||||
import net.minestom.server.command.builder.arguments.number.ArgumentDouble;
|
||||
import net.minestom.server.command.builder.arguments.number.ArgumentFloat;
|
||||
import net.minestom.server.command.builder.arguments.number.ArgumentInteger;
|
||||
@ -502,7 +499,7 @@ public final class CommandManager {
|
||||
|
||||
// You can uncomment this to test any brigadier parser on the client
|
||||
/*DeclareCommandsPacket.Node testNode = simpleArgumentNode(nodes, argument, executable, false);
|
||||
testNode.parser = "minecraft:vec3";
|
||||
testNode.parser = "minecraft:block_state";
|
||||
|
||||
if (true) {
|
||||
return nodes;
|
||||
@ -628,6 +625,9 @@ public final class CommandManager {
|
||||
} else if (argument instanceof ArgumentEntityType) {
|
||||
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(nodes, argument, executable, false);
|
||||
argumentNode.parser = "minecraft:entity_summon";
|
||||
} else if (argument instanceof ArgumentBlockState) {
|
||||
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(nodes, argument, executable, false);
|
||||
argumentNode.parser = "minecraft:block_state";
|
||||
} else if (argument instanceof ArgumentIntRange) {
|
||||
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(nodes, argument, executable, false);
|
||||
argumentNode.parser = "minecraft:int_range";
|
||||
|
@ -3,6 +3,7 @@ package net.minestom.server.command.builder;
|
||||
import net.minestom.server.chat.ChatColor;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.EntityType;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.item.Enchantment;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.particle.Particle;
|
||||
@ -98,6 +99,11 @@ public final class Arguments {
|
||||
return (EntityType) getObject(id);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Block getBlockState(@NotNull String id) {
|
||||
return (Block) getObject(id);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public IntRange getIntRange(@NotNull String id) {
|
||||
return (IntRange) getObject(id);
|
||||
|
@ -1,10 +1,7 @@
|
||||
package net.minestom.server.command.builder.arguments;
|
||||
|
||||
import net.minestom.server.command.builder.arguments.minecraft.*;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.registry.ArgumentEnchantment;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.registry.ArgumentEntityType;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.registry.ArgumentParticle;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.registry.ArgumentPotionEffect;
|
||||
import net.minestom.server.command.builder.arguments.minecraft.registry.*;
|
||||
import net.minestom.server.command.builder.arguments.number.ArgumentDouble;
|
||||
import net.minestom.server.command.builder.arguments.number.ArgumentFloat;
|
||||
import net.minestom.server.command.builder.arguments.number.ArgumentInteger;
|
||||
@ -91,6 +88,10 @@ public class ArgumentType {
|
||||
return new ArgumentEntityType(id);
|
||||
}
|
||||
|
||||
public static ArgumentBlockState BlockState(@NotNull String id) {
|
||||
return new ArgumentBlockState(id);
|
||||
}
|
||||
|
||||
public static ArgumentIntRange IntRange(@NotNull String id) {
|
||||
return new ArgumentIntRange(id);
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package net.minestom.server.command.builder.arguments.minecraft.registry;
|
||||
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.registry.Registries;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ArgumentBlockState extends ArgumentRegistry<Block> {
|
||||
|
||||
public ArgumentBlockState(@NotNull String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getRegistry(String value) {
|
||||
return Registries.getBlock(value);
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ public abstract class ArgumentRegistry<T> extends Argument<T> {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public abstract T getRegistry(String value);
|
||||
public abstract T getRegistry(@NotNull String value);
|
||||
|
||||
@Override
|
||||
public int getCorrectionResult(@NotNull String value) {
|
||||
|
Loading…
Reference in New Issue
Block a user