@Test
void type() {
var bool = BoolArgumentType.bool();
assertEquals(bool, mapper.type(Argument.of("test", bool).build()));
assertEquals(PlayerType.WORD, mapper.type(Argument.of("test", new PlayerType()).build()));
}
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = literal("spawn").
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandSpawn));
literalargumentbuilder.
then(literal("list").
then(argument("pos", BlockPosArgumentType.blockPos()).
executes( (c) -> listSpawns(c.getSource(), BlockPosArgumentType.getBlockPos(c, "pos"))))).
then(literal("tracking").
executes( (c) -> printTrackingReport(c.getSource())).
then(literal("start").
executes( (c) -> startTracking(c.getSource(), null, null)).
then(argument("from", BlockPosArgumentType.blockPos()).
then(argument("to", BlockPosArgumentType.blockPos()).
executes( (c) -> startTracking(
c.getSource(),
BlockPosArgumentType.getBlockPos(c, "from"),
BlockPosArgumentType.getBlockPos(c, "to")))))).
then(literal("stop").
executes( (c) -> stopTracking(c.getSource()))).
then(argument("type", word()).
suggests( (c, b) -> suggestMatching(Arrays.stream(EntityCategory.values()).map(EntityCategory::getName),b)).
executes( (c) -> recentSpawnsForType(c.getSource(), getString(c, "type"))))).
then(literal("test").
executes( (c)-> runTest(c.getSource(), 72000, null)).
then(argument("ticks", integer(10,720000)).
executes( (c)-> runTest(
c.getSource(),
getInteger(c, "ticks"),
null)).
then(argument("counter", word()).
suggests( (c, b) -> suggestMatching(Arrays.stream(DyeColor.values()).map(DyeColor::toString),b)).
executes((c)-> runTest(
c.getSource(),
getInteger(c, "ticks"),
getString(c, "counter")))))).
then(literal("mocking").
then(argument("to do or not to do?", BoolArgumentType.bool()).
executes( (c) -> toggleMocking(c.getSource(), BoolArgumentType.getBool(c, "to do or not to do?"))))).
then(literal("rates").
executes( (c) -> generalMobcaps(c.getSource())).
then(literal("reset").
executes( (c) -> resetSpawnRates(c.getSource()))).
then(argument("type", word()).
suggests( (c, b) -> suggestMatching(Arrays.stream(EntityCategory.values()).map(EntityCategory::getName),b)).
then(argument("rounds", integer(0)).
suggests( (c, b) -> suggestMatching(new String[]{"1"},b)).
executes( (c) -> setSpawnRates(
c.getSource(),
getString(c, "type"),
getInteger(c, "rounds")))))).
then(literal("mobcaps").
executes( (c) -> generalMobcaps(c.getSource())).
then(literal("set").
then(argument("cap (hostile)", integer(1,1400)).
executes( (c) -> setMobcaps(c.getSource(), getInteger(c, "cap (hostile)"))))).
then(argument("dimension", DimensionArgumentType.dimension()).
executes( (c)-> mobcapsForDimension(c.getSource(), DimensionArgumentType.getDimensionArgument(c, "dimension"))))).
then(literal("entities").
executes( (c) -> generalMobcaps(c.getSource()) ).
then(argument("type", string()).
suggests( (c, b)->suggestMatching(Arrays.stream(EntityCategory.values()).map(EntityCategory::getName), b)).
executes( (c) -> listEntitiesOfType(c.getSource(), getString(c, "type"), false)).
then(literal("all").executes( (c) -> listEntitiesOfType(c.getSource(), getString(c, "type"), true)))));
dispatcher.register(literalargumentbuilder);
}
/**
* An Boolean argument
*/
public BooleanArgument() {
super(BoolArgumentType.bool());
}