add ability to input seeds as strings

This commit is contained in:
C10udburst
2021-08-26 10:58:37 +02:00
parent cc9847138d
commit 2b79b81c92
2 changed files with 21 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
package cloudburst.rejects.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.command.CommandSource;
@@ -16,8 +17,6 @@ import meteordevelopment.meteorclient.utils.Utils;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
import com.mojang.brigadier.arguments.LongArgumentType;
public class SeedCommand extends Command {
private final static SimpleCommandExceptionType NO_SEED = new SimpleCommandExceptionType(new LiteralText("No seed for current world saved."));
@@ -54,15 +53,15 @@ public class SeedCommand extends Command {
return SINGLE_SUCCESS;
}));
builder.then(argument("seed", LongArgumentType.longArg()).executes(ctx -> {
Seeds.get().setSeed(LongArgumentType.getLong(ctx, "seed"));
builder.then(argument("seed", StringArgumentType.string()).executes(ctx -> {
Seeds.get().setSeed(StringArgumentType.getString(ctx, "seed"));
return SINGLE_SUCCESS;
}));
builder.then(argument("seed", LongArgumentType.longArg()).then(argument("version", EnumArgumentType.enumArgument(MCVersion.latest())).executes(ctx -> {
Seeds.get().setSeed(LongArgumentType.getLong(ctx, "seed"), EnumArgumentType.getEnum(ctx, "version", MCVersion.latest()));
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;
})));
}
}
}