Fix up tab completion for EntityType

This commit is contained in:
LeoDog896 2021-08-25 18:35:51 -04:00
parent 748b24b8ef
commit 811e3c542b
2 changed files with 14 additions and 7 deletions

View File

@ -23,7 +23,7 @@ public class ArgumentEntityType extends ArgumentRegistry<EntityType> {
@Override
public void processNodes(@NotNull NodeMaker nodeMaker, boolean executable) {
DeclareCommandsPacket.Node argumentNode = simpleArgumentNode(this, executable, false, true);
argumentNode.parser = "minecraft:entity_summon";
argumentNode.parser = "minecraft:resource_location";
argumentNode.suggestionsType = SuggestionType.SUMMONABLE_ENTITIES.getIdentifier();
nodeMaker.addNodes(new DeclareCommandsPacket.Node[]{argumentNode});

View File

@ -3,32 +3,39 @@ package demo.commands;
import net.minestom.server.command.CommandSender;
import net.minestom.server.command.builder.Command;
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.ArgumentType;
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.condition.Conditions;
import net.minestom.server.coordinate.Vec;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.LivingEntity;
import net.minestom.server.utils.location.RelativeVec;
import org.jetbrains.annotations.NotNull;
public class SummonCommand extends Command {
private final ArgumentEntityType entity;
private final ArgumentRelativeVec3 pos;
private final ArgumentEnum<EntityClass> entityClass;
private final Argument<RelativeVec> pos;
private final Argument<EntityClass> entityClass;
public SummonCommand() {
super("summon");
setCondition(Conditions::playerOnly);
entity = ArgumentType.EntityType("entity type");
pos = ArgumentType.RelativeVec3("pos");
entityClass = ArgumentType.Enum("class", EntityClass.class);
entityClass.setFormat(ArgumentEnum.Format.LOWER_CASED);
entityClass.setDefaultValue(EntityClass.CREATURE);
pos = ArgumentType.RelativeVec3("pos").setDefaultValue(() -> new RelativeVec(
new Vec(0, 0, 0),
RelativeVec.CoordinateType.RELATIVE,
true, true, true
));
entityClass = ArgumentType.Enum("class", EntityClass.class)
.setFormat(ArgumentEnum.Format.LOWER_CASED)
.setDefaultValue(EntityClass.CREATURE);;
addSyntax(this::execute, entity, pos, entityClass);
setDefaultExecutor((sender, context) -> sender.sendMessage("Usage: /summon <type> <x> <y> <z> <class>"));
}