Search in sources :

Example 1 with Seed

use of anticope.rejects.utils.seeds.Seed in project meteor-rejects by AntiCope.

the class SeedCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(ctx -> {
        Seed seed = Seeds.get().getSeed();
        if (seed == null)
            throw NO_SEED.create();
        info(seed.toText());
        return SINGLE_SUCCESS;
    });
    builder.then(literal("list").executes(ctx -> {
        Seeds.get().seeds.forEach((name, seed) -> {
            BaseText text = new LiteralText(name + " ");
            text.append(seed.toText());
            info(text);
        });
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("delete").executes(ctx -> {
        Seed seed = Seeds.get().getSeed();
        if (seed != null) {
            BaseText text = new LiteralText("Deleted ");
            text.append(seed.toText());
            info(text);
        }
        Seeds.get().seeds.remove(Utils.getWorldName());
        return SINGLE_SUCCESS;
    }));
    builder.then(argument("seed", StringArgumentType.string()).executes(ctx -> {
        Seeds.get().setSeed(StringArgumentType.getString(ctx, "seed"));
        return SINGLE_SUCCESS;
    }));
    builder.then(argument("seed", StringArgumentType.string()).then(argument("version", EnumArgumentType.enumArgument(MCVersion.latest())).executes(ctx -> {
        Seeds.get().setSeed(StringArgumentType.getString(ctx, "seed"), EnumArgumentType.getEnum(ctx, "version", MCVersion.latest()));
        return SINGLE_SUCCESS;
    })));
}
Also used : LiteralText(net.minecraft.text.LiteralText) MCVersion(com.seedfinding.mccore.version.MCVersion) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandSource(net.minecraft.command.CommandSource) Seed(anticope.rejects.utils.seeds.Seed) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) BaseText(net.minecraft.text.BaseText) Command(meteordevelopment.meteorclient.systems.commands.Command) EnumArgumentType(anticope.rejects.arguments.EnumArgumentType) Seeds(anticope.rejects.utils.seeds.Seeds) Utils(meteordevelopment.meteorclient.utils.Utils) BaseText(net.minecraft.text.BaseText) Seed(anticope.rejects.utils.seeds.Seed) LiteralText(net.minecraft.text.LiteralText)

Aggregations

EnumArgumentType (anticope.rejects.arguments.EnumArgumentType)1 Seed (anticope.rejects.utils.seeds.Seed)1 Seeds (anticope.rejects.utils.seeds.Seeds)1 SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)1 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)1 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)1 SimpleCommandExceptionType (com.mojang.brigadier.exceptions.SimpleCommandExceptionType)1 MCVersion (com.seedfinding.mccore.version.MCVersion)1 Command (meteordevelopment.meteorclient.systems.commands.Command)1 Utils (meteordevelopment.meteorclient.utils.Utils)1 CommandSource (net.minecraft.command.CommandSource)1 BaseText (net.minecraft.text.BaseText)1 LiteralText (net.minecraft.text.LiteralText)1