mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Fix up tab completion for EntityType
This commit is contained in:
parent
748b24b8ef
commit
811e3c542b
@ -23,7 +23,7 @@ public class ArgumentEntityType extends ArgumentRegistry<EntityType> {
|
|||||||
@Override
|
@Override
|
||||||
public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
|
public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
|
||||||
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, true);
|
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, true);
|
||||||
argumentNode.parser = "minecraft:entity_summon";
|
argumentNode.parser = "minecraft:resource_location";
|
||||||
argumentNode.suggestionsType = SuggestionType.SUMMONABLE_ENTITIES.getIdentifier();
|
argumentNode.suggestionsType = SuggestionType.SUMMONABLE_ENTITIES.getIdentifier();
|
||||||
|
|
||||||
nodeMaker.addNodes(new DeclareCommandsPacket.Node[]{argumentNode});
|
nodeMaker.addNodes(new DeclareCommandsPacket.Node[]{argumentNode});
|
||||||
|
@ -3,32 +3,39 @@ package demo.commands;
|
|||||||
import net.minestom.server.command.CommandSender;
|
import net.minestom.server.command.CommandSender;
|
||||||
import net.minestom.server.command.builder.Command;
|
import net.minestom.server.command.builder.Command;
|
||||||
import net.minestom.server.command.builder.CommandContext;
|
import net.minestom.server.command.builder.CommandContext;
|
||||||
|
import net.minestom.server.command.builder.arguments.Argument;
|
||||||
import net.minestom.server.command.builder.arguments.ArgumentEnum;
|
import net.minestom.server.command.builder.arguments.ArgumentEnum;
|
||||||
import net.minestom.server.command.builder.arguments.ArgumentType;
|
import net.minestom.server.command.builder.arguments.ArgumentType;
|
||||||
import net.minestom.server.command.builder.arguments.minecraft.registry.ArgumentEntityType;
|
import net.minestom.server.command.builder.arguments.minecraft.registry.ArgumentEntityType;
|
||||||
import net.minestom.server.command.builder.arguments.relative.ArgumentRelativeVec3;
|
import net.minestom.server.command.builder.arguments.relative.ArgumentRelativeVec3;
|
||||||
import net.minestom.server.command.builder.condition.Conditions;
|
import net.minestom.server.command.builder.condition.Conditions;
|
||||||
|
import net.minestom.server.coordinate.Vec;
|
||||||
import net.minestom.server.entity.Entity;
|
import net.minestom.server.entity.Entity;
|
||||||
import net.minestom.server.entity.EntityCreature;
|
import net.minestom.server.entity.EntityCreature;
|
||||||
import net.minestom.server.entity.EntityType;
|
import net.minestom.server.entity.EntityType;
|
||||||
import net.minestom.server.entity.LivingEntity;
|
import net.minestom.server.entity.LivingEntity;
|
||||||
|
import net.minestom.server.utils.location.RelativeVec;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class SummonCommand extends Command {
|
public class SummonCommand extends Command {
|
||||||
|
|
||||||
private final ArgumentEntityType entity;
|
private final ArgumentEntityType entity;
|
||||||
private final ArgumentRelativeVec3 pos;
|
private final Argument<RelativeVec> pos;
|
||||||
private final ArgumentEnum<EntityClass> entityClass;
|
private final Argument<EntityClass> entityClass;
|
||||||
|
|
||||||
public SummonCommand() {
|
public SummonCommand() {
|
||||||
super("summon");
|
super("summon");
|
||||||
setCondition(Conditions::playerOnly);
|
setCondition(Conditions::playerOnly);
|
||||||
|
|
||||||
entity = ArgumentType.EntityType("entity type");
|
entity = ArgumentType.EntityType("entity type");
|
||||||
pos = ArgumentType.RelativeVec3("pos");
|
pos = ArgumentType.RelativeVec3("pos").setDefaultValue(() -> new RelativeVec(
|
||||||
entityClass = ArgumentType.Enum("class", EntityClass.class);
|
new Vec(0, 0, 0),
|
||||||
entityClass.setFormat(ArgumentEnum.Format.LOWER_CASED);
|
RelativeVec.CoordinateType.RELATIVE,
|
||||||
entityClass.setDefaultValue(EntityClass.CREATURE);
|
true, true, true
|
||||||
|
));
|
||||||
|
entityClass = ArgumentType.Enum("class", EntityClass.class)
|
||||||
|
.setFormat(ArgumentEnum.Format.LOWER_CASED)
|
||||||
|
.setDefaultValue(EntityClass.CREATURE);;
|
||||||
addSyntax(this::execute, entity, pos, entityClass);
|
addSyntax(this::execute, entity, pos, entityClass);
|
||||||
setDefaultExecutor((sender, context) -> sender.sendMessage("Usage: /summon <type> <x> <y> <z> <class>"));
|
setDefaultExecutor((sender, context) -> sender.sendMessage("Usage: /summon <type> <x> <y> <z> <class>"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user