Auto Fill in commands

Started by Даниил Власов on

Topic category: Help with MCreator software

Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Auto Fill in commands

Hello. I'm making a warps system. And I need all created warps to appear in the autocomplete when I enter the warp command. Help please.

Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
here is my command code:…
Sat, 07/20/2024 - 23:33

here is my command code:"package net.mcreator.simplewarp.command;

/* imports omitted */

public class WarpCommand {

    public static void register(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandBuildContext, Commands.CommandSelection environment) {
        dispatcher.register(Commands.literal("warp").requires(s -> s.hasPermission(4))
                .then(Commands.literal("create").then(Commands.argument("WarpName", StringArgumentType.word()).then(Commands.argument("arguments", StringArgumentType.greedyString()).executes(arguments -> {
                    ServerLevel world = arguments.getSource().getLevel();

                    double x = arguments.getSource().getPosition().x();
                    double y = arguments.getSource().getPosition().y();
                    double z = arguments.getSource().getPosition().z();

                    Entity entity = arguments.getSource().getEntity();

                    Direction direction = Direction.DOWN;
                    if (entity != null)
                        direction = entity.getDirection();

                    HashMap<String, String> cmdparams = new HashMap<>();
                    int index = -1;
                    for (String param : arguments.getInput().split("\\s+")) {
                        if (index >= 0)
                            cmdparams.put(Integer.toString(index), param);
                        index++;
                    }

                    CreateWarpProcedure.execute(arguments, entity);
                    return 0;
                })).executes(arguments -> {
                    ServerLevel world = arguments.getSource().getLevel();

                    double x = arguments.getSource().getPosition().x();
                    double y = arguments.getSource().getPosition().y();
                    double z = arguments.getSource().getPosition().z();

                    Entity entity = arguments.getSource().getEntity();

                    Direction direction = Direction.DOWN;
                    if (entity != null)
                        direction = entity.getDirection();

                    HashMap<String, String> cmdparams = new HashMap<>();
                    int index = -1;
                    for (String param : arguments.getInput().split("\\s+")) {
                        if (index >= 0)
                            cmdparams.put(Integer.toString(index), param);
                        index++;
                    }

                    CreateWarpProcedure.execute(arguments, entity);
                    return 0;
                }))).then(Commands.literal("remove").then(Commands.argument("WarpName", StringArgumentType.word()).then(Commands.argument("arguments", StringArgumentType.greedyString()).executes(arguments -> {
                    ServerLevel world = arguments.getSource().getLevel();

                    double x = arguments.getSource().getPosition().x();
                    double y = arguments.getSource().getPosition().y();
                    double z = arguments.getSource().getPosition().z();

                    Entity entity = arguments.getSource().getEntity();

                    Direction direction = Direction.DOWN;
                    if (entity != null)
                        direction = entity.getDirection();

                    HashMap<String, String> cmdparams = new HashMap<>();
                    int index = -1;
                    for (String param : arguments.getInput().split("\\s+")) {
                        if (index >= 0)
                            cmdparams.put(Integer.toString(index), param);
                        index++;
                    }

                    RemoveWarpProcedure.execute(arguments, entity);
                    return 0;
                })).executes(arguments -> {
                    ServerLevel world = arguments.getSource().getLevel();

                    double x = arguments.getSource().getPosition().x();
                    double y = arguments.getSource().getPosition().y();
                    double z = arguments.getSource().getPosition().z();

                    Entity entity = arguments.getSource().getEntity();

                    Direction direction = Direction.DOWN;
                    if (entity != null)
                        direction = entity.getDirection();

                    HashMap<String, String> cmdparams = new HashMap<>();
                    int index = -1;
                    for (String param : arguments.getInput().split("\\s+")) {
                        if (index >= 0)
                            cmdparams.put(Integer.toString(index), param);
                        index++;
                    }

                    RemoveWarpProcedure.execute(arguments, entity);
                    return 0;
                }))).then(Commands.argument("WarpName", StringArgumentType.word()).then(Commands.argument("arguments", StringArgumentType.greedyString()).executes(arguments -> {
                    ServerLevel world = arguments.getSource().getLevel();

                    double x = arguments.getSource().getPosition().x();
                    double y = arguments.getSource().getPosition().y();
                    double z = arguments.getSource().getPosition().z();

                    Entity entity = arguments.getSource().getEntity();

                    Direction direction = Direction.DOWN;
                    if (entity != null)
                        direction = entity.getDirection();

                    HashMap<String, String> cmdparams = new HashMap<>();
                    int index = -1;
                    for (String param : arguments.getInput().split("\\s+")) {
                        if (index >= 0)
                            cmdparams.put(Integer.toString(index), param);
                        index++;
                    }

                    TeleportToWarpProcedure.execute(world, x, y, z, arguments, entity);
                    return 0;
                })).executes(arguments -> {
                    ServerLevel world = arguments.getSource().getLevel();

                    double x = arguments.getSource().getPosition().x();
                    double y = arguments.getSource().getPosition().y();
                    double z = arguments.getSource().getPosition().z();

                    Entity entity = arguments.getSource().getEntity();

                    Direction direction = Direction.DOWN;
                    if (entity != null)
                        direction = entity.getDirection();

                    HashMap<String, String> cmdparams = new HashMap<>();
                    int index = -1;
                    for (String param : arguments.getInput().split("\\s+")) {
                        if (index >= 0)
                            cmdparams.put(Integer.toString(index), param);
                        index++;
                    }

                    TeleportToWarpProcedure.execute(world, x, y, z, arguments, entity);
                    return 0;
                })));
    }

}"